[PATCH 1/7] conf: move default video addition after XML parsing

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

 



Separate parsing of the XML from auto-generating the device.
---
 src/conf/domain_conf.c | 56 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 34 insertions(+), 22 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9e547b4..12ce37c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16446,28 +16446,6 @@ virDomainDefParseXML(xmlDocPtr xml,
 
     VIR_FREE(nodes);
 
-    /* For backwards compatibility, if no <video> tag is set but there
-     * is a <graphics> tag, then we add a single video tag */
-    if (def->ngraphics && !def->nvideos) {
-        virDomainVideoDefPtr video;
-        if (VIR_ALLOC(video) < 0)
-            goto error;
-        video->type = virDomainVideoDefaultType(def);
-        if (video->type < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("cannot determine default video type"));
-            VIR_FREE(video);
-            goto error;
-        }
-        video->vram = virDomainVideoDefaultRAM(def, video->type);
-        video->heads = 1;
-        if (VIR_ALLOC_N(def->videos, 1) < 0) {
-            virDomainVideoDefFree(video);
-            goto error;
-        }
-        def->videos[def->nvideos++] = video;
-    }
-
     /* analysis of the host devices */
     if ((n = virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0)
         goto error;
@@ -18664,6 +18642,37 @@ virDomainDefAddImplicitControllers(virDomainDefPtr def)
     return 0;
 }
 
+static int
+virDomainDefAddImplicitVideo(virDomainDefPtr def)
+{
+    int ret = -1;
+    virDomainVideoDefPtr video = NULL;
+
+    /* For backwards compatibility, if no <video> tag is set but there
+     * is a <graphics> tag, then we add a single video tag */
+    if (def->ngraphics && !def->nvideos) {
+        if (VIR_ALLOC(video) < 0)
+            goto cleanup;
+        video->type = virDomainVideoDefaultType(def);
+        if (video->type < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("cannot determine default video type"));
+            goto cleanup;
+        }
+        video->vram = virDomainVideoDefaultRAM(def, video->type);
+        video->heads = 1;
+        if (VIR_ALLOC_N(def->videos, 1) < 0)
+            goto cleanup;
+        def->videos[def->nvideos++] = video;
+        video = NULL;
+    }
+
+    ret = 0;
+ cleanup:
+    virDomainVideoDefFree(video);
+    return ret;
+}
+
 int
 virDomainDefAddImplicitDevices(virDomainDefPtr def)
 {
@@ -18673,6 +18682,9 @@ virDomainDefAddImplicitDevices(virDomainDefPtr def)
     if (virDomainDefAddImplicitControllers(def) < 0)
         return -1;
 
+    if (virDomainDefAddImplicitVideo(def) < 0)
+        return -1;
+
     return 0;
 }
 
-- 
2.7.3

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