[1/7] conf: Break out virDomainDefParseCaps

Message ID 005b16b12e4cda51ddc497fa4962a1b794d723d9.1532467269.git.crobinso@redhat.com
State Accepted
Commit bd884c566e2f22544055d5fcd6e0adcf990e3921
Headers show
Series
  • conf: Replace SKIP_OSTYPE with SKIP_VALIDATE
Related show

Commit Message

Cole Robinson July 24, 2018, 9:23 p.m.
Handles parse virtType, os.type, bootloader bits, arch, machine,
emulator

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 src/conf/domain_conf.c | 96 +++++++++++++++++++++++++-----------------
 1 file changed, 58 insertions(+), 38 deletions(-)

-- 
2.17.1

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

Patch

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 178c6d2711..7eb5ffc718 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19114,46 +19114,15 @@  virDomainCachetuneDefParse(virDomainDefPtr def,
 }
 
 
-static virDomainDefPtr
-virDomainDefParseXML(xmlDocPtr xml,
-                     xmlNodePtr root,
-                     xmlXPathContextPtr ctxt,
-                     virCapsPtr caps,
-                     virDomainXMLOptionPtr xmlopt,
-                     unsigned int flags)
+static int
+virDomainDefParseCaps(virDomainDefPtr def,
+                      xmlXPathContextPtr ctxt,
+                      virCapsPtr caps,
+                      unsigned int flags)
 {
-    xmlNodePtr *nodes = NULL, node = NULL;
+    int ret = -1;
+    int virtType;
     char *tmp = NULL;
-    size_t i, j;
-    int n, virtType, gic_version;
-    long id = -1;
-    virDomainDefPtr def;
-    bool uuid_generated = false;
-    bool usb_none = false;
-    bool usb_other = false;
-    bool usb_master = false;
-    char *netprefix = NULL;
-
-    if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA) {
-        char *schema = virFileFindResource("domain.rng",
-                                           abs_topsrcdir "/docs/schemas",
-                                           PKGDATADIR "/schemas");
-        if (!schema)
-            return NULL;
-        if (virXMLValidateAgainstSchema(schema, xml) < 0) {
-            VIR_FREE(schema);
-            return NULL;
-        }
-        VIR_FREE(schema);
-    }
-
-    if (!(def = virDomainDefNew()))
-        return NULL;
-
-    if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
-        if (virXPathLong("string(./@id)", ctxt, &id) < 0)
-            id = -1;
-    def->id = (int)id;
 
     /* Find out what type of virtualization to use */
     if (!(tmp = virXMLPropString(ctxt->node, "type"))) {
@@ -19239,6 +19208,57 @@  virDomainDefParseXML(xmlDocPtr xml,
         VIR_FREE(capsdata);
     }
 
+    ret = 0;
+ error:
+    VIR_FREE(tmp);
+    return ret;
+}
+
+
+static virDomainDefPtr
+virDomainDefParseXML(xmlDocPtr xml,
+                     xmlNodePtr root,
+                     xmlXPathContextPtr ctxt,
+                     virCapsPtr caps,
+                     virDomainXMLOptionPtr xmlopt,
+                     unsigned int flags)
+{
+    xmlNodePtr *nodes = NULL, node = NULL;
+    char *tmp = NULL;
+    size_t i, j;
+    int n, gic_version;
+    long id = -1;
+    virDomainDefPtr def;
+    bool uuid_generated = false;
+    bool usb_none = false;
+    bool usb_other = false;
+    bool usb_master = false;
+    char *netprefix = NULL;
+
+    if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA) {
+        char *schema = virFileFindResource("domain.rng",
+                                           abs_topsrcdir "/docs/schemas",
+                                           PKGDATADIR "/schemas");
+        if (!schema)
+            return NULL;
+        if (virXMLValidateAgainstSchema(schema, xml) < 0) {
+            VIR_FREE(schema);
+            return NULL;
+        }
+        VIR_FREE(schema);
+    }
+
+    if (!(def = virDomainDefNew()))
+        return NULL;
+
+    if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
+        if (virXPathLong("string(./@id)", ctxt, &id) < 0)
+            id = -1;
+    def->id = (int)id;
+
+    if (virDomainDefParseCaps(def, ctxt, caps, flags) < 0)
+        goto error;
+
     /* Extract domain name */
     if (!(def->name = virXPathString("string(./name[1])", ctxt))) {
         virReportError(VIR_ERR_NO_NAME, NULL);