diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2014-06-12 11:33:16 +0200 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2014-06-12 11:55:58 +0200 |
commit | 922f884abeae010589fa775b022d284dfec9e075 (patch) | |
tree | e4060ed0eb9c7ae84a31a206d4c6fb64adbc6893 | |
parent | c230ae95abf4e0dd08183c37d204b0145ce0a5e8 (diff) | |
download | lvm2-922f884abeae010589fa775b022d284dfec9e075.tar.gz |
report: avoid passing NULL label
Internal reporting function cannot handle NULL reporting value,
so ensure there is at least dummy label.
So move dummy_lable from tools/reporter.c and use it for all
report_object() calls in lib/report/report.c.
(Fixes RHBZ 1108394)
Simlify lvm_report_object initialization.
-rw-r--r-- | WHATS_NEW | 1 | ||||
-rw-r--r-- | lib/report/report.c | 32 | ||||
-rw-r--r-- | tools/reporter.c | 20 |
3 files changed, 26 insertions, 27 deletions
@@ -1,5 +1,6 @@ Version 2.02.107 - ================================== + Fix crash when reporting of empty labels on pvs. Use retry_deactivation also when cleaning orphan devices. Prompt when setting the VG cluster attr if the cluster is not setup. Allow --yes to skip prompt in vgextend (worked only with -f). diff --git a/lib/report/report.c b/lib/report/report.c index 681e80c9a..6b32beea6 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -1274,19 +1274,35 @@ int report_object(void *handle, struct volume_group *vg, struct lv_segment *seg, struct pv_segment *pvseg, struct label *label) { - struct lvm_report_object obj; + struct device dummy_device = { .dev = 0 }; + struct label dummy_label = { .dev = &dummy_device }; + struct lvm_report_object obj = { + .vg = vg, + .lv = lv, + .pv = pv, + .seg = seg, + .pvseg = pvseg, + .label = label ? : (pv ? pv_label(pv) : NULL) + }; + + /* FIXME workaround for pv_label going through cache; remove once struct + * physical_volume gains a proper "label" pointer */ + if (!obj.label) { + if (pv) { + if (pv->fmt) + dummy_label.labeller = pv->fmt->labeller; + if (pv->dev) + dummy_label.dev = pv->dev; + else + memcpy(dummy_device.pvid, &pv->id, ID_LEN); + } + obj.label = &dummy_label; + } /* The two format fields might as well match. */ if (!vg && pv) _dummy_fid.fmt = pv->fmt; - obj.vg = vg; - obj.lv = lv; - obj.pv = pv; - obj.seg = seg; - obj.pvseg = pvseg; - obj.label = label ? label : (pv ? pv_label(pv) : NULL); - return dm_report_object(handle, &obj); } diff --git a/tools/reporter.c b/tools/reporter.c index b4a0c0b1d..b20b8ed9c 100644 --- a/tools/reporter.c +++ b/tools/reporter.c @@ -140,9 +140,6 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg, const char *vg_name = NULL; struct volume_group *old_vg = vg; char uuid[64] __attribute__((aligned(8))); - struct label *label; - struct label dummy_label = { .dev = 0 }; - struct device dummy_device = { .dev = 0 }; if (is_pv(pv) && !is_orphan(pv) && !vg) { vg_name = pv_vg_name(pv); @@ -180,22 +177,7 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg, pv = pvl->pv; } - /* FIXME workaround for pv_label going through cache; remove once struct - * physical_volume gains a proper "label" pointer */ - if (!(label = pv_label(pv))) { - if (pv->fmt) - dummy_label.labeller = pv->fmt->labeller; - - if (pv->dev) - dummy_label.dev = pv->dev; - else { - dummy_label.dev = &dummy_device; - memcpy(dummy_device.pvid, &pv->id, ID_LEN); - } - label = &dummy_label; - } - - if (!report_object(handle, vg, NULL, pv, NULL, NULL, label)) { + if (!report_object(handle, vg, NULL, pv, NULL, NULL, NULL)) { stack; ret = ECMD_FAILED; } |