b35f2b
From 7ba2905bfcab4dbe4a491ee8587dd4c9ef457c0b Mon Sep 17 00:00:00 2001
b35f2b
Message-Id: <7ba2905bfcab4dbe4a491ee8587dd4c9ef457c0b@dist-git>
b35f2b
From: Pavel Hrdina <phrdina@redhat.com>
b35f2b
Date: Fri, 21 May 2021 14:16:09 +0200
b35f2b
Subject: [PATCH] conf: introduce virDomainDefParseBootAcpiOptions
b35f2b
b35f2b
Extract the code to it's own function.
b35f2b
b35f2b
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
b35f2b
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
b35f2b
(cherry picked from commit 108cb29c1c7eec7b9089dd431e0bdcd82a0b07f1)
b35f2b
b35f2b
Conflicts:
b35f2b
    src/conf/domain_conf.c
b35f2b
        - missing upstream commit d293a556d710754d8aa8d5caac0bb01a365fcbd8
b35f2b
b35f2b
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1929357
b35f2b
b35f2b
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
b35f2b
Message-Id: <5fb7ee0165340ff517b3f7f16ddc542813ac385d.1621599207.git.phrdina@redhat.com>
b35f2b
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
b35f2b
---
b35f2b
 src/conf/domain_conf.c | 71 ++++++++++++++++++++++++------------------
b35f2b
 1 file changed, 41 insertions(+), 30 deletions(-)
b35f2b
b35f2b
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
b35f2b
index 493700ed6b..f8d8d33245 100644
b35f2b
--- a/src/conf/domain_conf.c
b35f2b
+++ b/src/conf/domain_conf.c
b35f2b
@@ -19429,13 +19429,51 @@ virDomainDefParseBootLoaderOptions(virDomainDefPtr def,
b35f2b
 
b35f2b
 
b35f2b
 static int
b35f2b
-virDomainDefParseBootOptions(virDomainDefPtr def,
b35f2b
-                             xmlXPathContextPtr ctxt)
b35f2b
+virDomainDefParseBootAcpiOptions(virDomainDefPtr def,
b35f2b
+                                 xmlXPathContextPtr ctxt)
b35f2b
 {
b35f2b
     int n;
b35f2b
     g_autofree xmlNodePtr *nodes = NULL;
b35f2b
     g_autofree char *tmp = NULL;
b35f2b
 
b35f2b
+    if ((n = virXPathNodeSet("./os/acpi/table", ctxt, &nodes)) < 0)
b35f2b
+        return -1;
b35f2b
+
b35f2b
+    if (n > 1) {
b35f2b
+        virReportError(VIR_ERR_XML_ERROR, "%s",
b35f2b
+                       _("Only one acpi table is supported"));
b35f2b
+        return -1;
b35f2b
+    }
b35f2b
+
b35f2b
+    if (n == 1) {
b35f2b
+        tmp = virXMLPropString(nodes[0], "type");
b35f2b
+
b35f2b
+        if (!tmp) {
b35f2b
+            virReportError(VIR_ERR_XML_ERROR, "%s",
b35f2b
+                           _("Missing acpi table type"));
b35f2b
+            return -1;
b35f2b
+        }
b35f2b
+
b35f2b
+        if (STREQ_NULLABLE(tmp, "slic")) {
b35f2b
+            VIR_FREE(tmp);
b35f2b
+            tmp = virXMLNodeContentString(nodes[0]);
b35f2b
+            def->os.slic_table = virFileSanitizePath(tmp);
b35f2b
+        } else {
b35f2b
+            virReportError(VIR_ERR_XML_ERROR,
b35f2b
+                           _("Unknown acpi table type: %s"),
b35f2b
+                           tmp);
b35f2b
+            return -1;
b35f2b
+        }
b35f2b
+    }
b35f2b
+
b35f2b
+    return 0;
b35f2b
+}
b35f2b
+
b35f2b
+
b35f2b
+static int
b35f2b
+virDomainDefParseBootOptions(virDomainDefPtr def,
b35f2b
+                             xmlXPathContextPtr ctxt)
b35f2b
+{
b35f2b
     /*
b35f2b
      * Booting options for different OS types....
b35f2b
      *
b35f2b
@@ -19467,36 +19505,9 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
b35f2b
     }
b35f2b
 
b35f2b
     if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
b35f2b
-        if ((n = virXPathNodeSet("./os/acpi/table", ctxt, &nodes)) < 0)
b35f2b
+        if (virDomainDefParseBootAcpiOptions(def, ctxt) < 0)
b35f2b
             return -1;
b35f2b
 
b35f2b
-        if (n > 1) {
b35f2b
-            virReportError(VIR_ERR_XML_ERROR, "%s",
b35f2b
-                           _("Only one acpi table is supported"));
b35f2b
-            return -1;
b35f2b
-        }
b35f2b
-
b35f2b
-        if (n == 1) {
b35f2b
-            tmp = virXMLPropString(nodes[0], "type");
b35f2b
-
b35f2b
-            if (!tmp) {
b35f2b
-                virReportError(VIR_ERR_XML_ERROR, "%s",
b35f2b
-                               _("Missing acpi table type"));
b35f2b
-                return -1;
b35f2b
-            }
b35f2b
-
b35f2b
-            if (STREQ_NULLABLE(tmp, "slic")) {
b35f2b
-                VIR_FREE(tmp);
b35f2b
-                tmp = virXMLNodeContentString(nodes[0]);
b35f2b
-                def->os.slic_table = virFileSanitizePath(tmp);
b35f2b
-            } else {
b35f2b
-                virReportError(VIR_ERR_XML_ERROR,
b35f2b
-                               _("Unknown acpi table type: %s"),
b35f2b
-                               tmp);
b35f2b
-                return -1;
b35f2b
-            }
b35f2b
-        }
b35f2b
-
b35f2b
         if (virDomainDefParseBootXML(ctxt, def) < 0)
b35f2b
             return -1;
b35f2b
     }
b35f2b
-- 
b35f2b
2.31.1
b35f2b