commit 3e4286703273b06a21ae07f3e76a66f9661199dc Author: Ján Tomko Date: Wed May 11 12:13:51 2016 +0200 Call per-device post-parse callback even on implicit video 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 Index: libvirt-1.3.4/src/conf/domain_conf.c =================================================================== --- libvirt-1.3.4.orig/src/conf/domain_conf.c +++ libvirt-1.3.4/src/conf/domain_conf.c @@ -4321,8 +4321,7 @@ virDomainDefPostParseDeviceIterator(virD 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) { @@ -4331,7 +4330,7 @@ virDomainDefPostParseInternal(virDomainD return -1; } - if (virDomainDefPostParseMemory(def, parseFlags) < 0) + if (virDomainDefPostParseMemory(def, data->parseFlags) < 0) return -1; if (virDomainDefRejectDuplicateControllers(def) < 0) @@ -4346,11 +4345,22 @@ virDomainDefPostParseInternal(virDomainD 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); @@ -4388,7 +4398,7 @@ virDomainDefPostParse(virDomainDefPtr de return ret; - if ((ret = virDomainDefPostParseInternal(def, caps, parseFlags)) < 0) + if ((ret = virDomainDefPostParseInternal(def, &data)) < 0) return ret; if (virDomainDefPostParseCheckFeatures(def, xmlopt) < 0)