[libvirt] [PATCHv2 2/2] conf: snapshot: Don't default-snapshot empty drives

Peter Krempa pkrempa at redhat.com
Thu Sep 11 17:54:58 UTC 2014


If a (floppy) drive isn't selected for snapshot explicitly and is empty
don't try to snapshot it. For external snapshots this would fail as we
can't generate a name for the snapshot from an empty drive.

Reported-by: Pavel Hrdina <phrdina at redhat.com>
---

Version 2 now doesn't discriminate according to drive type

 src/conf/snapshot_conf.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index c53a66b..4f99139 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -561,7 +561,13 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
         if (VIR_STRDUP(disk->name, def->dom->disks[i]->dst) < 0)
             goto cleanup;
         disk->index = i;
-        disk->snapshot = def->dom->disks[i]->snapshot;
+
+        /* Don't snapshot empty drives */
+        if (virStorageSourceIsEmpty(def->dom->disks[i]->src))
+            disk->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_NONE;
+        else
+            disk->snapshot = def->dom->disks[i]->snapshot;
+
         disk->src->type = VIR_STORAGE_TYPE_FILE;
         if (!disk->snapshot)
             disk->snapshot = default_snapshot;
-- 
2.1.0




More information about the libvir-list mailing list