[libvirt] [PATCH v3 0/9] Enable ramfb parameter for mediated devices

This is the third version of a patch series that adds support for a boot display for mediated vgpu devices using the 'ramfb' parameter. This version fixes a bunch of test failures that I had inadvertently introduced in the last series. It also splits the 4th patch up into several separate patches as suggested by Cole to make things more readable. Jonathon Jongsma (9): qemu: fix domain device validation qemu: use g_autoptr in qemuDomainDeviceDefValidate() qemu: Set capabilities properly for tests qemu: set domain capability for ramfb device qemu: set domain capability for video type "none" qemu: validate vhost-user video backend in qemu_domain.c qemu: move validation of video accel to qemu_domain.c qemu: use domain caps to validate video device model qemu: add 'ramfb' attribute for mediated devices docs/formatdomain.html.in | 8 ++ docs/schemas/domaincommon.rng | 5 ++ src/conf/domain_capabilities.c | 17 +++- src/conf/domain_conf.c | 11 +++ src/conf/domain_conf.h | 1 + src/qemu/qemu_capabilities.c | 3 + src/qemu/qemu_command.c | 17 +++- src/qemu/qemu_domain.c | 61 ++++++------- src/qemu/qemu_process.c | 61 ------------- .../qemu_1.7.0.x86_64.xml | 1 + .../qemu_2.12.0-virt.aarch64.xml | 1 + .../qemu_2.12.0.ppc64.xml | 1 + .../qemu_2.12.0.s390x.xml | 1 + .../qemu_2.12.0.x86_64.xml | 1 + .../qemu_2.6.0-virt.aarch64.xml | 1 + .../qemu_2.6.0.aarch64.xml | 1 + .../domaincapsschemadata/qemu_2.6.0.ppc64.xml | 1 + .../qemu_2.6.0.x86_64.xml | 1 + .../domaincapsschemadata/qemu_2.7.0.s390x.xml | 1 + .../qemu_2.8.0-tcg.x86_64.xml | 1 + .../domaincapsschemadata/qemu_2.8.0.s390x.xml | 1 + .../qemu_2.8.0.x86_64.xml | 1 + .../qemu_2.9.0-q35.x86_64.xml | 1 + .../qemu_2.9.0-tcg.x86_64.xml | 1 + .../qemu_2.9.0.x86_64.xml | 1 + .../domaincapsschemadata/qemu_3.0.0.s390x.xml | 2 + .../qemu_3.1.0.x86_64.xml | 2 + .../domaincapsschemadata/qemu_4.0.0.s390x.xml | 1 + .../qemu_4.0.0.x86_64.xml | 2 + .../qemu_4.1.0.x86_64.xml | 2 + .../qemu_4.2.0.aarch64.xml | 2 + .../domaincapsschemadata/qemu_4.2.0.ppc64.xml | 1 + .../qemu_4.2.0.x86_64.xml | 2 + tests/qemuhotplugtest.c | 3 + ...tdev-mdev-display-ramfb.x86_64-latest.args | 37 ++++++++ .../hostdev-mdev-display-ramfb.xml | 33 +++++++ tests/qemuxml2argvtest.c | 2 + tests/qemuxml2xmltest.c | 89 +++++++++++-------- tests/securityselinuxlabeltest.c | 9 ++ 39 files changed, 254 insertions(+), 133 deletions(-) create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml -- 2.21.0

When the virDomainCapsDeviceDefValidate() function returned an error status (-1), we were aborting the function early, but returning the default return value (0). This patch properly returns an error in that case. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/qemu/qemu_domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 09b6c9a570..92a0df2d75 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7211,7 +7211,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, if ((ret = qemuDomainDeviceDefValidateAddress(dev, qemuCaps)) < 0) goto cleanup; - if (virDomainCapsDeviceDefValidate(domCaps, dev, def) < 0) + if ((ret = virDomainCapsDeviceDefValidate(domCaps, dev, def)) < 0) goto cleanup; switch ((virDomainDeviceType)dev->type) { -- 2.21.0

This allows us to simplify the function and avoid jumping to 'cleanup'. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/qemu/qemu_domain.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 92a0df2d75..39ab424873 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7195,8 +7195,8 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, { int ret = 0; virQEMUDriverPtr driver = opaque; - virQEMUCapsPtr qemuCaps = NULL; - virDomainCapsPtr domCaps = NULL; + g_autoptr(virQEMUCaps) qemuCaps = NULL; + g_autoptr(virDomainCaps) domCaps = NULL; if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator))) @@ -7206,13 +7206,13 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, def->os.machine, def->os.arch, def->virtType))) - goto cleanup; + return -1; if ((ret = qemuDomainDeviceDefValidateAddress(dev, qemuCaps)) < 0) - goto cleanup; + return ret; if ((ret = virDomainCapsDeviceDefValidate(domCaps, dev, def)) < 0) - goto cleanup; + return ret; switch ((virDomainDeviceType)dev->type) { case VIR_DOMAIN_DEVICE_NET: @@ -7298,9 +7298,6 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, break; } - cleanup: - virObjectUnref(qemuCaps); - virObjectUnref(domCaps); return ret; } -- 2.21.0

