Re: [PATCH V2] conf: report error in virCPUDefParseXML

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

 



On Thu, Sep 25, 2014 at 07:28:33PM +0800, Jincheng Miao wrote:
When detected invalid 'memAccess', virCPUDefParseXML should report error.

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

Signed-off-by: Jincheng Miao <jmiao@xxxxxxxxxx>
---
src/conf/cpu_conf.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 116aa58..9b7fbb0 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -507,17 +507,19 @@ virCPUDefParseXML(xmlNodePtr node,

            memAccessStr = virXMLPropString(nodes[i], "memAccess");
            if (memAccessStr) {
-                def->cells[cur_cell].memAccess =
-                    virMemAccessTypeFromString(memAccessStr);
+                int rc = virMemAccessTypeFromString(memAccessStr);

-                if (def->cells[cur_cell].memAccess <= 0) {
+                if (rc <= 0) {
                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                   _("Invalid 'memAccess' attribute "
                                     "value '%s'"),
                                   memAccessStr);
                    VIR_FREE(memAccessStr);
-                    goto cleanup;
+                    goto error;
                }
+
+                def->cells[cur_cell].memAccess = rc;
+
                VIR_FREE(memAccessStr);
            }
        }
--
1.9.3


ACK and I'm adding a test case that shows the problem is fixed:

diff --git c/tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.xml w/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess-invalid.xml
similarity index 95%
copy from tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.xml
copy to tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess-invalid.xml
index e7db69c..83b8ac2 100644
--- c/tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.xml
+++ w/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess-invalid.xml
@@ -21,7 +21,7 @@
  <cpu>
    <numa>
      <cell id='0' cpus='0' memory='1048576'/>
-      <cell id='1' cpus='1' memory='1048576' memAccess='shared'/>
+      <cell id='1' cpus='1' memory='1048576' memAccess='invalid'/>
      <cell id='2' cpus='2' memory='1048576' memAccess='private'/>
      <cell id='3' cpus='3' memory='1048576'/>
    </numa>
diff --git c/tests/qemuxml2argvtest.c w/tests/qemuxml2argvtest.c
index 4c85bfe..b380fd8 100644
--- c/tests/qemuxml2argvtest.c
+++ w/tests/qemuxml2argvtest.c
@@ -691,6 +691,7 @@ mymain(void)
            QEMU_CAPS_OBJECT_MEMORY_FILE);
    DO_TEST("hugepages-shared", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
+    DO_TEST_PARSE_ERROR("hugepages-memaccess-invalid", NONE);
    DO_TEST_FAILURE("hugepages-pages4", QEMU_CAPS_MEM_PATH,
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
    DO_TEST("hugepages-pages5", QEMU_CAPS_MEM_PATH);
--

Martin

Attachment: signature.asc
Description: Digital signature

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