https://bugzilla.redhat.com/show_bug.cgi?id=1260846
Introduced by 8fedbbdb, if we parse the disordered numa
cell, will get segfault. This is because we allow parse
the numa cell not in order and we alloc them before the
parse loop, the cpumask maybe NULL when parse each numa
cell.
Signed-off-by: Luyao Huang
---
src/conf/numa_conf.c | 10 +---
.../qemuxml2argv-cpu-numa-disordered.xml | 26 +++
.../qemuxml2xmlout-cpu-numa-disordered.xml | 29 ++
tests/qemuxml2xmltest.c| 1 +
4 files changed, 63 insertions(+), 3 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-disordered.xml
create mode 100644
tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa-disordered.xml
diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
index 5c123b9..b5963ac 100644
--- a/src/conf/numa_conf.c
+++ b/src/conf/numa_conf.c
@@ -759,11 +759,15 @@ virDomainNumaDefCPUParseXML(virDomainNumaPtr def,
}
VIR_FREE(tmp);
-for (j = 0; j < i; j++) {
+for (j = 0; j < n; j++) {
+if (j == cur_cell || !def->mem_nodes[j].cpumask)
+continue;
+
if (virBitmapOverlaps(def->mem_nodes[j].cpumask,
- def->mem_nodes[i].cpumask)) {
+ def->mem_nodes[cur_cell].cpumask)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("NUMA cells %zu and %zu have overlapping vCPU
ids"), i, j);
+ _("NUMA cells %u and %zu have overlapping vCPU
ids"),
+ cur_cell, j);
goto cleanup;
}
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-disordered.xml
b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-disordered.xml
new file mode 100644
index 000..ad31607
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-disordered.xml
@@ -0,0 +1,26 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 328650
+ 328650
+ 16
+
+hvm
+
+
+
+
+
+
+
+
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa-disordered.xml
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa-disordered.xml
new file mode 100644
index 000..0a76f12
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa-disordered.xml
@@ -0,0 +1,29 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 328650
+ 328650
+ 16
+
+hvm
+
+
+
+
+
+
+
+
+
+
+
+ destroy
+ restart
+ destroy
+
+/usr/bin/qemu
+
+
+
+
+
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index d41954e..5a20ebc 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -608,6 +608,7 @@ mymain(void)
DO_TEST_DIFFERENT("cpu-numa1");
DO_TEST_DIFFERENT("cpu-numa2");
DO_TEST_DIFFERENT("cpu-numa-no-memory-element");
+DO_TEST_DIFFERENT("cpu-numa-disordered");
DO_TEST("cpu-numa-disjoint");
DO_TEST("cpu-numa-memshared");
--
1.8.3.1
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list