Several tests were not specifying the necessary qemu capabilities for what they were testing. Due to the way that the video devices are currently validated, this is not causing any problems. But a change to video device validation in a following patch would have exposed this issue and resulted in multiple test failures about the domain configuration not supporting particular video models. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- tests/qemuhotplugtest.c | 3 ++ tests/qemuxml2argvtest.c | 1 + tests/qemuxml2xmltest.c | 89 ++++++++++++++++++-------------- tests/securityselinuxlabeltest.c | 9 ++++ 4 files changed, 64 insertions(+), 38 deletions(-) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index d3da08875a..3b5d006949 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -82,6 +82,9 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_SCSI_DISK_WWN); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_QXL); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_VGA); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA); if (qemuTestCapsCacheInsert(driver.qemuCapsCache, priv->qemuCaps) < 0) goto cleanup; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5212ce50bd..7c314050f6 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2917,6 +2917,7 @@ mymain(void) DO_TEST("virtio-options", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_KEYBOARD, QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET, QEMU_CAPS_VIRTIO_INPUT_HOST, + QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_DEVICE_VHOST_USER_GPU, QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM, diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index b9364f942f..15db9d7de9 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -359,35 +359,37 @@ mymain(void) DO_TEST("disk-mirror-old", NONE); DO_TEST("disk-mirror", NONE); DO_TEST("disk-active-commit", NONE); - DO_TEST("graphics-listen-network", NONE); - DO_TEST("graphics-vnc", NONE); - DO_TEST("graphics-vnc-websocket", NONE); - DO_TEST("graphics-vnc-sasl", NONE); - DO_TEST("graphics-vnc-tls", NONE); - DO_TEST("graphics-vnc-no-listen-attr", NONE); - DO_TEST("graphics-vnc-remove-generated-socket", NONE); + DO_TEST("graphics-listen-network", QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-vnc", QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-vnc-websocket", QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-vnc-sasl", QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-vnc-tls", QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-vnc-no-listen-attr", QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-vnc-remove-generated-socket", QEMU_CAPS_DEVICE_CIRRUS_VGA); cfg->vncAutoUnixSocket = true; - DO_TEST("graphics-vnc-auto-socket-cfg", NONE); + DO_TEST("graphics-vnc-auto-socket-cfg", QEMU_CAPS_DEVICE_CIRRUS_VGA); cfg->vncAutoUnixSocket = false; - DO_TEST("graphics-vnc-socket", NONE); - DO_TEST("graphics-vnc-auto-socket", NONE); + DO_TEST("graphics-vnc-socket", QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-vnc-auto-socket", QEMU_CAPS_DEVICE_CIRRUS_VGA); DO_TEST("graphics-vnc-egl-headless", - QEMU_CAPS_EGL_HEADLESS); - - DO_TEST("graphics-sdl", NONE); - DO_TEST("graphics-sdl-fullscreen", NONE); - DO_TEST("graphics-spice", NONE); - DO_TEST("graphics-spice-compression", NONE); - DO_TEST("graphics-spice-qxl-vga", NONE); - DO_TEST("graphics-spice-socket", NONE); - DO_TEST("graphics-spice-auto-socket", NONE); + QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_EGL_HEADLESS); + + DO_TEST("graphics-sdl", QEMU_CAPS_DEVICE_VGA); + DO_TEST("graphics-sdl-fullscreen", QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-spice", QEMU_CAPS_DEVICE_QXL); + DO_TEST("graphics-spice-compression", QEMU_CAPS_DEVICE_QXL); + DO_TEST("graphics-spice-qxl-vga", QEMU_CAPS_DEVICE_QXL); + DO_TEST("graphics-spice-socket", QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-spice-auto-socket", QEMU_CAPS_DEVICE_CIRRUS_VGA); cfg->spiceAutoUnixSocket = true; - DO_TEST("graphics-spice-auto-socket-cfg", NONE); + DO_TEST("graphics-spice-auto-socket-cfg", QEMU_CAPS_DEVICE_CIRRUS_VGA); cfg->spiceAutoUnixSocket = false; DO_TEST("graphics-spice-egl-headless", + QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_EGL_HEADLESS); DO_TEST("graphics-egl-headless-rendernode", + QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_EGL_HEADLESS, QEMU_CAPS_EGL_HEADLESS_RENDERNODE); @@ -419,15 +421,15 @@ mymain(void) DO_TEST("sound", NONE); DO_TEST("sound-device", NONE); DO_TEST("watchdog", NONE); - DO_TEST("net-bandwidth", NONE); - DO_TEST("net-bandwidth2", NONE); + DO_TEST("net-bandwidth", QEMU_CAPS_DEVICE_VGA); + DO_TEST("net-bandwidth2", QEMU_CAPS_DEVICE_VGA); DO_TEST("net-mtu", NONE); DO_TEST("net-coalesce", NONE); DO_TEST("net-many-models", NONE); DO_TEST("serial-tcp-tlsx509-chardev", NONE); DO_TEST("serial-tcp-tlsx509-chardev-notls", NONE); - DO_TEST("serial-spiceport", NONE); + DO_TEST("serial-spiceport", QEMU_CAPS_DEVICE_QXL); DO_TEST("serial-spiceport-nospice", NONE); DO_TEST("console-compat", NONE); DO_TEST("console-compat2", NONE); @@ -457,7 +459,9 @@ mymain(void) QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_ZPCI); DO_TEST("hostdev-mdev-precreated", NONE); - DO_TEST("hostdev-mdev-display", QEMU_CAPS_VFIO_PCI_DISPLAY); + DO_TEST("hostdev-mdev-display", + QEMU_CAPS_DEVICE_QXL, + QEMU_CAPS_VFIO_PCI_DISPLAY); DO_TEST("pci-rom", NONE); DO_TEST("pci-rom-disabled", NONE); DO_TEST("pci-rom-disabled-invalid", NONE); @@ -497,7 +501,7 @@ mymain(void) DO_TEST("event_idx", NONE); DO_TEST("vhost_queues", NONE); DO_TEST("interface-driver", NONE); - DO_TEST("interface-server", NONE); + DO_TEST("interface-server", QEMU_CAPS_DEVICE_CIRRUS_VGA); DO_TEST("virtio-lun", NONE); DO_TEST("usb-none", NONE); @@ -545,7 +549,7 @@ mymain(void) DO_TEST("seclabel-dynamic-none", NONE); DO_TEST("seclabel-device-multiple", NONE); DO_TEST_FULL("seclabel-dynamic-none-relabel", WHEN_INACTIVE, - ARG_QEMU_CAPS, NONE); + ARG_QEMU_CAPS, QEMU_CAPS_DEVICE_CIRRUS_VGA, NONE); DO_TEST("numad-static-vcpu-no-numatune", NONE); DO_TEST("disk-scsi-lun-passthrough-sgio", @@ -660,8 +664,8 @@ mymain(void) QEMU_CAPS_SCSI_LSI); DO_TEST("console-virtio", NONE); DO_TEST("serial-target-port-auto", NONE); - DO_TEST("graphics-listen-network2", NONE); - DO_TEST("graphics-spice-timeout", NONE); + DO_TEST("graphics-listen-network2", QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-spice-timeout", QEMU_CAPS_DEVICE_VGA); DO_TEST("numad-auto-vcpu-no-numatune", NONE); DO_TEST("numad-auto-memory-vcpu-no-cpuset-and-placement", NONE); DO_TEST("numad-auto-memory-vcpu-cpuset", NONE); @@ -690,7 +694,7 @@ mymain(void) DO_TEST("pci-autoadd-idx", QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_CIRRUS_VGA); - DO_TEST("pci-autofill-addr", NONE); + DO_TEST("pci-autofill-addr", QEMU_CAPS_DEVICE_CIRRUS_VGA); DO_TEST("q35", QEMU_CAPS_DEVICE_PCI_BRIDGE, @@ -1155,10 +1159,16 @@ mymain(void) DO_TEST("memory-hotplug-nvdimm-readonly", NONE); DO_TEST("net-udp", NONE); - DO_TEST("video-virtio-gpu-device", NONE); - DO_TEST("video-virtio-gpu-virgl", NONE); - DO_TEST("video-virtio-gpu-spice-gl", NONE); - DO_TEST("video-virtio-gpu-sdl-gl", NONE); + DO_TEST("video-virtio-gpu-device", QEMU_CAPS_DEVICE_VIRTIO_GPU); + DO_TEST("video-virtio-gpu-virgl", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_VIRGL); + DO_TEST("video-virtio-gpu-spice-gl", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_VIRGL); + DO_TEST("video-virtio-gpu-sdl-gl", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_VIRGL); DO_TEST("virtio-input", QEMU_CAPS_VIRTIO_KEYBOARD, @@ -1182,7 +1192,8 @@ mymain(void) QEMU_CAPS_OBJECT_RNG_RANDOM, QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM, - QEMU_CAPS_VIRTIO_PCI_ATS); + QEMU_CAPS_VIRTIO_PCI_ATS, + QEMU_CAPS_DEVICE_VHOST_USER_GPU); DO_TEST("fd-memory-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_KVM); @@ -1208,9 +1219,9 @@ mymain(void) QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_QXL); - DO_TEST("video-qxl-heads", NONE); - DO_TEST("video-qxl-noheads", NONE); - DO_TEST("video-virtio-gpu-secondary", NONE); + DO_TEST("video-qxl-heads", QEMU_CAPS_DEVICE_QXL); + DO_TEST("video-qxl-noheads", QEMU_CAPS_DEVICE_QXL); + DO_TEST("video-virtio-gpu-secondary", QEMU_CAPS_DEVICE_VIRTIO_GPU); DO_TEST("video-virtio-gpu-ccw", QEMU_CAPS_CCW, QEMU_CAPS_DEVICE_VIRTIO_GPU, @@ -1257,7 +1268,9 @@ mymain(void) DO_TEST("pseries-cpu-exact", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE); - DO_TEST("user-aliases", QEMU_CAPS_QCOW2_LUKS); + DO_TEST("user-aliases", + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_QCOW2_LUKS); DO_TEST("input-virtio-ccw", QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_KEYBOARD, diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c index 6f9b5c0e70..eba5b0b6af 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -340,6 +340,7 @@ mymain(void) { int ret = 0; int rc = testUserXattrEnabled(); + g_autoptr(virQEMUCaps) qemuCaps = NULL; if (rc < 0) return EXIT_FAILURE; @@ -357,6 +358,14 @@ mymain(void) if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; + if (!(qemuCaps = virQEMUCapsNew())) + return EXIT_FAILURE; + + virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA); + + if (qemuTestCapsCacheInsert(driver.qemuCapsCache, qemuCaps) < 0) + return EXIT_FAILURE; + #define DO_TEST_LABELING(name) \ if (virTestRun("Labelling " # name, testSELinuxLabeling, name) < 0) \ ret = -1; -- 2.21.0

commit 9bfcf0f62d9cf16db526a948242a7409ae883209 added the QEMU_CAPS_DEVICE_RAMFB capability but did not set the domain capability. This patch sets the domain capability for the ramfb device and updates the tests. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/qemu/qemu_capabilities.c | 2 ++ tests/domaincapsschemadata/qemu_3.0.0.s390x.xml | 1 + tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_4.2.0.aarch64.xml | 1 + tests/domaincapsschemadata/qemu_4.2.0.x86_64.xml | 1 + 7 files changed, 8 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 3ce1556fc2..381e7bcf34 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5400,6 +5400,8 @@ virQEMUCapsFillDomainDeviceVideoCaps(virQEMUCapsPtr qemuCaps, VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_VIRTIO); if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_BOCHS_DISPLAY)) VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_BOCHS); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_RAMFB)) + VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_RAMFB); return 0; } diff --git a/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml b/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml index 0e81e2ea33..d32f7b5875 100644 --- a/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml @@ -158,6 +158,7 @@ <video supported='yes'> <enum name='modelType'> <value>virtio</value> + <value>ramfb</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml b/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml index 059403cebc..ecb1f06e90 100644 --- a/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml @@ -128,6 +128,7 @@ <value>qxl</value> <value>virtio</value> <value>bochs</value> + <value>ramfb</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml index eb24b9a604..2a475f20be 100644 --- a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml @@ -128,6 +128,7 @@ <value>qxl</value> <value>virtio</value> <value>bochs</value> + <value>ramfb</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml b/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml index f5685d2068..07b869859c 100644 --- a/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml @@ -132,6 +132,7 @@ <value>qxl</value> <value>virtio</value> <value>bochs</value> + <value>ramfb</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_4.2.0.aarch64.xml b/tests/domaincapsschemadata/qemu_4.2.0.aarch64.xml index b53c29c482..c384ae2f9a 100644 --- a/tests/domaincapsschemadata/qemu_4.2.0.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_4.2.0.aarch64.xml @@ -100,6 +100,7 @@ <value>vmvga</value> <value>virtio</value> <value>bochs</value> + <value>ramfb</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_4.2.0.x86_64.xml b/tests/domaincapsschemadata/qemu_4.2.0.x86_64.xml index 5bd376bb2e..2f86eac7f0 100644 --- a/tests/domaincapsschemadata/qemu_4.2.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_4.2.0.x86_64.xml @@ -132,6 +132,7 @@ <value>qxl</value> <value>virtio</value> <value>bochs</value> + <value>ramfb</value> </enum> </video> <hostdev supported='yes'> -- 2.21.0

