[PATCH v2 1/4] conf: Make virDomainLoaderDefParseXML parse <nvram/> too

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

 



This is pure code movement without any functional change.
The code simply reads better this way, that's all.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3cbb93d..ae18255 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12617,16 +12617,17 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def)
 }
 
 static int
-virDomainLoaderDefParseXML(xmlNodePtr node,
+virDomainLoaderDefParseXML(xmlNodePtr loader_node,
+                           xmlNodePtr nvram_node,
                            virDomainLoaderDefPtr loader)
 {
     int ret = -1;
     char *readonly_str = NULL;
     char *type_str = NULL;
 
-    readonly_str = virXMLPropString(node, "readonly");
-    type_str = virXMLPropString(node, "type");
-    loader->path = (char *) xmlNodeGetContent(node);
+    readonly_str = virXMLPropString(loader_node, "readonly");
+    type_str = virXMLPropString(loader_node, "type");
+    loader->path = (char *) xmlNodeGetContent(loader_node);
 
     if (readonly_str &&
         (loader->readonly = virTristateBoolTypeFromString(readonly_str)) <= 0) {
@@ -12645,6 +12646,11 @@ virDomainLoaderDefParseXML(xmlNodePtr node,
         loader->type = type;
     }
 
+    if (nvram_node) {
+        loader->nvram = (char *)xmlNodeGetContent(nvram_node);
+        loader->templt = virXMLPropString(nvram_node, "template");
+    }
+
     ret = 0;
  cleanup:
     VIR_FREE(readonly_str);
@@ -13735,7 +13741,7 @@ virDomainDefParseXML(xmlDocPtr xml,
     if (STREQ(def->os.type, "xen") ||
         STREQ(def->os.type, "hvm") ||
         STREQ(def->os.type, "uml")) {
-        xmlNodePtr loader_node;
+        xmlNodePtr loader_node, nvram_node;
 
         def->os.kernel = virXPathString("string(./os/kernel[1])", ctxt);
         def->os.initrd = virXPathString("string(./os/initrd[1])", ctxt);
@@ -13746,11 +13752,10 @@ virDomainDefParseXML(xmlDocPtr xml,
             if (VIR_ALLOC(def->os.loader) < 0)
                 goto error;
 
-            if (virDomainLoaderDefParseXML(loader_node, def->os.loader) < 0)
-                goto error;
+            nvram_node = virXPathNode("./os/nvram[1]", ctxt);
 
-            def->os.loader->nvram = virXPathString("string(./os/nvram[1])", ctxt);
-            def->os.loader->templt = virXPathString("string(./os/nvram[1]/@template)", ctxt);
+            if (virDomainLoaderDefParseXML(loader_node, nvram_node, def->os.loader) < 0)
+                goto error;
         }
     }
 
-- 
2.0.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



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