[libvirt PATCH 04/11] conf: introduce virDomainDefLifecycleParse

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

 



Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 86 ++++++++++++++++++++++++------------------
 1 file changed, 50 insertions(+), 36 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 62f9b6316e..79998635ac 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21587,6 +21587,55 @@ virDomainDefTunablesParse(virDomainDefPtr def,
 }
 
 
+static int
+virDomainDefLifecycleParse(virDomainDefPtr def,
+                           xmlXPathContextPtr ctxt)
+{
+    if (virDomainEventActionParseXML(ctxt, "on_reboot",
+                                     "string(./on_reboot[1])",
+                                     &def->onReboot,
+                                     VIR_DOMAIN_LIFECYCLE_ACTION_RESTART,
+                                     virDomainLifecycleActionTypeFromString) < 0)
+        goto error;
+
+    if (virDomainEventActionParseXML(ctxt, "on_poweroff",
+                                     "string(./on_poweroff[1])",
+                                     &def->onPoweroff,
+                                     VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY,
+                                     virDomainLifecycleActionTypeFromString) < 0)
+        goto error;
+
+    if (virDomainEventActionParseXML(ctxt, "on_crash",
+                                     "string(./on_crash[1])",
+                                     &def->onCrash,
+                                     VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY,
+                                     virDomainLifecycleActionTypeFromString) < 0)
+        goto error;
+
+    if (virDomainEventActionParseXML(ctxt, "on_lockfailure",
+                                     "string(./on_lockfailure[1])",
+                                     &def->onLockFailure,
+                                     VIR_DOMAIN_LOCK_FAILURE_DEFAULT,
+                                     virDomainLockFailureTypeFromString) < 0)
+        goto error;
+
+    if (virDomainPMStateParseXML(ctxt,
+                                 "string(./pm/suspend-to-mem/@enabled)",
+                                 &def->pm.s3) < 0)
+        goto error;
+
+    if (virDomainPMStateParseXML(ctxt,
+                                 "string(./pm/suspend-to-disk/@enabled)",
+                                 &def->pm.s4) < 0)
+        goto error;
+
+    return 0;
+
+ error:
+    return -1;
+}
+
+
 static virDomainDefPtr
 virDomainDefParseXML(xmlDocPtr xml,
                      xmlXPathContextPtr ctxt,
@@ -21700,42 +21749,7 @@ virDomainDefParseXML(xmlDocPtr xml,
     if (virDomainFeaturesDefParse(def, ctxt) < 0)
         goto error;
 
-    if (virDomainEventActionParseXML(ctxt, "on_reboot",
-                                     "string(./on_reboot[1])",
-                                     &def->onReboot,
-                                     VIR_DOMAIN_LIFECYCLE_ACTION_RESTART,
-                                     virDomainLifecycleActionTypeFromString) < 0)
-        goto error;
-
-    if (virDomainEventActionParseXML(ctxt, "on_poweroff",
-                                     "string(./on_poweroff[1])",
-                                     &def->onPoweroff,
-                                     VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY,
-                                     virDomainLifecycleActionTypeFromString) < 0)
-        goto error;
-
-    if (virDomainEventActionParseXML(ctxt, "on_crash",
-                                     "string(./on_crash[1])",
-                                     &def->onCrash,
-                                     VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY,
-                                     virDomainLifecycleActionTypeFromString) < 0)
-        goto error;
-
-    if (virDomainEventActionParseXML(ctxt, "on_lockfailure",
-                                     "string(./on_lockfailure[1])",
-                                     &def->onLockFailure,
-                                     VIR_DOMAIN_LOCK_FAILURE_DEFAULT,
-                                     virDomainLockFailureTypeFromString) < 0)
-        goto error;
-
-    if (virDomainPMStateParseXML(ctxt,
-                                 "string(./pm/suspend-to-mem/@enabled)",
-                                 &def->pm.s3) < 0)
-        goto error;
-
-    if (virDomainPMStateParseXML(ctxt,
-                                 "string(./pm/suspend-to-disk/@enabled)",
-                                 &def->pm.s4) < 0)
+    if (virDomainDefLifecycleParse(def, ctxt) < 0)
         goto error;
 
     if (virDomainPerfDefParseXML(def, ctxt) < 0)
-- 
2.26.2




[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]

  Powered by Linux