In a follow-up commit, we will use the domain capabilities to validate video device configurations, which means that we also need to make sure that the domain capabilities include the "none" video device. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/qemu/qemu_capabilities.c | 1 + tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml | 1 + tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml | 1 + tests/domaincapsschemadata/qemu_2.12.0.s390x.xml | 1 + tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml | 1 + tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml | 1 + tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml | 1 + tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_2.7.0.s390x.xml | 1 + tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_2.8.0.s390x.xml | 1 + tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_3.0.0.s390x.xml | 1 + tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_4.0.0.s390x.xml | 1 + tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml | 1 + tests/domaincapsschemadata/qemu_4.2.0.aarch64.xml | 1 + tests/domaincapsschemadata/qemu_4.2.0.ppc64.xml | 1 + tests/domaincapsschemadata/qemu_4.2.0.x86_64.xml | 1 + 25 files changed, 25 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 381e7bcf34..206a0ff241 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5388,6 +5388,7 @@ virQEMUCapsFillDomainDeviceVideoCaps(virQEMUCapsPtr qemuCaps, dev->supported = VIR_TRISTATE_BOOL_YES; dev->modelType.report = true; + VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_NONE); if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_VGA); if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA)) diff --git a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml index a2df336833..2c73c99d35 100644 --- a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml @@ -92,6 +92,7 @@ <value>cirrus</value> <value>vmvga</value> <value>qxl</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml index ed1af3224b..d5bb85878d 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml @@ -96,6 +96,7 @@ <enum name='modelType'> <value>vga</value> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml index e8d3c22337..b9d51e1752 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml @@ -64,6 +64,7 @@ <enum name='modelType'> <value>vga</value> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml index 8d039f3514..9b8e90671d 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml @@ -152,6 +152,7 @@ <video supported='yes'> <enum name='modelType'> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml index 109162ffd8..828aa03ed2 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml @@ -125,6 +125,7 @@ <value>vmvga</value> <value>qxl</value> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml index 13441b9923..ee76cb2e83 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml @@ -93,6 +93,7 @@ <enum name='modelType'> <value>vga</value> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml index 974739c38e..a3ada3a6a5 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml @@ -91,6 +91,7 @@ <enum name='modelType'> <value>vga</value> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml index 9f628a3652..a4dd2a51cc 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml @@ -64,6 +64,7 @@ <enum name='modelType'> <value>vga</value> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml index bb1f784328..26b569d914 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml @@ -99,6 +99,7 @@ <value>vmvga</value> <value>qxl</value> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml index 322d12c719..a1e282482c 100644 --- a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml @@ -57,6 +57,7 @@ <video supported='yes'> <enum name='modelType'> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml b/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml index b6679a6e64..38db60a748 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml @@ -100,6 +100,7 @@ <value>vmvga</value> <value>qxl</value> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml index c7a4578f61..dec4ca960b 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml @@ -138,6 +138,7 @@ <video supported='yes'> <enum name='modelType'> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml index 3af3fcc4a9..057aac246f 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml @@ -100,6 +100,7 @@ <value>vmvga</value> <value>qxl</value> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml index aac295a20d..ad894728ea 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml @@ -109,6 +109,7 @@ <value>vmvga</value> <value>qxl</value> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml index 12537c039b..3cc81e9fa1 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml @@ -132,6 +132,7 @@ <value>vmvga</value> <value>qxl</value> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml index 80fc7e1657..790b39bd7d 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml @@ -109,6 +109,7 @@ <value>vmvga</value> <value>qxl</value> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml b/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml index d32f7b5875..55b442ced8 100644 --- a/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml @@ -158,6 +158,7 @@ <video supported='yes'> <enum name='modelType'> <value>virtio</value> + <value>none</value> <value>ramfb</value> </enum> </video> diff --git a/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml b/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml index ecb1f06e90..5a121eb987 100644 --- a/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml @@ -127,6 +127,7 @@ <value>vmvga</value> <value>qxl</value> <value>virtio</value> + <value>none</value> <value>bochs</value> <value>ramfb</value> </enum> diff --git a/tests/domaincapsschemadata/qemu_4.0.0.s390x.xml b/tests/domaincapsschemadata/qemu_4.0.0.s390x.xml index e68f8e8d9a..6cda114260 100644 --- a/tests/domaincapsschemadata/qemu_4.0.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_4.0.0.s390x.xml @@ -164,6 +164,7 @@ <video supported='yes'> <enum name='modelType'> <value>virtio</value> + <value>none</value> </enum> </video> <hostdev supported='yes'> diff --git a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml index 2a475f20be..00bf7d1ec3 100644 --- a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml @@ -127,6 +127,7 @@ <value>vmvga</value> <value>qxl</value> <value>virtio</value> + <value>none</value> <value>bochs</value> <value>ramfb</value> </enum> diff --git a/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml b/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml index 07b869859c..97533c6d05 100644 --- a/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml @@ -131,6 +131,7 @@ <value>vmvga</value> <value>qxl</value> <value>virtio</value> + <value>none</value> <value>bochs</value> <value>ramfb</value> </enum> diff --git a/tests/domaincapsschemadata/qemu_4.2.0.aarch64.xml b/tests/domaincapsschemadata/qemu_4.2.0.aarch64.xml index c384ae2f9a..0d8ccafefb 100644 --- a/tests/domaincapsschemadata/qemu_4.2.0.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_4.2.0.aarch64.xml @@ -99,6 +99,7 @@ <value>cirrus</value> <value>vmvga</value> <value>virtio</value> + <value>none</value> <value>bochs</value> <value>ramfb</value> </enum> diff --git a/tests/domaincapsschemadata/qemu_4.2.0.ppc64.xml b/tests/domaincapsschemadata/qemu_4.2.0.ppc64.xml index 78e141dfb2..df7a06c690 100644 --- a/tests/domaincapsschemadata/qemu_4.2.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_4.2.0.ppc64.xml @@ -66,6 +66,7 @@ <value>cirrus</value> <value>vmvga</value> <value>virtio</value> + <value>none</value> <value>bochs</value> </enum> </video> diff --git a/tests/domaincapsschemadata/qemu_4.2.0.x86_64.xml b/tests/domaincapsschemadata/qemu_4.2.0.x86_64.xml index 2f86eac7f0..7938433ed9 100644 --- a/tests/domaincapsschemadata/qemu_4.2.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_4.2.0.x86_64.xml @@ -131,6 +131,7 @@ <value>vmvga</value> <value>qxl</value> <value>virtio</value> + <value>none</value> <value>bochs</value> <value>ramfb</value> </enum> -- 2.21.0

