These checks are not related to XML parsing and can be moved
to post parse time. Errors were changed from VIR_ERR_XML_ERROR to
VIR_ERR_CONFIG_UNSUPPORTED.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/conf/domain_conf.c | 43 ++++++++++++++++++++++++------------------
1 file changed, 25 insertions(+), 18 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8352c60473..a8d82f4733 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5303,10 +5303,31 @@ virDomainDiskDefPostParse(virDomainDiskDefPtr disk,
}
-static void
+static int
virDomainVideoDefPostParse(virDomainVideoDefPtr video,
const virDomainDef *def)
{
+
+ if (video->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
+ if (video->ram != 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("ram attribute only supported for video type
qxl"));
+ return -1;
+ }
+
+ if (video->vram64 != 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("vram64 attribute only supported for video type
qxl"));
+ return -1;
+ }
+
+ if (video->vgamem != 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("vgamem attribute only supported for video type
qxl"));
+ return -1;
+ }
+ }
+
/* Fill out (V)RAM if the driver-specific callback did not do so */
if (video->ram == 0 && video->type == VIR_DOMAIN_VIDEO_TYPE_QXL)
video->ram = virDomainVideoDefaultRAM(def, video->type);
@@ -5315,6 +5336,8 @@ virDomainVideoDefPostParse(virDomainVideoDefPtr video,
video->ram = VIR_ROUND_UP_POWER_OF_TWO(video->ram);
video->vram = VIR_ROUND_UP_POWER_OF_TWO(video->vram);
+
+ return 0;
}
@@ -5414,8 +5437,7 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefPtr dev,
break;
case VIR_DOMAIN_DEVICE_VIDEO:
- virDomainVideoDefPostParse(dev->data.video, def);
- ret = 0;
+ ret = virDomainVideoDefPostParse(dev->data.video, def);
break;
case VIR_DOMAIN_DEVICE_HOSTDEV:
@@ -16263,11 +16285,6 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt,
}
if (ram) {
- if (def->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("ram attribute only supported for type of qxl"));
- return NULL;
- }
if (virStrToLong_uip(ram, NULL, 10, &def->ram) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("cannot parse video ram '%s'"), ram);
@@ -16284,11 +16301,6 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt,
}
if (vram64) {
- if (def->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("vram64 attribute only supported for type of
qxl"));
- return NULL;
- }
if (virStrToLong_uip(vram64, NULL, 10, &def->vram64) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("cannot parse video vram64 '%s'"),
vram64);
@@ -16297,11 +16309,6 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt,
}
if (vgamem) {
- if (def->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("vgamem attribute only supported for type of
qxl"));
- return NULL;
- }
if (virStrToLong_uip(vgamem, NULL, 10, &def->vgamem) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("cannot parse video vgamem '%s'"),
vgamem);
--
2.26.2