From b028739e4fce3d1b8e1ac5009f2e2def2f53f2e2 Mon Sep 17 00:00:00 2001 Message-Id: From: Eric Blake Date: Tue, 28 Oct 2014 08:21:17 -0600 Subject: [PATCH] qemu: forbid snapshot-delete --children-only on external snapshot 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 (cherry picked from commit 2086a9905aac877d1618f96c7eea8e3d6a01fd9a) Signed-off-by: Jiri Denemark --- src/qemu/qemu_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3c1d2f5..88a1895 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14612,7 +14612,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); -- 2.1.3