The goal is to move all of the video device validation to a single place and use domain caps to validate the supported video device models. Since qemuDomainDeviceDefValidateVideo() is called from qemuProcessStartValidate(), these changes should not change anny behavior. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/qemu/qemu_domain.c | 14 ++++++++++++-- src/qemu/qemu_process.c | 9 +-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 39ab424873..0a6d774437 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5704,7 +5704,8 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev, static int -qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video) +qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video, + virQEMUCapsPtr qemuCaps) { switch ((virDomainVideoType) video->type) { case VIR_DOMAIN_VIDEO_TYPE_NONE: @@ -5784,6 +5785,15 @@ qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video) } } + if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { + if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_USER_GPU)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("this QEMU does not support 'vhost-user' video device")); + return -1; + } + } + return 0; } @@ -7245,7 +7255,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, break; case VIR_DOMAIN_DEVICE_VIDEO: - ret = qemuDomainDeviceDefValidateVideo(dev->data.video); + ret = qemuDomainDeviceDefValidateVideo(dev->data.video, qemuCaps); break; case VIR_DOMAIN_DEVICE_DISK: diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9eaea4edfd..25465f05e2 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5251,14 +5251,7 @@ qemuProcessStartValidateVideo(virDomainObjPtr vm, for (i = 0; i < vm->def->nvideos; i++) { video = vm->def->videos[i]; - if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { - if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_USER_GPU)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("this QEMU does not support 'vhost-user' video device")); - return -1; - } - } else { + if (video->backend != VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { if ((video->type == VIR_DOMAIN_VIDEO_TYPE_VGA && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) || (video->type == VIR_DOMAIN_VIDEO_TYPE_CIRRUS && -- 2.21.0

Continue consolidation of video device validation started in previous patch. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/qemu/qemu_domain.c | 9 +++++++++ src/qemu/qemu_process.c | 11 ----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0a6d774437..8bd5891e53 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5792,6 +5792,15 @@ qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video, _("this QEMU does not support 'vhost-user' video device")); return -1; } + } else if (video->accel) { + if (video->accel->accel3d == VIR_TRISTATE_SWITCH_ON && + (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO || + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_VIRGL))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("%s 3d acceleration is not supported"), + virDomainVideoTypeToString(video->type)); + return -1; + } } return 0; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 25465f05e2..5ef3e37fc2 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5274,17 +5274,6 @@ qemuProcessStartValidateVideo(virDomainObjPtr vm, virDomainVideoTypeToString(video->type)); return -1; } - - if (video->accel) { - if (video->accel->accel3d == VIR_TRISTATE_SWITCH_ON && - (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO || - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_VIRGL))) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("%s 3d acceleration is not supported"), - virDomainVideoTypeToString(video->type)); - return -1; - } - } } } -- 2.21.0

