qemu: command: move qemuBuildGraphicsSDLCommandLine validation to qemu_domain.c

There are validations for SDL, VNC, SPICE and EGL_HEADLESS
around several BuildGraphics*CommandLine in qemu_command.c. This
patch starts to move all of them to qemu_domain.c, inside the
existent qemuDomainDeviceDefValidateGraphics() function. This
function is called by qemuDomainDefValidate(), validating the
graphics parameters in domain define time.

In this patch we'll move the SDL validation code from
qemuBuildGraphicsSDLCommandLine(). Tests were adapted to consider
SDL validation in this earlier stage.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Daniel Henrique Barboza 2019-12-09 20:15:25 -03:00 committed by Cole Robinson
parent 83d7dadc48
commit 3559626790
3 changed files with 32 additions and 14 deletions

View File

@ -7428,19 +7428,10 @@ qemuBuildGraphicsSDLCommandLine(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
virCommandAddArg(cmd, "-display");
virBufferAddLit(&opt, "sdl");
if (graphics->data.sdl.gl != VIR_TRISTATE_BOOL_ABSENT) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SDL_GL)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("OpenGL for SDL is not supported with this QEMU "
"binary"));
return -1;
}
if (graphics->data.sdl.gl != VIR_TRISTATE_BOOL_ABSENT)
virBufferAsprintf(&opt, ",gl=%s",
virTristateSwitchTypeToString(graphics->data.sdl.gl));
}
virCommandAddArgBuffer(cmd, &opt);
return 0;
@ -7896,9 +7887,6 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
break;
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported graphics type '%s'"),
virDomainGraphicsTypeToString(graphics->type));
return -1;
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
default:

View File

@ -7681,6 +7681,35 @@ qemuDomainDeviceDefValidateGraphics(const virDomainGraphicsDef *graphics,
}
}
switch (graphics->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
if (graphics->data.sdl.gl != VIR_TRISTATE_BOOL_ABSENT) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SDL_GL)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("OpenGL for SDL is not supported with this QEMU "
"binary"));
return -1;
}
}
break;
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
break;
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
break;
case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
break;
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported graphics type '%s'"),
virDomainGraphicsTypeToString(graphics->type));
return -1;
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
default:
return -1;
}
return 0;
}

View File

@ -1174,7 +1174,8 @@ mymain(void)
QEMU_CAPS_VIRTIO_GPU_VIRGL);
DO_TEST("video-virtio-gpu-sdl-gl",
QEMU_CAPS_DEVICE_VIRTIO_GPU,
QEMU_CAPS_VIRTIO_GPU_VIRGL);
QEMU_CAPS_VIRTIO_GPU_VIRGL,
QEMU_CAPS_SDL_GL);
DO_TEST("virtio-input",
QEMU_CAPS_VIRTIO_KEYBOARD,