[PATCH] qemu: snapshot: Fix incorrect disk type for auto-generated disks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When changing the parsing and formatting functions in commit
43f2ccdc73090bd03f64de4d58d46ffa0134d705 I forgot to update the qemu
disk alingnment function for snapshots that automatically adds snapshot
configs for disks that were not mentioned in the XML. The function
allocated a new disk snapshot definition but did not correctly
initialize the snapshot disk source type variable. This resulted into
the disks considered as block devices and invalid XML was generated.

Reported by John Ferlan.
---

Notes:
    Doing a unit test for this will require yet another addition to the testsuite
    so I'm sending this patch first.

 src/conf/snapshot_conf.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 5637975..55abd80 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -532,6 +532,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
             goto cleanup;
         disk->index = i;
         disk->snapshot = def->dom->disks[i]->snapshot;
+        disk->type = -1;
         if (!disk->snapshot)
             disk->snapshot = default_snapshot;
     }
@@ -549,6 +550,15 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
             const char *tmp;
             struct stat sb;

+            if (disk->type != VIR_DOMAIN_DISK_TYPE_FILE ||
+                disk->type != -1) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("cannot generate external snapshot name "
+                                 "for disk '%s' on a '%s' device"),
+                               disk->name, virDomainDiskTypeToString(disk->type));
+                goto cleanup;
+            }
+
             if (!original) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                _("cannot generate external snapshot name "
-- 
1.8.4.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]