]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Validate disk source configuration also for the backing store
authorPeter Krempa <pkrempa@redhat.com>
Thu, 8 Mar 2018 16:23:46 +0000 (17:23 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 14 Mar 2018 11:19:44 +0000 (12:19 +0100)
Since we already parse the <backingStore> of a disk source, we should
also validate the configuration for the whole backing chain and not only
for the top level image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
src/conf/domain_conf.c

index 1c79d2b49bea952aadb0d76e2856d9bfa2db749a..8cd41edb5e37915b22081abd39358b0d0701877b 100644 (file)
@@ -8974,6 +8974,8 @@ virDomainDiskSourceDefParseAuthValidate(const virStorageSource *src)
 static int
 virDomainDiskDefParseValidate(const virDomainDiskDef *def)
 {
+    virStorageSourcePtr next;
+
     if (def->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) {
         if (def->event_idx != VIR_TRISTATE_SWITCH_ABSENT) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -9044,19 +9046,21 @@ virDomainDiskDefParseValidate(const virDomainDiskDef *def)
         }
     }
 
-    if (virDomainDiskSourceDefParseAuthValidate(def->src) < 0)
-        return -1;
+    for (next = def->src; next; next = next->backingStore) {
+        if (virDomainDiskSourceDefParseAuthValidate(next) < 0)
+            return -1;
 
-    if (def->src->encryption) {
-        virStorageEncryptionPtr encryption = def->src->encryption;
+        if (next->encryption) {
+            virStorageEncryptionPtr encryption = next->encryption;
 
-        if (encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS &&
-            encryption->encinfo.cipher_name) {
+            if (encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS &&
+                encryption->encinfo.cipher_name) {
 
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("supplying <cipher> for domain disk definition "
-                             "is unnecessary"));
-            return -1;
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("supplying <cipher> for domain disk definition "
+                                 "is unnecessary"));
+                return -1;
+            }
         }
     }