[PATCH v3 04/14] domain_conf.c: move QXL attributes check to virDomainVideoDefValidate()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
 src/conf/domain_conf.c     | 15 ---------------
 src/conf/domain_validate.c | 20 ++++++++++++++++++++
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d80bc8495e..db0ca975fe 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16132,11 +16132,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);
@@ -16153,11 +16148,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);
@@ -16166,11 +16156,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);
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index c81fd296b9..234eb72f11 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -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;
 }
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux