[libvirt] [PATCH 2/3] Call per-device post-parse callback even on implicit video

Ján Tomko jtomko at redhat.com
Wed May 11 10:57:31 UTC 2016


Commit 6879be48 moved adding of an implicit video device after XML
parsing. As a result, libxlDomainDeviceDefPostParse() is no longer
called to set the default vram when adding an implicit device.
Commit 6879be48 assumes virDomainVideoDefaultRAM() will set the
default vram, but it returns 0 if the domain virtType is
VIR_DOMAIN_VIRT_XEN. Attempting to start an HVM domain with vram=0
results in

error: unsupported configuration: videoram must be at least 4MB for CIRRUS

The default vram setting for Xen HVM domains depends on the device
model used (qemu-xen vs qemu-traditional), hence setting the
default is deferred to libxlDomainDeviceDefPostParse().

Call the device post-parse callback even for implicit video,
to fill out the default vram even for VIR_DOMAIN_VIRT_XEN.

https://bugzilla.redhat.com/show_bug.cgi?id=1334557
Most-of-commit-message-by: Jim Fehlig <jfehlig at suse.com>
---
 src/conf/domain_conf.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 13d0f9f..b3165fc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4362,8 +4362,7 @@ virDomainDefPostParseDeviceIterator(virDomainDefPtr def ATTRIBUTE_UNUSED,
 
 static int
 virDomainDefPostParseInternal(virDomainDefPtr def,
-                              virCapsPtr caps ATTRIBUTE_UNUSED,
-                              unsigned int parseFlags)
+                              struct virDomainDefPostParseDeviceIteratorData *data)
 {
     /* verify init path for container based domains */
     if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init) {
@@ -4372,7 +4371,7 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
         return -1;
     }
 
-    if (virDomainDefPostParseMemory(def, parseFlags) < 0)
+    if (virDomainDefPostParseMemory(def, data->parseFlags) < 0)
         return -1;
 
     if (virDomainDefRejectDuplicateControllers(def) < 0)
@@ -4387,11 +4386,22 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
     if (virDomainDefAddImplicitDevices(def) < 0)
         return -1;
 
-    /* Mark the first video as primary. If the user specified primary="yes",
-     * the parser already inserted the device at def->videos[0] */
-    if (def->nvideos != 0)
+    if (def->nvideos != 0) {
+        virDomainDeviceDef device = {
+            .type = VIR_DOMAIN_DEVICE_VIDEO,
+            .data.video = def->videos[0],
+        };
+
+        /* Mark the first video as primary. If the user specified primary="yes",
+         * the parser already inserted the device at def->videos[0] */
         def->videos[0]->primary = true;
 
+        /* videos[0] might have been added in AddImplicitDevices, after we've
+         * done the per-device post-parse */
+        if (virDomainDefPostParseDeviceIterator(NULL, &device, NULL, data) < 0)
+            return -1;
+    }
+
     /* clean up possibly duplicated metadata entries */
     virDomainDefMetadataSanitize(def);
 
@@ -4429,7 +4439,7 @@ virDomainDefPostParse(virDomainDefPtr def,
         return ret;
 
 
-    if ((ret = virDomainDefPostParseInternal(def, caps, parseFlags)) < 0)
+    if ((ret = virDomainDefPostParseInternal(def, &data)) < 0)
         return ret;
 
     if (virDomainDefPostParseCheckFeatures(def, xmlopt) < 0)
-- 
2.7.3




More information about the libvir-list mailing list