]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
qemu: snapshot: Fix incorrect disk type for auto-generated disks
authorPeter Krempa <pkrempa@redhat.com>
Thu, 5 Dec 2013 14:58:31 +0000 (15:58 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 6 Dec 2013 09:45:49 +0000 (10:45 +0100)
When changing the parsing and formatting functions in commit
43f2ccdc73090bd03f64de4d58d46ffa0134d705 I forgot to update the qemu
disk alignment 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.

src/conf/snapshot_conf.c

index 563797529c6ecb1fb79be71ec7d9ea90745d6cce..c18b99b6a999194169978d2c5e365fa2f75daf20 100644 (file)
@@ -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 "