[libvirt] [PATCH 0/2] qemu: fix snapshot crasher bug and improve virsh (blockdev-add saga)

While reviewers liked my story plot, the CPU did not. Fix it to make everyone happy. Peter Krempa (2): qemu: driver: Fix off-by-one in qemuDomainSnapshotDiskDataCollect virsh: snapshot: Don't block --no-metadata with --print-xml src/qemu/qemu_driver.c | 2 +- tools/virsh-snapshot.c | 8 +------- tools/virsh.pod | 4 ++-- 3 files changed, 4 insertions(+), 10 deletions(-) -- 2.21.0

Commit f34397e51c17 introduced a crash-inducing problem when collecting disk snapshot data, where the array would be filled starting from the second element. The code then dereferenced the first one. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 40a2aa440f..ec08dd939e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15073,8 +15073,8 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr driver, if (snapdef->disks[i].snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE) continue; - ndata++; dd = data + ndata; + ndata++; dd->disk = vm->def->disks[i]; -- 2.21.0

On Thu, Jun 20, 2019 at 03:47:56PM +0200, Peter Krempa wrote:
Commit f34397e51c17 introduced a crash-inducing problem when collecting disk snapshot data, where the array would be filled starting from the second element.
The code then dereferenced the first one.
How did this get past review?
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

When testing stuff you might want to print the XML. Interlocking it with no metadata adds exactly 0 value to the user. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tools/virsh-snapshot.c | 8 +------- tools/virsh.pod | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index f6bb38bc96..e9f0ee0810 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -369,14 +369,8 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; const vshCmdOpt *opt = NULL; - if (vshCommandOptBool(cmd, "no-metadata")) { - if (vshCommandOptBool(cmd, "print-xml")) { - vshError(ctl, "%s", - _("--print-xml is incompatible with --no-metadata")); - return false; - } + if (vshCommandOptBool(cmd, "no-metadata")) flags |= VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA; - } if (vshCommandOptBool(cmd, "halt")) flags |= VIR_DOMAIN_SNAPSHOT_CREATE_HALT; if (vshCommandOptBool(cmd, "disk-only")) diff --git a/tools/virsh.pod b/tools/virsh.pod index 2e70b68a66..dc39004a66 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -4653,7 +4653,7 @@ metadata is silently lost when the domain quits running (whether by command such as B<destroy> or by internal guest action). =item B<snapshot-create-as> I<domain> {[I<--print-xml>] -| [I<--no-metadata>] [I<--halt>] [I<--reuse-external>]} [I<name>] +[I<--no-metadata>] [I<--halt>] [I<--reuse-external>]} [I<name>] [I<description>] [I<--disk-only> [I<--quiesce>]] [I<--atomic>] [[I<--live>] [I<--memspec> B<memspec>]] [I<--diskspec>] B<diskspec>]... @@ -4703,7 +4703,7 @@ If I<--no-metadata> is specified, then the snapshot data is created, but any metadata is immediately discarded (that is, libvirt does not treat the snapshot as current, and cannot revert to the snapshot unless B<snapshot-create> is later used to teach libvirt about the -metadata again). This flag is incompatible with I<--print-xml>. +metadata again). If I<--atomic> is specified, libvirt will guarantee that the snapshot either succeeds, or fails with no changes; not all hypervisors support -- 2.21.0

On Thu, Jun 20, 2019 at 03:47:57PM +0200, Peter Krempa wrote:
When testing stuff you might want to print the XML. Interlocking it with no metadata adds exactly 0 value to the user.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tools/virsh-snapshot.c | 8 +------- tools/virsh.pod | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa