render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
9119d9
From b028739e4fce3d1b8e1ac5009f2e2def2f53f2e2 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <b028739e4fce3d1b8e1ac5009f2e2def2f53f2e2@dist-git>
9119d9
From: Eric Blake <eblake@redhat.com>
9119d9
Date: Tue, 28 Oct 2014 08:21:17 -0600
9119d9
Subject: [PATCH] qemu: forbid snapshot-delete --children-only on external
9119d9
 snapshot
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=956506 documents that
9119d9
given a domain where an internal snapshot parent has an external
9119d9
snapshot child, we lacked a safety check when trying to use the
9119d9
--children-only option to snapshot-delete:
9119d9
9119d9
$ virsh start dom
9119d9
$ virsh snapshot-create-as dom internal
9119d9
$ virsh snapshot-create-as dom external --disk-only
9119d9
$ virsh snapshot-delete dom external
9119d9
error: Failed to delete snapshot external
9119d9
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
9119d9
$ virsh snapshot-delete dom internal --children
9119d9
error: Failed to delete snapshot internal
9119d9
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
9119d9
$ virsh snapshot-delete dom internal --children-only
9119d9
Domain snapshot internal children deleted
9119d9
9119d9
While I'd still like to see patches that actually do proper external
9119d9
snapshot deletion, we should at least fix the inconsistency in the
9119d9
meantime.  With this patch:
9119d9
9119d9
$ virsh snapshot-delete dom internal --children-only
9119d9
error: Failed to delete snapshot internal
9119d9
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
9119d9
9119d9
* src/qemu/qemu_driver.c (qemuDomainSnapshotDelete): Fix condition.
9119d9
9119d9
Signed-off-by: Eric Blake <eblake@redhat.com>
9119d9
(cherry picked from commit 2086a9905aac877d1618f96c7eea8e3d6a01fd9a)
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/qemu/qemu_driver.c | 3 ++-
9119d9
 1 file changed, 2 insertions(+), 1 deletion(-)
9119d9
9119d9
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
9119d9
index 3c1d2f5..88a1895 100644
9119d9
--- a/src/qemu/qemu_driver.c
9119d9
+++ b/src/qemu/qemu_driver.c
9119d9
@@ -14612,7 +14612,8 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
9119d9
         if (!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) &&
9119d9
             virDomainSnapshotIsExternal(snap))
9119d9
             external++;
9119d9
-        if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN)
9119d9
+        if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN |
9119d9
+                     VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY))
9119d9
             virDomainSnapshotForEachDescendant(snap,
9119d9
                                                qemuDomainSnapshotCountExternal,
9119d9
                                                &external);
9119d9
-- 
9119d9
2.1.3
9119d9