As suggested by Cole, this patch uses the domain capabilities to validate the supported video model types. This allows us to remove the model type validation from qemu_process.c and qemu_domain.c and consolidates it all in a single place that will automatically adjust when new domain capabilities are added. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- src/conf/domain_capabilities.c | 17 +++++++++++++- src/qemu/qemu_domain.c | 23 ++---------------- src/qemu/qemu_process.c | 43 ---------------------------------- 3 files changed, 18 insertions(+), 65 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 43a778a505..f55a6ebf5b 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -686,6 +686,19 @@ virDomainCapsDeviceRNGDefValidate(virDomainCapsPtr const caps, return 0; } +static int +virDomainCapsDeviceVideoDefValidate(virDomainCapsPtr const caps, + const virDomainVideoDefPtr dev) +{ + if (ENUM_VALUE_MISSING(caps->video.modelType, dev->type)) { + ENUM_VALUE_ERROR("video model", + virDomainVideoTypeToString(dev->type)); + return -1; + } + + return 0; +} + int virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps, @@ -698,6 +711,9 @@ virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps, case VIR_DOMAIN_DEVICE_RNG: ret = virDomainCapsDeviceRNGDefValidate(caps, dev->data.rng); break; + case VIR_DOMAIN_DEVICE_VIDEO: + ret = virDomainCapsDeviceVideoDefValidate(caps, dev->data.video); + break; case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_REDIRDEV: @@ -706,7 +722,6 @@ virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps, case VIR_DOMAIN_DEVICE_CHR: case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_HOSTDEV: - case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_INPUT: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8bd5891e53..7ec6c0a748 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5707,28 +5707,9 @@ static int qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video, virQEMUCapsPtr qemuCaps) { - switch ((virDomainVideoType) video->type) { - case VIR_DOMAIN_VIDEO_TYPE_NONE: + /* there's no properties to validate for NONE video devices */ + if (video->type == VIR_DOMAIN_VIDEO_TYPE_NONE) return 0; - case VIR_DOMAIN_VIDEO_TYPE_XEN: - case VIR_DOMAIN_VIDEO_TYPE_VBOX: - case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: - case VIR_DOMAIN_VIDEO_TYPE_GOP: - case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("video type '%s' is not supported with QEMU"), - virDomainVideoTypeToString(video->type)); - return -1; - case VIR_DOMAIN_VIDEO_TYPE_VGA: - case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: - case VIR_DOMAIN_VIDEO_TYPE_VMVGA: - case VIR_DOMAIN_VIDEO_TYPE_QXL: - case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: - case VIR_DOMAIN_VIDEO_TYPE_BOCHS: - case VIR_DOMAIN_VIDEO_TYPE_RAMFB: - case VIR_DOMAIN_VIDEO_TYPE_LAST: - break; - } if (!video->primary && video->type != VIR_DOMAIN_VIDEO_TYPE_QXL && diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5ef3e37fc2..c066f5eb82 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5241,46 +5241,6 @@ qemuProcessStartValidateGraphics(virDomainObjPtr vm) } -static int -qemuProcessStartValidateVideo(virDomainObjPtr vm, - virQEMUCapsPtr qemuCaps) -{ - size_t i; - virDomainVideoDefPtr video; - - for (i = 0; i < vm->def->nvideos; i++) { - video = vm->def->videos[i]; - - if (video->backend != VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { - if ((video->type == VIR_DOMAIN_VIDEO_TYPE_VGA && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) || - (video->type == VIR_DOMAIN_VIDEO_TYPE_CIRRUS && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA)) || - (video->type == VIR_DOMAIN_VIDEO_TYPE_VMVGA && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMWARE_SVGA)) || - (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL)) || - (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU)) || - (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO && - video->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW)) || - (video->type == VIR_DOMAIN_VIDEO_TYPE_BOCHS && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_BOCHS_DISPLAY)) || - (video->type == VIR_DOMAIN_VIDEO_TYPE_RAMFB && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_RAMFB))) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("this QEMU does not support '%s' video device"), - virDomainVideoTypeToString(video->type)); - return -1; - } - } - } - - return 0; -} - - static int qemuProcessStartValidateIOThreads(virDomainObjPtr vm, virQEMUCapsPtr qemuCaps) @@ -5465,9 +5425,6 @@ qemuProcessStartValidate(virQEMUDriverPtr driver, if (qemuProcessStartValidateGraphics(vm) < 0) return -1; - if (qemuProcessStartValidateVideo(vm, qemuCaps) < 0) - return -1; - if (qemuProcessStartValidateIOThreads(vm, qemuCaps) < 0) return -1; -- 2.21.0

The 'ramfb' attribute provides a framebuffer to the guest that can be used as a boot display for the vgpu For example, the following configuration can be used to provide a vgpu with a boot display: <hostdev mode='subsystem' type='mdev' model='vfio-pci' display='on' ramfb='on'> <source> <address uuid='$UUID'/> </source> </hostdev> Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- docs/formatdomain.html.in | 8 ++++ docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 11 ++++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 17 ++++++++- ...tdev-mdev-display-ramfb.x86_64-latest.args | 37 +++++++++++++++++++ .../hostdev-mdev-display-ramfb.xml | 33 +++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 8 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 500f114f41..50f9ff9618 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4847,6 +4847,14 @@ <a href="#elementsGraphics">graphical framebuffer</a> in order to use this attribute, currently only supported with VNC, Spice and egl-headless graphics devices. + + <span class="since">Since version 5.9.0</span>, there is an optional + <code>ramfb</code> attribute for devices with + <code>model='vfio-pci'</code>. Supported values are either + <code>on</code> or <code>off</code> (default is 'off'). When + enabled, this attribute provides a memory framebuffer device to the + guest. This framebuffer will be used as a boot display when a vgpu + device is the primary display. <p> Note: There are also some implications on the usage of guest's address type depending on the <code>model</code> attribute, diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ead5a25068..57e0dcf6ed 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4769,6 +4769,11 @@ <value>vfio-ap</value> </choice> </attribute> + <optional> + <attribute name="ramfb"> + <ref name="virOnOff"/> + </attribute> + </optional> <optional> <attribute name="display"> <ref name="virOnOff"/> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2e6a113de3..ab75f13eec 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8130,6 +8130,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, g_autofree char *backendStr = NULL; g_autofree char *model = NULL; g_autofree char *display = NULL; + g_autofree char *ramfb = NULL; /* @managed can be read from the xml document - it is always an * attribute of the toplevel element, no matter what type of @@ -8145,6 +8146,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, rawio = virXMLPropString(node, "rawio"); model = virXMLPropString(node, "model"); display = virXMLPropString(node, "display"); + ramfb = virXMLPropString(node, "ramfb"); /* @type is passed in from the caller rather than read from the * xml document, because it is specified in different places for @@ -8253,6 +8255,15 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, display); return -1; } + + if (ramfb && + (mdevsrc->ramfb = virTristateSwitchTypeFromString(ramfb)) <= 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown value '%s' for <hostdev> attribute " + "'ramfb'"), + ramfb); + return -1; + } } switch (def->source.subsys.type) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index edac6250e4..72b2a8c482 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -262,6 +262,7 @@ struct _virDomainHostdevSubsysMediatedDev { int model; /* enum virMediatedDeviceModelType */ int display; /* virTristateSwitch */ char uuidstr[VIR_UUID_STRING_BUFLEN]; /* mediated device's uuid string */ + int ramfb; /* virTristateSwitch */ }; typedef enum { diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e98195b1d7..1a2d0c173d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5416,6 +5416,17 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, return virBufferContentAndReset(&buf); } +static const char * +qemuBuildHostdevMdevModelTypeString(virDomainHostdevSubsysMediatedDevPtr mdev) +{ + /* when the 'ramfb' attribute is set, we must use the nohotplug variant + * rather than 'vfio-pci' */ + if (mdev->model == VIR_MDEV_MODEL_TYPE_VFIO_PCI && + mdev->ramfb == VIR_TRISTATE_SWITCH_ON) + return "vfio-pci-nohotplug"; + + return virMediatedDeviceModelTypeToString(mdev->model); +} char * qemuBuildHostdevMediatedDevStr(const virDomainDef *def, @@ -5430,7 +5441,7 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def, if (!(mdevPath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr))) return NULL; - dev_str = virMediatedDeviceModelTypeToString(mdevsrc->model); + dev_str = qemuBuildHostdevMdevModelTypeString(mdevsrc); if (!dev_str) return NULL; @@ -5448,6 +5459,10 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def, if (dev->info->bootIndex) virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex); + if (mdevsrc->ramfb == VIR_TRISTATE_SWITCH_ON) + virBufferAsprintf(&buf, ",ramfb=%s", + virTristateSwitchTypeToString(mdevsrc->ramfb)); + if (virBufferCheckError(&buf) < 0) return NULL; diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args new file mode 100644 index 0000000000..30d2f83318 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args @@ -0,0 +1,37 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest2 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest2/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest2/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest2/.config \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i686 \ +-name guest=QEMUGuest2,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest2/master-key.aes \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-vnc 127.0.0.1:0 \ +-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,\ +vram64_size_mb=0,vgamem_mb=16,max_outputs=1,bus=pci.0,addr=0x2 \ +-device vfio-pci-nohotplug,id=hostdev0,\ +sysfsdev=/sys/bus/mdev/devices/53764d0e-85a0-42b4-af5c-2046b460b1dc,display=on,\ +bus=pci.0,addr=0x3,ramfb=on \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml b/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml new file mode 100644 index 0000000000..2e7851b2b0 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml @@ -0,0 +1,33 @@ +<domain type='qemu'> + <name>QEMUGuest2</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-i686</emulator> + <controller type='usb' index='0'> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <controller type='ide' index='0'> + </controller> + <graphics type='vnc'/> + <hostdev mode='subsystem' type='mdev' model='vfio-pci' display='on' ramfb='on'> + <source> + <address uuid='53764d0e-85a0-42b4-af5c-2046b460b1dc'/> + </source> + </hostdev> + <video> + <model type='qxl' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 7c314050f6..56fb6f00a9 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1638,6 +1638,7 @@ mymain(void) DO_TEST_PARSE_ERROR("hostdev-mdev-display-missing-graphics", QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_VFIO_PCI_DISPLAY); + DO_TEST_CAPS_LATEST("hostdev-mdev-display-ramfb"); DO_TEST_PARSE_ERROR("hostdev-vfio-zpci-wrong-arch", QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("hostdev-vfio-zpci", -- 2.21.0

On 10/18/19 11:30 AM, Jonathon Jongsma wrote:
This is the third version of a patch series that adds support for a boot display for mediated vgpu devices using the 'ramfb' parameter. This version fixes a bunch of test failures that I had inadvertently introduced in the last series. It also splits the 4th patch up into several separate patches as suggested by Cole to make things more readable.
Jonathon Jongsma (9): qemu: fix domain device validation qemu: use g_autoptr in qemuDomainDeviceDefValidate() qemu: Set capabilities properly for tests qemu: set domain capability for ramfb device qemu: set domain capability for video type "none" qemu: validate vhost-user video backend in qemu_domain.c qemu: move validation of video accel to qemu_domain.c qemu: use domain caps to validate video device model qemu: add 'ramfb' attribute for mediated devices
Pushed with some fixups: * rebased and resolved conflicts * fixed function spacing in the last two patches, to preserve existing 2 line spacing (this was a bit ambiguous in the second to last patch) * adjusted docs version in the last patch to mention 5.10.0 Thanks, Cole

On 11/14/19 11:40 AM, Cole Robinson wrote:
On 10/18/19 11:30 AM, Jonathon Jongsma wrote:
This is the third version of a patch series that adds support for a boot display for mediated vgpu devices using the 'ramfb' parameter. This version fixes a bunch of test failures that I had inadvertently introduced in the last series. It also splits the 4th patch up into several separate patches as suggested by Cole to make things more readable.
Jonathon Jongsma (9): qemu: fix domain device validation qemu: use g_autoptr in qemuDomainDeviceDefValidate() qemu: Set capabilities properly for tests qemu: set domain capability for ramfb device qemu: set domain capability for video type "none" qemu: validate vhost-user video backend in qemu_domain.c qemu: move validation of video accel to qemu_domain.c qemu: use domain caps to validate video device model qemu: add 'ramfb' attribute for mediated devices
Pushed with some fixups:
* rebased and resolved conflicts * fixed function spacing in the last two patches, to preserve existing 2 line spacing (this was a bit ambiguous in the second to last patch) * adjusted docs version in the last patch to mention 5.10.0
Also, ramfb addition warrants a news.xml update too Thanks, Cole
participants (2)
-
Cole Robinson
-
Jonathon Jongsma