860ffc
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
860ffc
Date: Wed, 11 May 2016 12:13:51 +0200
860ffc
Subject: [PATCH] Call per-device post-parse callback even on implicit video
860ffc
860ffc
Commit 6879be48 moved adding of an implicit video device after XML
860ffc
parsing. As a result, libxlDomainDeviceDefPostParse() is no longer
860ffc
called to set the default vram when adding an implicit device.
860ffc
Commit 6879be48 assumes virDomainVideoDefaultRAM() will set the
860ffc
default vram, but it returns 0 if the domain virtType is
860ffc
VIR_DOMAIN_VIRT_XEN. Attempting to start an HVM domain with vram=0
860ffc
results in
860ffc
860ffc
error: unsupported configuration: videoram must be at least 4MB for CIRRUS
860ffc
860ffc
The default vram setting for Xen HVM domains depends on the device
860ffc
model used (qemu-xen vs qemu-traditional), hence setting the
860ffc
default is deferred to libxlDomainDeviceDefPostParse().
860ffc
860ffc
Call the device post-parse callback even for implicit video,
860ffc
to fill out the default vram even for VIR_DOMAIN_VIRT_XEN.
860ffc
860ffc
https://bugzilla.redhat.com/show_bug.cgi?id=1334557
860ffc
Most-of-commit-message-by: Jim Fehlig <jfehlig@suse.com>
860ffc
(cherry picked from commit 3e4286703273b06a21ae07f3e76a66f9661199dc)
860ffc
---
860ffc
 src/conf/domain_conf.c | 24 +++++++++++++++++-------
860ffc
 1 file changed, 17 insertions(+), 7 deletions(-)
860ffc
860ffc
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
860ffc
index e9206f9..aa0268b 100644
860ffc
--- a/src/conf/domain_conf.c
860ffc
+++ b/src/conf/domain_conf.c
860ffc
@@ -4321,8 +4321,7 @@ virDomainDefPostParseDeviceIterator(virDomainDefPtr def ATTRIBUTE_UNUSED,
860ffc
 
860ffc
 static int
860ffc
 virDomainDefPostParseInternal(virDomainDefPtr def,
860ffc
-                              virCapsPtr caps ATTRIBUTE_UNUSED,
860ffc
-                              unsigned int parseFlags)
860ffc
+                              struct virDomainDefPostParseDeviceIteratorData *data)
860ffc
 {
860ffc
     /* verify init path for container based domains */
860ffc
     if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init) {
860ffc
@@ -4331,7 +4330,7 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
860ffc
         return -1;
860ffc
     }
860ffc
 
860ffc
-    if (virDomainDefPostParseMemory(def, parseFlags) < 0)
860ffc
+    if (virDomainDefPostParseMemory(def, data->parseFlags) < 0)
860ffc
         return -1;
860ffc
 
860ffc
     if (virDomainDefRejectDuplicateControllers(def) < 0)
860ffc
@@ -4346,11 +4345,22 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
860ffc
     if (virDomainDefAddImplicitDevices(def) < 0)
860ffc
         return -1;
860ffc
 
860ffc
-    /* Mark the first video as primary. If the user specified primary="yes",
860ffc
-     * the parser already inserted the device at def->videos[0] */
860ffc
-    if (def->nvideos != 0)
860ffc
+    if (def->nvideos != 0) {
860ffc
+        virDomainDeviceDef device = {
860ffc
+            .type = VIR_DOMAIN_DEVICE_VIDEO,
860ffc
+            .data.video = def->videos[0],
860ffc
+        };
860ffc
+
860ffc
+        /* Mark the first video as primary. If the user specified primary="yes",
860ffc
+         * the parser already inserted the device at def->videos[0] */
860ffc
         def->videos[0]->primary = true;
860ffc
 
860ffc
+        /* videos[0] might have been added in AddImplicitDevices, after we've
860ffc
+         * done the per-device post-parse */
860ffc
+        if (virDomainDefPostParseDeviceIterator(NULL, &device, NULL, data) < 0)
860ffc
+            return -1;
860ffc
+    }
860ffc
+
860ffc
     /* clean up possibly duplicated metadata entries */
860ffc
     virDomainDefMetadataSanitize(def);
860ffc
 
860ffc
@@ -4388,7 +4398,7 @@ virDomainDefPostParse(virDomainDefPtr def,
860ffc
         return ret;
860ffc
 
860ffc
 
860ffc
-    if ((ret = virDomainDefPostParseInternal(def, caps, parseFlags)) < 0)
860ffc
+    if ((ret = virDomainDefPostParseInternal(def, &data)) < 0)
860ffc
         return ret;
860ffc
 
860ffc
     if (virDomainDefPostParseCheckFeatures(def, xmlopt) < 0)