[libvirt PATCH 08/10] conf: switch nvram parsing to use XML node / property helpers

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

 



Instead of using XPath, parse the <nvram> using the XML node and
property helpers so the code is consistent with the parsing of
<loader>.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 13ec64c19f..6163910c91 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18229,21 +18229,30 @@ virDomainDefParseBootLoaderOptions(virDomainDef *def,
                                    xmlXPathContextPtr ctxt)
 {
     xmlNodePtr loader_node = virXPathNode("./os/loader[1]", ctxt);
+    xmlNodePtr nvram_node = virXPathNode("./os/nvram[1]", ctxt);
     const bool fwAutoSelect = def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_NONE;
+    virDomainLoaderDef *loader;
 
     if (!loader_node)
         return 0;
 
-    def->os.loader = g_new0(virDomainLoaderDef, 1);
+    def->os.loader = loader = g_new0(virDomainLoaderDef, 1);
 
     if (virDomainLoaderDefParseXML(loader_node,
                                    def->os.loader,
                                    fwAutoSelect) < 0)
         return -1;
 
-    def->os.loader->nvram = virXPathString("string(./os/nvram[1])", ctxt);
-    if (!fwAutoSelect)
-        def->os.loader->nvramTemplate = virXPathString("string(./os/nvram[1]/@template)", ctxt);
+    if (nvram_node) {
+        if (!(loader->nvram = virXMLNodeContentString(nvram_node)))
+            return -1;
+
+        if (STREQ(loader->nvram, ""))
+            VIR_FREE(loader->nvram);
+
+        if (!fwAutoSelect)
+            def->os.loader->nvramTemplate = virXMLPropString(nvram_node, "template");
+    }
 
     return 0;
 }
-- 
2.34.1




[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