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.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
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 70b80fad63..7661527d39 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7400,12 +7400,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 b33e150690..c25adbc4f3 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7627,9 +7627,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 0645b936d0..9646a30fb6 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 052c7034e1..f22bc0c9e6 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");
@@ -418,8 +440,8 @@ mymain(void)
QEMU_CAPS_HDA_DUPLEX,
QEMU_CAPS_HDA_OUTPUT);
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);
@@ -460,7 +482,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);
@@ -503,7 +526,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);
@@ -671,7 +695,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);
@@ -1251,7 +1277,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");
@@ -1288,7 +1314,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,
--
2.23.0