We'll add more video validations into the function in the next
patch. Let's move it beforehand to domain_validate.c.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/conf/domain_conf.c | 57 --------------------------------------
src/conf/domain_validate.c | 57 ++++++++++++++++++++++++++++++++++++++
src/conf/domain_validate.h | 2 ++
3 files changed, 59 insertions(+), 57 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a8bd54a368..d80bc8495e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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)
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index eb2ef6c7fb..c81fd296b9 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -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;
+}
diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h
index df4f35c1dd..ed170391f8 100644
--- a/src/conf/domain_validate.h
+++ b/src/conf/domain_validate.h
@@ -26,3 +26,5 @@
int virDomainDefBootValidate(const virDomainDef *def);
int virDomainDefVideoValidate(const virDomainDef *def);
+int virDomainVideoDefValidate(const virDomainVideoDef *video,
+ const virDomainDef *def);
--
2.26.2