]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
src/xenconfig: wrap common parsing code
authorKiarie Kahurani <davidkiarie4@gmail.com>
Mon, 11 Aug 2014 21:21:24 +0000 (00:21 +0300)
committerJim Fehlig <jfehlig@suse.com>
Tue, 19 Aug 2014 02:36:56 +0000 (20:36 -0600)
Wrap parsing code common to xm and xl in xenParseConfigCommon
and export it.

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
src/xenconfig/xen_xm.c
src/xenconfig/xen_xm.h

index 292903e51423b50bccb1d58aaabfaf227c0fc971..e15b77a34423f7b6d3f3ad475fa8fcffff9653fa 100644 (file)
@@ -1263,61 +1263,75 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def)
 }
 
 
-/*
- * Turn a config record into a lump of XML describing the
- * domain, suitable for later feeding for virDomainCreateXML
- */
-virDomainDefPtr
-xenParseXM(virConfPtr conf, int xendConfigVersion,
-           virCapsPtr caps)
+int
+xenParseConfigCommon(virConfPtr conf,
+                     virDomainDefPtr def,
+                     virCapsPtr caps,
+                     int xendConfigVersion)
 {
-    virDomainDefPtr def = NULL;
-
-    if (VIR_ALLOC(def) < 0)
-        return NULL;
-
-    def->virtType = VIR_DOMAIN_VIRT_XEN;
-    def->id = -1;
-
     if (xenParseXMGeneralMeta(conf, def, caps) < 0)
-        goto cleanup;
+        return -1;
 
     if (xenParseXMOS(conf, def) < 0)
-        goto cleanup;
+        return -1;
 
     if (xenParseXMMem(conf, def) < 0)
-        goto cleanup;
+        return -1;
 
     if (xenParseXMEventsActions(conf, def) < 0)
-        goto cleanup;
+        return -1;
 
     if (xenParseXMCPUFeatures(conf, def) < 0)
-        goto cleanup;
+        return -1;
 
     if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0)
-        goto cleanup;
-
-    if (xenParseXMDisk(conf, def, xendConfigVersion) < 0)
-        goto cleanup;
+        return -1;
 
     if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0)
-        goto cleanup;
+        return -1;
 
     if (xenParseXMVif(conf, def) < 0)
-        goto cleanup;
+        return -1;
 
     if (xenParseXMPCI(conf, def) < 0)
-        goto cleanup;
+        return -1;
 
     if (xenParseXMEmulatedDevices(conf, def) < 0)
-        goto cleanup;
+        return -1;
 
     if (xenParseXMVfb(conf, def, xendConfigVersion) < 0)
-        goto cleanup;
+        return -1;
 
     if (xenParseXMCharDev(conf, def) < 0)
+        return -1;
+
+    return 0;
+}
+
+
+/*
+ * Turn a config record into a lump of XML describing the
+ * domain, suitable for later feeding for virDomainCreateXML
+ */
+virDomainDefPtr
+xenParseXM(virConfPtr conf,
+           int xendConfigVersion,
+           virCapsPtr caps)
+{
+    virDomainDefPtr def = NULL;
+
+    if (VIR_ALLOC(def) < 0)
+        return NULL;
+
+    def->virtType = VIR_DOMAIN_VIRT_XEN;
+    def->id = -1;
+
+    if (xenParseConfigCommon(conf, def, caps, xendConfigVersion) < 0)
         goto cleanup;
 
+    if (xenParseXMDisk(conf, def, xendConfigVersion) < 0)
+         goto cleanup;
+
     return def;
 
  cleanup:
index 629a4b32632dbe3eee8198b682fc1c95d0241569..29617fc681e095226180e4103cdbbda5641660fd 100644 (file)
@@ -36,4 +36,9 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def,
 virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion,
                            virCapsPtr caps);
 
+int xenParseConfigCommon(virConfPtr conf,
+                         virDomainDefPtr def,
+                         virCapsPtr caps,
+                         int xendConfigVersion);
+
 #endif /* __VIR_XEN_XM_H__ */