From 45270337f057f26ce484f6e2cf197aeeb7d0c4ea Mon Sep 17 00:00:00 2001 From: Daniel Henrique Barboza Date: Mon, 9 Dec 2019 20:15:26 -0300 Subject: [PATCH] qemu: command: move qemuBuildGraphicsVNCCommandLine validation to qemu_domain.c Move the VNC cap validation from qemuBuildGraphicsVNCCommandLine() to qemuDomainDeviceDefValidateGraphics(). This function is called by qemuDomainDefValidate(), validating the graphics parameters in domain define time. Tests were adapted to consider SDL validation in this earlier stage. Reviewed-by: Cole Robinson Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_command.c | 6 ---- src/qemu/qemu_domain.c | 7 ++++- tests/qemuhotplugtest.c | 1 + tests/qemuxml2xmltest.c | 63 +++++++++++++++++++++++++++++------------ 4 files changed, 52 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3a360b72e0..8ff092cc44 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7448,12 +7448,6 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, virDomainGraphicsListenDefPtr glisten = NULL; bool escapeAddr; - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("vnc graphics are not supported with this QEMU")); - return -1; - } - if (!(glisten = virDomainGraphicsGetListen(graphics, 0))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing listen element")); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3a636097c7..a8b4762320 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7694,9 +7694,14 @@ qemuDomainDeviceDefValidateGraphics(const virDomainGraphicsDef *graphics, break; case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("vnc graphics are not supported with this QEMU")); + return -1; + } break; + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: - break; case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS: break; case VIR_DOMAIN_GRAPHICS_TYPE_RDP: diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index cc2824ea14..6490067494 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -84,6 +84,7 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_PIIX_DISABLE_S3); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_PIIX_DISABLE_S4); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VNC); if (qemuTestCapsCacheInsert(driver.qemuCapsCache, priv->qemuCaps) < 0) return -1; diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 3a69643456..677398b11d 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -341,20 +341,42 @@ mymain(void) DO_TEST("disk-mirror-old", NONE); DO_TEST("disk-mirror", NONE); DO_TEST("disk-active-commit", 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); + DO_TEST("graphics-listen-network", + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_VNC); + DO_TEST("graphics-vnc", + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_VNC); + DO_TEST("graphics-vnc-websocket", + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_VNC); + DO_TEST("graphics-vnc-sasl", + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_VNC); + DO_TEST("graphics-vnc-tls", + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_VNC); + DO_TEST("graphics-vnc-no-listen-attr", + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_VNC); + DO_TEST("graphics-vnc-remove-generated-socket", + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_VNC); cfg->vncAutoUnixSocket = true; - DO_TEST("graphics-vnc-auto-socket-cfg", QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-vnc-auto-socket-cfg", + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_VNC); cfg->vncAutoUnixSocket = false; - 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-socket", + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_VNC); + DO_TEST("graphics-vnc-auto-socket", + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_VNC); DO_TEST("graphics-vnc-egl-headless", - QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_EGL_HEADLESS); + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_EGL_HEADLESS, + QEMU_CAPS_VNC); DO_TEST_CAPS_ARCH_LATEST("default-video-type-aarch64", "aarch64"); DO_TEST_CAPS_ARCH_LATEST("default-video-type-ppc64", "ppc64"); @@ -413,8 +435,8 @@ mymain(void) DO_TEST("sound", NONE); DO_TEST("sound-device", NONE); DO_TEST("watchdog", NONE); - DO_TEST("net-bandwidth", QEMU_CAPS_DEVICE_VGA); - DO_TEST("net-bandwidth2", QEMU_CAPS_DEVICE_VGA); + DO_TEST("net-bandwidth", QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_VNC); + DO_TEST("net-bandwidth2", QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_VNC); DO_TEST("net-mtu", NONE); DO_TEST("net-coalesce", NONE); DO_TEST("net-many-models", NONE); @@ -455,7 +477,8 @@ mymain(void) DO_TEST("hostdev-mdev-display", QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_VFIO_PCI_DISPLAY, - QEMU_CAPS_DEVICE_VFIO_PCI); + QEMU_CAPS_DEVICE_VFIO_PCI, + QEMU_CAPS_VNC); DO_TEST("pci-rom", NONE); DO_TEST("pci-rom-disabled", NONE); DO_TEST("pci-rom-disabled-invalid", NONE); @@ -498,7 +521,8 @@ mymain(void) DO_TEST("interface-server", QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_PIIX_DISABLE_S3, - QEMU_CAPS_PIIX_DISABLE_S4); + QEMU_CAPS_PIIX_DISABLE_S4, + QEMU_CAPS_VNC); DO_TEST("virtio-lun", NONE); DO_TEST("usb-none", NONE); @@ -666,7 +690,9 @@ mymain(void) QEMU_CAPS_SCSI_LSI); DO_TEST("console-virtio", NONE); DO_TEST("serial-target-port-auto", NONE); - DO_TEST("graphics-listen-network2", QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-listen-network2", + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_VNC); 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); @@ -1246,7 +1272,7 @@ mymain(void) QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS, QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW); - DO_TEST("video-none-device", NONE); + DO_TEST("video-none-device", QEMU_CAPS_VNC); DO_TEST_CAPS_LATEST("intel-iommu"); DO_TEST_CAPS_VER("intel-iommu", "2.6.0"); @@ -1283,7 +1309,8 @@ mymain(void) QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_PIIX_DISABLE_S3, - QEMU_CAPS_PIIX_DISABLE_S4); + QEMU_CAPS_PIIX_DISABLE_S4, + QEMU_CAPS_VNC); DO_TEST("input-virtio-ccw", QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_KEYBOARD, -- GitLab