]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Move <disk> encryption validation
authorJohn Ferlan <jferlan@redhat.com>
Thu, 14 Sep 2017 15:01:40 +0000 (11:01 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 15 Sep 2017 12:12:26 +0000 (08:12 -0400)
Rather than checking during XML processing, move the check for
valid <encryption> into virDomainDiskDefParseValidate and alter
the text of the message slightly to be a bit more correct.

src/conf/domain_conf.c

index aefe6f989e185daafd28209e21c5880df40c7cff..f1b2447def0c056a1689851d0da79b160c0c7635 100644 (file)
@@ -8605,6 +8605,19 @@ virDomainDiskDefParseValidate(const virDomainDiskDef *def)
     if (virDomainDiskSourceDefParseAuthValidate(def->src) < 0)
         return -1;
 
+    if (def->src->encryption) {
+        virStorageEncryptionPtr encryption = def->src->encryption;
+
+        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;
+        }
+    }
+
     return 0;
 }
 
@@ -9095,17 +9108,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
         def->startupPolicy = val;
     }
 
-    if (encryption) {
-        if (encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS &&
-            encryption->encinfo.cipher_name) {
-
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("supplying the <cipher> for a domain is "
-                             "unnecessary"));
-            goto error;
-        }
-    }
-
     def->dst = target;
     target = NULL;
     def->src->auth = authdef;