[PATCH 2/5] src/xenconfig: wrap common parsing code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Kiarie Kahurani <davidkiarie4@xxxxxxxxx>

Wrap parsing code common to xm and xl in xenParseConfigCommon
and export it.

Signed-off-by: Kiarie Kahurani <davidkiarie4@xxxxxxxxx>
Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
---
 src/xenconfig/xen_xm.c | 72 ++++++++++++++++++++++++++++++--------------------
 src/xenconfig/xen_xm.h |  5 ++++
 2 files changed, 48 insertions(+), 29 deletions(-)

diff --git a/src/xenconfig/xen_xm.c b/src/xenconfig/xen_xm.c
index 292903e..e15b77a 100644
--- a/src/xenconfig/xen_xm.c
+++ b/src/xenconfig/xen_xm.c
@@ -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:
diff --git a/src/xenconfig/xen_xm.h b/src/xenconfig/xen_xm.h
index 629a4b3..29617fc 100644
--- a/src/xenconfig/xen_xm.h
+++ b/src/xenconfig/xen_xm.h
@@ -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__ */
-- 
1.8.4.5

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]