From: Kiarie Kahurani <davidkiar...@gmail.com>

Introduce function
 xenParseXMPCI(virConfPtr conf,......);
which parses CPU Features and allocation config instead

signed-off-by: David Kiarie<davidkiar...@gmail.com>
---
 src/xenxs/xen_xm.c | 126 +++++++++++++++++++++++++++++++----------------------
 1 file changed, 73 insertions(+), 53 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 2fb3a4c..66d7b44 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -436,6 +436,77 @@ int xenParseXMPCI(virConfPtr conf, virDomainDefPtr def)
 }
 
 
+static
+int xenParseXMCPUFeatures(virConfPtr conf, virDomainDefPtr def)
+{
+    unsigned long count;
+    const char *str;
+    int val;
+
+    if (xenXMConfigGetULong(conf, "vcpus", &count, 1) < 0 ||
+        MAX_VIRT_CPUS < count)
+        return -1;
+
+    def->maxvcpus = count;
+    if (xenXMConfigGetULong(conf, "vcpu_avail", &count, -1) < 0)
+        return -1;
+
+    def->vcpus = MIN(count_one_bits_l(count), def->maxvcpus);
+    if (xenXMConfigGetString(conf, "cpus", &str, NULL) < 0)
+        return -1;
+
+    if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0))
+            return -1;
+
+    if (STREQ(def->os.type, "hvm")) {
+        if (xenXMConfigGetBool(conf, "pae", &val, 0) < 0)
+            return -1;
+
+        else if (val)
+            def->features[VIR_DOMAIN_FEATURE_PAE] = 
VIR_DOMAIN_FEATURE_STATE_ON;
+        if (xenXMConfigGetBool(conf, "acpi", &val, 0) < 0)
+            return -1;
+
+        else if (val)
+            def->features[VIR_DOMAIN_FEATURE_ACPI] = 
VIR_DOMAIN_FEATURE_STATE_ON;
+        if (xenXMConfigGetBool(conf, "apic", &val, 0) < 0)
+            return -1;
+
+        else if (val)
+            def->features[VIR_DOMAIN_FEATURE_APIC] = 
VIR_DOMAIN_FEATURE_STATE_ON;
+        if (xenXMConfigGetBool(conf, "hap", &val, 0) < 0)
+            return -1;
+
+        else if (val)
+            def->features[VIR_DOMAIN_FEATURE_HAP] = 
VIR_DOMAIN_FEATURE_STATE_ON;
+        if (xenXMConfigGetBool(conf, "viridian", &val, 0) < 0)
+            return -1;
+
+        else if (val)
+            def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] = 
VIR_DOMAIN_FEATURE_STATE_ON;
+        if (xenXMConfigGetBool(conf, "hpet", &val, -1) < 0)
+            return -1;
+
+        else if (val != -1) {
+            virDomainTimerDefPtr timer;
+
+            if (VIR_ALLOC_N(def->clock.timers, 1) < 0 ||
+                VIR_ALLOC(timer) < 0)
+                return -1;
+
+            timer->name = VIR_DOMAIN_TIMER_NAME_HPET;
+            timer->present = val;
+            timer->tickpolicy = -1;
+
+            def->clock.ntimers = 1;
+            def->clock.timers[0] = timer;
+        }
+    }
+
+    return 0;
+}
+
+
 virDomainDefPtr
 xenParseXM(virConfPtr conf, int xendConfigVersion,
                        virCapsPtr caps)
@@ -450,7 +521,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
     virDomainGraphicsDefPtr graphics = NULL;
     size_t i;
     const char *defaultMachine;
-    unsigned long count;
     char *script = NULL;
     char *listenAddr = NULL;
 
@@ -549,60 +619,10 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
         goto cleanup;
     if (xenParseXMEventsActions(conf, def) < 0)
         goto cleanup;
-    if (xenXMConfigGetULong(conf, "vcpus", &count, 1) < 0 ||
-        MAX_VIRT_CPUS < count)
-        goto cleanup;
-    def->maxvcpus = count;
-    if (xenXMConfigGetULong(conf, "vcpu_avail", &count, -1) < 0)
-        goto cleanup;
-    def->vcpus = MIN(count_one_bits_l(count), def->maxvcpus);
-
-    if (xenXMConfigGetString(conf, "cpus", &str, NULL) < 0)
-        goto cleanup;
-    if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0))
-            goto cleanup;
-    if (hvm) {
-        if (xenXMConfigGetBool(conf, "pae", &val, 0) < 0)
-            goto cleanup;
-        else if (val)
-            def->features[VIR_DOMAIN_FEATURE_PAE] = 
VIR_DOMAIN_FEATURE_STATE_ON;
-        if (xenXMConfigGetBool(conf, "acpi", &val, 0) < 0)
-            goto cleanup;
-        else if (val)
-            def->features[VIR_DOMAIN_FEATURE_ACPI] = 
VIR_DOMAIN_FEATURE_STATE_ON;
-        if (xenXMConfigGetBool(conf, "apic", &val, 0) < 0)
-            goto cleanup;
-        else if (val)
-            def->features[VIR_DOMAIN_FEATURE_APIC] = 
VIR_DOMAIN_FEATURE_STATE_ON;
-        if (xenXMConfigGetBool(conf, "hap", &val, 0) < 0)
-            goto cleanup;
-        else if (val)
-            def->features[VIR_DOMAIN_FEATURE_HAP] = 
VIR_DOMAIN_FEATURE_STATE_ON;
-        if (xenXMConfigGetBool(conf, "viridian", &val, 0) < 0)
-            goto cleanup;
-        else if (val)
-            def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] = 
VIR_DOMAIN_FEATURE_STATE_ON;
-
-        if (xenXMConfigGetBool(conf, "hpet", &val, -1) < 0)
-            goto cleanup;
-        else if (val != -1) {
-            virDomainTimerDefPtr timer;
-
-            if (VIR_ALLOC_N(def->clock.timers, 1) < 0 ||
-                VIR_ALLOC(timer) < 0)
-                goto cleanup;
-
-            timer->name = VIR_DOMAIN_TIMER_NAME_HPET;
-            timer->present = val;
-            timer->tickpolicy = -1;
-
-            def->clock.ntimers = 1;
-            def->clock.timers[0] = timer;
-        }
-    }
-
     if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0)
         goto cleanup;
+    if (xenParseXMCPUFeatures(conf, def) < 0)
+        goto cleanup;
     if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0)
         goto cleanup;
 
-- 
1.8.4.5

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

Reply via email to