qemu: Validate video model

The aim is to eliminate virDomainCapsDeviceDefValidate(). And in
order to do so, the domain video model has to be validated in
qemuValidateDomainDeviceDefVideo().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Michal Privoznik 2020-11-13 20:43:39 +01:00
parent 5216304bfe
commit a33279daa8
4 changed files with 45 additions and 20 deletions

View File

@ -640,22 +640,8 @@ virDomainCapsFormat(const virDomainCaps *caps)
} while (0)
static int
virDomainCapsDeviceVideoDefValidate(const virDomainCaps *caps,
const virDomainVideoDef *dev)
{
if (ENUM_VALUE_MISSING(caps->video.modelType, dev->type)) {
ENUM_VALUE_ERROR("video model",
virDomainVideoTypeToString(dev->type));
return -1;
}
return 0;
}
int
virDomainCapsDeviceDefValidate(const virDomainCaps *caps,
virDomainCapsDeviceDefValidate(const virDomainCaps *caps G_GNUC_UNUSED,
const virDomainDeviceDef *dev,
const virDomainDef *def G_GNUC_UNUSED)
{
@ -663,9 +649,6 @@ virDomainCapsDeviceDefValidate(const virDomainCaps *caps,
switch ((virDomainDeviceType) dev->type) {
case VIR_DOMAIN_DEVICE_VIDEO:
ret = virDomainCapsDeviceVideoDefValidate(caps, dev->data.video);
break;
case VIR_DOMAIN_DEVICE_AUDIO:
/* TODO: add validation */
break;

View File

@ -2203,10 +2203,52 @@ static int
qemuValidateDomainDeviceDefVideo(const virDomainVideoDef *video,
virQEMUCapsPtr qemuCaps)
{
virQEMUCapsFlags cap = QEMU_CAPS_LAST;
/* there's no properties to validate for NONE video devices */
if (video->type == VIR_DOMAIN_VIDEO_TYPE_NONE)
return 0;
switch ((virDomainVideoType) video->type) {
case VIR_DOMAIN_VIDEO_TYPE_VGA:
cap = QEMU_CAPS_DEVICE_VGA;
break;
case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
cap = QEMU_CAPS_DEVICE_CIRRUS_VGA;
break;
case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
cap = QEMU_CAPS_DEVICE_VMWARE_SVGA;
break;
case VIR_DOMAIN_VIDEO_TYPE_QXL:
cap = QEMU_CAPS_DEVICE_QXL;
break;
case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
cap = QEMU_CAPS_DEVICE_VIRTIO_GPU;
break;
case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
cap = QEMU_CAPS_DEVICE_BOCHS_DISPLAY;
break;
case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
cap = QEMU_CAPS_DEVICE_RAMFB;
break;
case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
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_NONE:
case VIR_DOMAIN_VIDEO_TYPE_LAST:
/* nada */
break;
}
if (!virQEMUCapsGet(qemuCaps, cap)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("domain configuration does not support video model '%s'"),
virDomainVideoTypeToString(video->type));
return -1;
}
if (!video->primary &&
video->type != VIR_DOMAIN_VIDEO_TYPE_QXL &&
video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO) {

View File

@ -1 +1 @@
unsupported configuration: domain configuration does not support 'video model' value 'default'
unsupported configuration: domain configuration does not support video model 'default'

View File

@ -1 +1 @@
unsupported configuration: domain configuration does not support 'video model' value 'qxl'
unsupported configuration: domain configuration does not support video model 'qxl'