[libvirt PATCH 6/9] conf: introduce virDomainDefParseBootAcpiOptions

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

 



Extract the code to it's own function.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 79 ++++++++++++++++++++++++------------------
 1 file changed, 45 insertions(+), 34 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f6e8d5180a..14a2c818d6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19645,14 +19645,54 @@ virDomainDefParseBootLoaderOptions(virDomainDefPtr def,
 }
 
 
+static int
+virDomainDefParseBootAcpiOptions(virDomainDefPtr def,
+                                 xmlXPathContextPtr ctxt)
+{
+    int n;
+    g_autofree xmlNodePtr *nodes = NULL;
+    g_autofree char *tmp = NULL;
+
+    if ((n = virXPathNodeSet("./os/acpi/table", ctxt, &nodes)) < 0)
+        return -1;
+
+    if (n > 1) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("Only one acpi table is supported"));
+        return -1;
+    }
+
+    if (n == 1) {
+        tmp = virXMLPropString(nodes[0], "type");
+
+        if (!tmp) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("Missing acpi table type"));
+            return -1;
+        }
+
+        if (STREQ_NULLABLE(tmp, "slic")) {
+            VIR_FREE(tmp);
+            if (!(tmp = virXMLNodeContentString(nodes[0])))
+                return -1;
+
+            def->os.slic_table = virFileSanitizePath(tmp);
+        } else {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("Unknown acpi table type: %s"),
+                           tmp);
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
+
 static int
 virDomainDefParseBootOptions(virDomainDefPtr def,
                              xmlXPathContextPtr ctxt)
 {
-    int n;
-    g_autofree xmlNodePtr *nodes = NULL;
-    g_autofree char *tmp = NULL;
-
     /*
      * Booting options for different OS types....
      *
@@ -19684,38 +19724,9 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
     }
 
     if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
-        if ((n = virXPathNodeSet("./os/acpi/table", ctxt, &nodes)) < 0)
+        if (virDomainDefParseBootAcpiOptions(def, ctxt) < 0)
             return -1;
 
-        if (n > 1) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("Only one acpi table is supported"));
-            return -1;
-        }
-
-        if (n == 1) {
-            tmp = virXMLPropString(nodes[0], "type");
-
-            if (!tmp) {
-                virReportError(VIR_ERR_XML_ERROR, "%s",
-                               _("Missing acpi table type"));
-                return -1;
-            }
-
-            if (STREQ_NULLABLE(tmp, "slic")) {
-                VIR_FREE(tmp);
-                if (!(tmp = virXMLNodeContentString(nodes[0])))
-                    return -1;
-
-                def->os.slic_table = virFileSanitizePath(tmp);
-            } else {
-                virReportError(VIR_ERR_XML_ERROR,
-                               _("Unknown acpi table type: %s"),
-                               tmp);
-                return -1;
-            }
-        }
-
         if (virDomainDefParseBootXML(ctxt, def) < 0)
             return -1;
     }
-- 
2.30.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