]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: forbid snapshot-delete --children-only on external snapshot
authorEric Blake <eblake@redhat.com>
Mon, 27 Oct 2014 11:37:34 +0000 (05:37 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 27 Oct 2014 20:04:47 +0000 (14:04 -0600)
https://bugzilla.redhat.com/show_bug.cgi?id=956506 documents that
given a domain where an internal snapshot parent has an external
snapshot child, we lacked a safety check when trying to use the
--children-only option to snapshot-delete:

$ virsh start dom
$ virsh snapshot-create-as dom internal
$ virsh snapshot-create-as dom external --disk-only
$ virsh snapshot-delete dom external
error: Failed to delete snapshot external
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
$ virsh snapshot-delete dom internal --children
error: Failed to delete snapshot internal
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
$ virsh snapshot-delete dom internal --children-only
Domain snapshot internal children deleted

While I'd still like to see patches that actually do proper external
snapshot deletion, we should at least fix the inconsistency in the
meantime.  With this patch:

$ virsh snapshot-delete dom internal --children-only
error: Failed to delete snapshot internal
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet

* src/qemu/qemu_driver.c (qemuDomainSnapshotDelete): Fix condition.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/qemu/qemu_driver.c

index cd8d3c75e00a800819356536bdb678415bf6d940..5eccacc5e9d3d144f2229a814bb4cb2112f421f2 100644 (file)
@@ -14812,7 +14812,8 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
         if (!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) &&
             virDomainSnapshotIsExternal(snap))
             external++;
-        if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN)
+        if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN |
+                     VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY))
             virDomainSnapshotForEachDescendant(snap,
                                                qemuDomainSnapshotCountExternal,
                                                &external);