render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
ab145e
From 6891ef941e693d86ebbab9e529e908dacf4a7dc6 Mon Sep 17 00:00:00 2001
ab145e
Message-Id: <6891ef941e693d86ebbab9e529e908dacf4a7dc6@dist-git>
ab145e
From: Pavel Hrdina <phrdina@redhat.com>
ab145e
Date: Fri, 21 May 2021 14:16:08 +0200
ab145e
Subject: [PATCH] conf: introduce virDomainDefParseBootLoaderOptions
ab145e
ab145e
Extract the code to it's own function.
ab145e
ab145e
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
ab145e
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
ab145e
(cherry picked from commit b8dd70db4ee2f3a5edcbbeb8515830db9652cb59)
ab145e
ab145e
Conflicts:
ab145e
    src/conf/domain_conf.c
ab145e
        - using VIR_ALLOC in downstream instead of g_new0
ab145e
ab145e
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1929357
ab145e
ab145e
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
ab145e
Message-Id: <e9d0f563b055b415deb7718d33f7661a797a48f1.1621599207.git.phrdina@redhat.com>
ab145e
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
ab145e
---
ab145e
 src/conf/domain_conf.c | 44 +++++++++++++++++++++++++++---------------
ab145e
 1 file changed, 28 insertions(+), 16 deletions(-)
ab145e
ab145e
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
ab145e
index bb484a57c6..493700ed6b 100644
ab145e
--- a/src/conf/domain_conf.c
ab145e
+++ b/src/conf/domain_conf.c
ab145e
@@ -19402,6 +19402,32 @@ virDomainDefParseBootFirmwareOptions(virDomainDefPtr def,
ab145e
 }
ab145e
 
ab145e
 
ab145e
+static int
ab145e
+virDomainDefParseBootLoaderOptions(virDomainDefPtr def,
ab145e
+                                   xmlXPathContextPtr ctxt)
ab145e
+{
ab145e
+    xmlNodePtr loader_node = virXPathNode("./os/loader[1]", ctxt);
ab145e
+    const bool fwAutoSelect = def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_NONE;
ab145e
+
ab145e
+    if (!loader_node)
ab145e
+        return 0;
ab145e
+
ab145e
+    if (VIR_ALLOC(def->os.loader) < 0)
ab145e
+        return -1;
ab145e
+
ab145e
+    if (virDomainLoaderDefParseXML(loader_node,
ab145e
+                                   def->os.loader,
ab145e
+                                   fwAutoSelect) < 0)
ab145e
+        return -1;
ab145e
+
ab145e
+    def->os.loader->nvram = virXPathString("string(./os/nvram[1])", ctxt);
ab145e
+    if (!fwAutoSelect)
ab145e
+        def->os.loader->templt = virXPathString("string(./os/nvram[1]/@template)", ctxt);
ab145e
+
ab145e
+    return 0;
ab145e
+}
ab145e
+
ab145e
+
ab145e
 static int
ab145e
 virDomainDefParseBootOptions(virDomainDefPtr def,
ab145e
                              xmlXPathContextPtr ctxt)
ab145e
@@ -19428,7 +19454,6 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
ab145e
         def->os.type == VIR_DOMAIN_OSTYPE_XENPVH ||
ab145e
         def->os.type == VIR_DOMAIN_OSTYPE_HVM ||
ab145e
         def->os.type == VIR_DOMAIN_OSTYPE_UML) {
ab145e
-        xmlNodePtr loader_node;
ab145e
 
ab145e
         virDomainDefParseBootKernelOptions(def, ctxt);
ab145e
 
ab145e
@@ -19437,21 +19462,8 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
ab145e
                 return -1;
ab145e
         }
ab145e
 
ab145e
-        if ((loader_node = virXPathNode("./os/loader[1]", ctxt))) {
ab145e
-            const bool fwAutoSelect = def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_NONE;
ab145e
-
ab145e
-            if (VIR_ALLOC(def->os.loader) < 0)
ab145e
-                return -1;
ab145e
-
ab145e
-            if (virDomainLoaderDefParseXML(loader_node,
ab145e
-                                           def->os.loader,
ab145e
-                                           fwAutoSelect) < 0)
ab145e
-                return -1;
ab145e
-
ab145e
-            def->os.loader->nvram = virXPathString("string(./os/nvram[1])", ctxt);
ab145e
-            if (!fwAutoSelect)
ab145e
-                def->os.loader->templt = virXPathString("string(./os/nvram[1]/@template)", ctxt);
ab145e
-        }
ab145e
+        if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0)
ab145e
+            return -1;
ab145e
     }
ab145e
 
ab145e
     if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
ab145e
-- 
ab145e
2.31.1
ab145e