separate virDomainDefParseVirtTypeInfo from virDomainDefParseXML
---
 src/conf/domain_conf.c | 48 ++++++++++++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 055404e..bf2cf7f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18565,6 +18565,36 @@ virDomainDefParseIdInfo(virDomainParseTotalParamPtr 
param)
 }
 
 
+static int
+virDomainDefParseVirtTypeInfo(virDomainParseTotalParamPtr param)
+{
+    virDomainDefPtr def = param->def;
+    xmlXPathContextPtr ctxt = param->ctxt;
+    char *tmp = NULL;
+    int virtType;
+    int ret = -1;
+
+    /* Find out what type of virtualization to use */
+    if (!(tmp = virXMLPropString(ctxt->node, "type"))) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "%s", _("missing domain type attribute"));
+        goto cleanup;
+    }
+
+    if ((virtType = virDomainVirtTypeFromString(tmp)) < 0) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("invalid domain type %s"), tmp);
+        goto cleanup;
+    }
+    def->virtType = virtType;
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(tmp);
+    return ret;
+}
+
+
 static virDomainDefPtr
 virDomainDefParseXML(xmlDocPtr xml,
                      xmlNodePtr root,
@@ -18579,7 +18609,7 @@ virDomainDefParseXML(xmlDocPtr xml,
     xmlNodePtr *nodes = NULL, node = NULL;
     char *tmp = NULL;
     size_t i, j;
-    int n, virtType, gic_version;
+    int n, gic_version;
     size_t fun_index = 0;
     virDomainDefPtr def;
     bool uuid_generated = false;
@@ -18606,6 +18636,7 @@ virDomainDefParseXML(xmlDocPtr xml,
 
     virDomainPreaseInfoFunc parse_funs[] = {
             virDomainDefParseIdInfo,
+            virDomainDefParseVirtTypeInfo,
             NULL
     };
 
@@ -18633,21 +18664,6 @@ virDomainDefParseXML(xmlDocPtr xml,
         fun_index++;
     }
 
-    /* Find out what type of virtualization to use */
-    if (!(tmp = virXMLPropString(ctxt->node, "type"))) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "%s", _("missing domain type attribute"));
-        goto error;
-    }
-
-    if ((virtType = virDomainVirtTypeFromString(tmp)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("invalid domain type %s"), tmp);
-        goto error;
-    }
-    def->virtType = virtType;
-    VIR_FREE(tmp);
-
     def->os.bootloader = virXPathString("string(./bootloader)", ctxt);
     def->os.bootloaderArgs = virXPathString("string(./bootloader_args)", ctxt);
 
-- 
2.8.3


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to