[PATCH] conf: disallow invalid values for video attributes

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

 



Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1190956

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/conf/domain_conf.c                                            | 8 ++++----
 ...v-seclabel-dynamic-none.xml => qemuxml2argv-video-invalid.xml} | 4 +++-
 tests/qemuxml2argvtest.c                                          | 1 +
 3 files changed, 8 insertions(+), 5 deletions(-)
 copy tests/qemuxml2argvdata/{qemuxml2argv-seclabel-dynamic-none.xml => qemuxml2argv-video-invalid.xml} (90%)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d5b15db..77319dc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10580,7 +10580,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
                            _("ram attribute only supported for type of qxl"));
             goto error;
         }
-        if (virStrToLong_ui(ram, NULL, 10, &def->ram) < 0) {
+        if (virStrToLong_uip(ram, NULL, 10, &def->ram) < 0) {
             virReportError(VIR_ERR_XML_ERROR,
                            _("cannot parse video ram '%s'"), ram);
             goto error;
@@ -10590,7 +10590,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     }

     if (vram) {
-        if (virStrToLong_ui(vram, NULL, 10, &def->vram) < 0) {
+        if (virStrToLong_uip(vram, NULL, 10, &def->vram) < 0) {
             virReportError(VIR_ERR_XML_ERROR,
                            _("cannot parse video vram '%s'"), vram);
             goto error;
@@ -10605,7 +10605,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
                            _("vgamem attribute only supported for type of qxl"));
             goto error;
         }
-        if (virStrToLong_ui(vgamem, NULL, 10, &def->vgamem) < 0) {
+        if (virStrToLong_uip(vgamem, NULL, 10, &def->vgamem) < 0) {
             virReportError(VIR_ERR_XML_ERROR,
                            _("cannot parse video vgamem '%s'"), vgamem);
             goto error;
@@ -10613,7 +10613,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     }

     if (heads) {
-        if (virStrToLong_ui(heads, NULL, 10, &def->heads) < 0) {
+        if (virStrToLong_uip(heads, NULL, 10, &def->heads) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("cannot parse video heads '%s'"), heads);
             goto error;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-none.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-invalid.xml
similarity index 90%
copy from tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-none.xml
copy to tests/qemuxml2argvdata/qemuxml2argv-video-invalid.xml
index cec59f8..e3848e1 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-none.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-invalid.xml
@@ -22,7 +22,9 @@
     <controller type='usb' index='0'/>
     <controller type='ide' index='0'/>
     <controller type='pci' index='0' model='pci-root'/>
+    <video>
+      <model type='qxl' ram='-1' vram='-1' vgamem='-1' heads='-1'/>
+    </video>
     <memballoon model='virtio'/>
   </devices>
-  <seclabel type='none' model='none'/>
 </domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 77ee630..f864c2a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1362,6 +1362,7 @@ mymain(void)
             QEMU_CAPS_DEVICE_QXL_VGA, QEMU_CAPS_DEVICE_QXL,
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_QXL_VGA_VGAMEM,
             QEMU_CAPS_QXL_VGAMEM);
+    DO_TEST_PARSE_ERROR("video-invalid", NONE);

     DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
             QEMU_CAPS_OBJECT_RNG_RANDOM);
-- 
2.3.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]