Move EGL Headless validation from qemuBuildGraphicsEGLHeadlessCommandLine()
to qemuDomainDeviceDefValidateGraphics(). This function is called by
qemuDomainDefValidate(), validating the graphics parameters in domain
define time.
Tests were adapted to consider validation in this earlier stage.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_command.c | 10 +---------
src/qemu/qemu_domain.c | 7 +++++++
tests/qemuxml2argvdata/graphics-egl-headless.args | 2 +-
.../qemuxml2argvdata/graphics-spice-egl-headless.args | 2 +-
tests/qemuxml2argvdata/graphics-vnc-egl-headless.args | 2 +-
tests/qemuxml2argvtest.c | 9 ++++++---
tests/qemuxml2xmltest.c | 6 ++++--
7 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index aceb42a289..efc70d6de9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7729,7 +7729,6 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
static int
qemuBuildGraphicsEGLHeadlessCommandLine(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
virCommandPtr cmd,
- virQEMUCapsPtr qemuCaps,
virDomainGraphicsDefPtr graphics)
{
g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
@@ -7737,13 +7736,6 @@ qemuBuildGraphicsEGLHeadlessCommandLine(virQEMUDriverConfigPtr cfg
G_GNUC_UNUSED
virBufferAddLit(&opt, "egl-headless");
if (graphics->data.egl_headless.rendernode) {
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_EGL_HEADLESS_RENDERNODE)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("This QEMU doesn't support OpenGL rendernode
"
- "with egl-headless graphics type"));
- return -1;
- }
-
virBufferAddLit(&opt, ",rendernode=");
virQEMUBuildBufferEscapeComma(&opt,
graphics->data.egl_headless.rendernode);
@@ -7788,7 +7780,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
break;
case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
if (qemuBuildGraphicsEGLHeadlessCommandLine(cfg, cmd,
- qemuCaps, graphics) < 0)
+ graphics) < 0)
return -1;
break;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 9f29d2afbe..415f0916a2 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7717,6 +7717,13 @@ qemuDomainDeviceDefValidateGraphics(const virDomainGraphicsDef
*graphics,
break;
case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_EGL_HEADLESS_RENDERNODE)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("This QEMU doesn't support OpenGL rendernode
"
+ "with egl-headless graphics type"));
+ return -1;
+ }
+
break;
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
diff --git a/tests/qemuxml2argvdata/graphics-egl-headless.args
b/tests/qemuxml2argvdata/graphics-egl-headless.args
index 76d7583462..04b09803de 100644
--- a/tests/qemuxml2argvdata/graphics-egl-headless.args
+++ b/tests/qemuxml2argvdata/graphics-egl-headless.args
@@ -25,5 +25,5 @@ server,nowait \
-usb \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--display egl-headless \
+-display egl-headless,rendernode=/dev/dri/foo \
-vga cirrus
diff --git a/tests/qemuxml2argvdata/graphics-spice-egl-headless.args
b/tests/qemuxml2argvdata/graphics-spice-egl-headless.args
index 54b7184376..159b6e15fb 100644
--- a/tests/qemuxml2argvdata/graphics-spice-egl-headless.args
+++ b/tests/qemuxml2argvdata/graphics-spice-egl-headless.args
@@ -27,7 +27,7 @@ server,nowait \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-spice port=5903,addr=127.0.0.1,seamless-migration=on \
--display egl-headless \
+-display egl-headless,rendernode=/dev/dri/foo \
-vga qxl \
-global qxl-vga.ram_size=67108864 \
-global qxl-vga.vram_size=33554432 \
diff --git a/tests/qemuxml2argvdata/graphics-vnc-egl-headless.args
b/tests/qemuxml2argvdata/graphics-vnc-egl-headless.args
index 3c0901d1a5..5c01972ef8 100644
--- a/tests/qemuxml2argvdata/graphics-vnc-egl-headless.args
+++ b/tests/qemuxml2argvdata/graphics-vnc-egl-headless.args
@@ -27,5 +27,5 @@ server,nowait \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-vnc '[2001:1:2:3:4:5:1234:1234]:3' \
--display egl-headless \
+-display egl-headless,rendernode=/dev/dri/foo \
-vga cirrus
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 3a002bb393..0af6083750 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1163,7 +1163,8 @@ mymain(void)
DO_TEST("graphics-egl-headless",
QEMU_CAPS_EGL_HEADLESS,
- QEMU_CAPS_DEVICE_CIRRUS_VGA);
+ QEMU_CAPS_DEVICE_CIRRUS_VGA,
+ QEMU_CAPS_EGL_HEADLESS_RENDERNODE);
DO_TEST_CAPS_LATEST("graphics-egl-headless");
DO_TEST_CAPS_LATEST("graphics-egl-headless-rendernode");
@@ -1207,7 +1208,8 @@ mymain(void)
DO_TEST("graphics-vnc-egl-headless",
QEMU_CAPS_VNC,
QEMU_CAPS_EGL_HEADLESS,
- QEMU_CAPS_DEVICE_CIRRUS_VGA);
+ QEMU_CAPS_DEVICE_CIRRUS_VGA,
+ QEMU_CAPS_EGL_HEADLESS_RENDERNODE);
DO_TEST("graphics-sdl",
QEMU_CAPS_DEVICE_VGA);
@@ -1269,7 +1271,8 @@ mymain(void)
DO_TEST("graphics-spice-egl-headless",
QEMU_CAPS_SPICE,
QEMU_CAPS_EGL_HEADLESS,
- QEMU_CAPS_DEVICE_QXL);
+ QEMU_CAPS_DEVICE_QXL,
+ QEMU_CAPS_EGL_HEADLESS_RENDERNODE);
DO_TEST_CAPS_LATEST_PARSE_ERROR("graphics-spice-invalid-egl-headless");
DO_TEST_CAPS_LATEST("graphics-spice-gl-auto-rendernode");
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index d3ef08dcdf..b449c21f18 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -376,7 +376,8 @@ mymain(void)
DO_TEST("graphics-vnc-egl-headless",
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_EGL_HEADLESS,
- QEMU_CAPS_VNC);
+ QEMU_CAPS_VNC,
+ QEMU_CAPS_EGL_HEADLESS_RENDERNODE);
DO_TEST_CAPS_ARCH_LATEST("default-video-type-aarch64",
"aarch64");
DO_TEST_CAPS_ARCH_LATEST("default-video-type-ppc64", "ppc64");
@@ -420,7 +421,8 @@ mymain(void)
DO_TEST("graphics-spice-egl-headless",
QEMU_CAPS_DEVICE_QXL,
QEMU_CAPS_EGL_HEADLESS,
- QEMU_CAPS_SPICE);
+ QEMU_CAPS_SPICE,
+ QEMU_CAPS_EGL_HEADLESS_RENDERNODE);
DO_TEST("graphics-egl-headless-rendernode",
QEMU_CAPS_DEVICE_CIRRUS_VGA,
--
2.23.0