[PATCH v2 02/25] src/xenxs:Refactor code parsing event actions config

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

 



From: Kiarie Kahurani <davidkiarie4@xxxxxxxxx>

Introduce function
 xenParseXMEventActions(virConfPtr conf,......);
which parses events config instead

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

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 5e26e5e..d0a166d 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -266,6 +266,42 @@ int xenParseXMMem(virConfPtr conf, virDomainDefPtr def)
  * Turn a config record into a lump of XML describing the
  * domain, suitable for later feeding for virDomainCreateXML
  */
+static
+int xenParseXMEventsActions(virConfPtr conf, virDomainDefPtr def)
+{
+    const char *str;
+
+    if (xenXMConfigGetString(conf, "on_poweroff", &str, "destroy") < 0)
+        return -1;
+
+    if ((def->onPoweroff = virDomainLifecycleTypeFromString(str)) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("unexpected value %s for on_poweroff"), str);
+        return -1;
+    }
+
+    if (xenXMConfigGetString(conf, "on_reboot", &str, "restart") < 0)
+        return -1;
+
+    if ((def->onReboot = virDomainLifecycleTypeFromString(str)) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("unexpected value %s for on_reboot"), str);
+        return -1;
+    }
+
+    if (xenXMConfigGetString(conf, "on_crash", &str, "restart") < 0)
+        return -1;
+
+    if ((def->onCrash = virDomainLifecycleCrashTypeFromString(str)) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("unexpected value %s for on_crash"), str);
+        return -1;
+    }
+
+    return 0;
+}
+
+
 virDomainDefPtr
 xenParseXM(virConfPtr conf, int xendConfigVersion,
                        virCapsPtr caps)
@@ -379,6 +415,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 
     if (xenParseXMMem(conf, def) < 0)
         goto cleanup;
+    if (xenParseXMEventsActions(conf, def) < 0)
+        goto cleanup;
     if (xenXMConfigGetULong(conf, "vcpus", &count, 1) < 0 ||
         MAX_VIRT_CPUS < count)
         goto cleanup;
@@ -391,33 +429,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
         goto cleanup;
     if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0))
             goto cleanup;
-
-    if (xenXMConfigGetString(conf, "on_poweroff", &str, "destroy") < 0)
-        goto cleanup;
-    if ((def->onPoweroff = virDomainLifecycleTypeFromString(str)) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("unexpected value %s for on_poweroff"), str);
-        goto cleanup;
-    }
-
-    if (xenXMConfigGetString(conf, "on_reboot", &str, "restart") < 0)
-        goto cleanup;
-    if ((def->onReboot = virDomainLifecycleTypeFromString(str)) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("unexpected value %s for on_reboot"), str);
-        goto cleanup;
-    }
-
-    if (xenXMConfigGetString(conf, "on_crash", &str, "restart") < 0)
-        goto cleanup;
-    if ((def->onCrash = virDomainLifecycleCrashTypeFromString(str)) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("unexpected value %s for on_crash"), str);
-        goto cleanup;
-    }
-
-
-
     if (hvm) {
         if (xenXMConfigGetBool(conf, "pae", &val, 0) < 0)
             goto cleanup;
-- 
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]