]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: move default video addition after XML parsing
authorJán Tomko <jtomko@redhat.com>
Mon, 11 Apr 2016 12:06:03 +0000 (14:06 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 12 Apr 2016 08:45:35 +0000 (10:45 +0200)
Separate parsing of the XML from auto-generating the device.

src/conf/domain_conf.c

index d2cf8d556e8a123b7ceac1dafcd807b02e05203e..5b831b6e28f60acead4deb5984e343965ef7b80b 100644 (file)
@@ -16447,28 +16447,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;
@@ -18665,6 +18643,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)
 {
@@ -18674,6 +18683,9 @@ virDomainDefAddImplicitDevices(virDomainDefPtr def)
     if (virDomainDefAddImplicitControllers(def) < 0)
         return -1;
 
+    if (virDomainDefAddImplicitVideo(def) < 0)
+        return -1;
+
     return 0;
 }