mirror of https://gitee.com/openkylin/libvirt.git
domain_conf.c: move virDomainVideoDefValidate() to domain_validate.c
We'll add more video validations into the function in the next patch. Let's move it beforehand to domain_validate.c. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
88bbae85f9
commit
212c58b20e
|
@ -6612,63 +6612,6 @@ virDomainHostdevDefValidate(const virDomainHostdevDef *hostdev)
|
|||
}
|
||||
|
||||
|
||||
static int
|
||||
virDomainVideoDefValidate(const virDomainVideoDef *video,
|
||||
const virDomainDef *def)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("missing video model and cannot determine default"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* it doesn't make sense to pair video device type 'none' with any other
|
||||
* types, there can be only a single video device in such case
|
||||
*/
|
||||
for (i = 0; i < def->nvideos; i++) {
|
||||
if (def->videos[i]->type == VIR_DOMAIN_VIDEO_TYPE_NONE &&
|
||||
def->nvideos > 1) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("a 'none' video type must be the only video device "
|
||||
"defined for the domain"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
switch (video->backend) {
|
||||
case VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER:
|
||||
if (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("'vhostuser' driver is only supported with 'virtio' device"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT:
|
||||
case VIR_DOMAIN_VIDEO_BACKEND_TYPE_QEMU:
|
||||
if (video->accel && video->accel->rendernode) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("unsupported rendernode accel attribute without 'vhostuser'"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case VIR_DOMAIN_VIDEO_BACKEND_TYPE_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainInputType, video->backend);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (video->res && (video->res->x == 0 || video->res->y == 0)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("video resolution values must be greater than 0"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virDomainMemoryDefValidate(const virDomainMemoryDef *mem,
|
||||
const virDomainDef *def)
|
||||
|
|
|
@ -73,3 +73,60 @@ virDomainDefVideoValidate(const virDomainDef *def)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virDomainVideoDefValidate(const virDomainVideoDef *video,
|
||||
const virDomainDef *def)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("missing video model and cannot determine default"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* it doesn't make sense to pair video device type 'none' with any other
|
||||
* types, there can be only a single video device in such case
|
||||
*/
|
||||
for (i = 0; i < def->nvideos; i++) {
|
||||
if (def->videos[i]->type == VIR_DOMAIN_VIDEO_TYPE_NONE &&
|
||||
def->nvideos > 1) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("a 'none' video type must be the only video device "
|
||||
"defined for the domain"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
switch (video->backend) {
|
||||
case VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER:
|
||||
if (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("'vhostuser' driver is only supported with 'virtio' device"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT:
|
||||
case VIR_DOMAIN_VIDEO_BACKEND_TYPE_QEMU:
|
||||
if (video->accel && video->accel->rendernode) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("unsupported rendernode accel attribute without 'vhostuser'"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case VIR_DOMAIN_VIDEO_BACKEND_TYPE_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainInputType, video->backend);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (video->res && (video->res->x == 0 || video->res->y == 0)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("video resolution values must be greater than 0"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -26,3 +26,5 @@
|
|||
|
||||
int virDomainDefBootValidate(const virDomainDef *def);
|
||||
int virDomainDefVideoValidate(const virDomainDef *def);
|
||||
int virDomainVideoDefValidate(const virDomainVideoDef *video,
|
||||
const virDomainDef *def);
|
||||
|
|
Loading…
Reference in New Issue