]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
domain_conf.c: move QXL attributes check to virDomainVideoDefValidate()
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Wed, 2 Dec 2020 20:36:28 +0000 (17:36 -0300)
committerDaniel Henrique Barboza <danielhb413@gmail.com>
Wed, 9 Dec 2020 12:51:51 +0000 (09:51 -0300)
These checks are not related to XML parsing and can be moved to the
validate callback. Errors were changed from VIR_ERR_XML_ERROR to
VIR_ERR_CONFIG_UNSUPPORTED.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/conf/domain_conf.c
src/conf/domain_validate.c

index 90b4b391ec705961d6e8394e33c5146f48b3d7bb..85f3df01adaeaced7d773adda54ee6643d3a406c 100644 (file)
@@ -16137,11 +16137,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);
@@ -16158,11 +16153,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);
@@ -16171,11 +16161,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);
index c81fd296b9c19b98a698b1267225c133361dcbaa..234eb72f1193f84beb5844876357b86505b16cd2 100644 (file)
@@ -128,5 +128,25 @@ virDomainVideoDefValidate(const virDomainVideoDef *video,
         return -1;
     }
 
+    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;
+        }
+    }
+
     return 0;
 }