[PREPOST 01/17] src/xenxs:Introduce function

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

 



From: Kiarie Kahurani <davidkiarie4@xxxxxxxxx>

Introduce function xenParseXMGeneral(virConfPtr conf, ...);
This function parses the xm general options such as uuid and name

signed-off-by: David Kiarie <davidkiarie4@xxxxxxxxx>
---
 src/xenxs/xen_xm.c | 65 +++++++++++++++++++++++++++++++-----------------------
 1 file changed, 37 insertions(+), 28 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 25a042d..1953a85 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -253,44 +253,25 @@ xenXMConfigGetUUID(virConfPtr conf, const char *name, unsigned char *uuid)
  * 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)
+static int xenParseXMGeneral(virConfPtr conf, virDomainDefPtr def,
+                      virCapsPtr caps)
 {
+
+    const char *defaultMachine;
     const char *str;
     int hvm = 0;
-    int val;
-    virConfValuePtr list;
-    virDomainDefPtr def = NULL;
-    virDomainDiskDefPtr disk = NULL;
-    virDomainNetDefPtr net = NULL;
-    virDomainGraphicsDefPtr graphics = NULL;
-    virDomainHostdevDefPtr hostdev = NULL;
-    size_t i;
-    const char *defaultMachine;
-    int vmlocaltime = 0;
-    unsigned long count;
-    char *script = NULL;
-    char *listenAddr = NULL;
-
-    if (VIR_ALLOC(def) < 0)
-        return NULL;
-
-    def->virtType = VIR_DOMAIN_VIRT_XEN;
-    def->id = -1;
 
     if (xenXMConfigCopyString(conf, "name", &def->name) < 0)
-        goto cleanup;
+        return -1;
     if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0)
-        goto cleanup;
-
+        return -1;
 
     if ((xenXMConfigGetString(conf, "builder", &str, "linux") == 0) &&
         STREQ(str, "hvm"))
         hvm = 1;
 
     if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0)
-        goto cleanup;
+        return -1;
 
     def->os.arch =
         virCapabilitiesDefaultGuestArch(caps,
@@ -300,7 +281,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("no supported architecture for os type '%s'"),
                        def->os.type);
-        goto cleanup;
+        return -1;
     }
 
     defaultMachine = virCapabilitiesDefaultGuestMachine(caps,
@@ -309,9 +290,37 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
                                                         virDomainVirtTypeToString(def->virtType));
     if (defaultMachine != NULL) {
         if (VIR_STRDUP(def->os.machine, defaultMachine) < 0)
-            goto cleanup;
+            return -1;
     }
+    return 0;
+}
+virDomainDefPtr
+xenParseXM(virConfPtr conf, int xendConfigVersion,
+                       virCapsPtr caps)
+{
+    const char *str;
+    int hvm = 0;
+    int val;
+    virConfValuePtr list;
+    virDomainDefPtr def = NULL;
+    virDomainDiskDefPtr disk = NULL;
+    virDomainNetDefPtr net = NULL;
+    virDomainGraphicsDefPtr graphics = NULL;
+    virDomainHostdevDefPtr hostdev = NULL;
+    size_t i;
+    int vmlocaltime = 0;
+    unsigned long count;
+    char *script = NULL;
+    char *listenAddr = NULL;
+
+    if (VIR_ALLOC(def) < 0)
+        return NULL;
 
+    def->virtType = VIR_DOMAIN_VIRT_XEN;
+    def->id = -1;
+    if (xenParseXMGeneral(conf, def, caps) < 0)
+        goto cleanup;
+    hvm = (STREQ(def->os.type, "hvm"));
     if (hvm) {
         const char *boot;
         if (xenXMConfigCopyString(conf, "kernel", &def->os.loader) < 0)
-- 
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]