[PATCH v3 09/14] domain_conf.c: move smartcard address check to domain_validate.c

Daniel Henrique Barboza danielhb413 at gmail.com
Tue Dec 8 22:20:25 UTC 2020


This check is not tied to XML parsing and can be moved to
virDomainSmartcardDefValidate().

Reviewed-by: Michal Privoznik <mprivozn at redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 src/conf/domain_conf.c     | 7 -------
 src/conf/domain_validate.c | 7 +++++++
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a301ab5c74..a5dcb0bbce 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13222,13 +13222,6 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr xmlopt,
     if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0)
         return NULL;
 
-    if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
-        def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Controllers must use the 'ccid' address type"));
-        return NULL;
-    }
-
     return g_steal_pointer(&def);
 }
 
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 882fbdac57..6fca604d17 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -484,6 +484,13 @@ int
 virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard,
                               const virDomainDef *def)
 {
+    if (smartcard->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+        smartcard->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Controllers must use the 'ccid' address type"));
+        return -1;
+    }
+
     if (smartcard->type == VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH)
         return virDomainChrSourceDefValidate(smartcard->data.passthru, NULL, def);
 
-- 
2.26.2




More information about the libvir-list mailing list