[libvirt] [PATCH 5/6] conf: Move <disk> encryption validation

John Ferlan jferlan at redhat.com
Thu Sep 14 18:03:09 UTC 2017


Rather than checking during XML processing, move the check for
valid <encryption> into virDomainDiskDefParseValidate.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/conf/domain_conf.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 07bda1a36..09c5bc1ae 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8605,7 +8605,23 @@ virDomainDiskDefParseValidate(const virDomainDiskDef *def)
         }
     }
 
-    return virDomainDiskSourceDefParseAuthValidate(def->src);
+    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 the <cipher> for a domain is "
+                             "unnecessary"));
+            return -1;
+        }
+    }
+
+    return 0;
 }
 
 
@@ -9095,17 +9111,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;
-- 
2.13.5




More information about the libvir-list mailing list