diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index b1d883fcbbbe915063db4cf11d38efde3d73c400..e98e9052aa919430bcc710382a904cdefbea724c 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -582,14 +582,16 @@ --> - - - - - - - - + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4ecb58c90fb1cc639cdb9042c8a2d3560bcace11..ca02bb9493b0d2bf80f6dd22a5dfebe1316c0a0c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3208,6 +3208,13 @@ virDomainDefPostParseInternal(virDomainDefPtr def, return -1; } + if (virDomainDefGetMemoryInitial(def) == 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Memory size must be specified via or in the " + " configuration")); + return -1; + } + if (def->mem.cur_balloon > virDomainDefGetMemoryActual(def)) { /* Older libvirt could get into this situation due to * rounding; if the discrepancy is less than 4MiB, we silently @@ -13245,7 +13252,7 @@ virDomainDefParseXML(xmlDocPtr xml, /* Extract domain memory */ if (virDomainParseMemory("./memory[1]", NULL, ctxt, - &def->mem.max_balloon, true, true) < 0) + &def->mem.max_balloon, false, true) < 0) goto error; if (virDomainParseMemory("./currentMemory[1]", NULL, ctxt, diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-no-memory-element.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-no-memory-element.args new file mode 100644 index 0000000000000000000000000000000000000000..ca34f734fe9df48a215c514476323ae0463ea14a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-no-memory-element.args @@ -0,0 +1,7 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M pc \ +-m 214 -smp 16,sockets=2,cores=4,threads=2 \ +-numa node,nodeid=0,cpus=0-7,mem=107 \ +-numa node,nodeid=1,cpus=8-15,mem=107 -nographic -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -usb -net none -serial none \ +-parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-no-memory-element.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-no-memory-element.xml new file mode 100644 index 0000000000000000000000000000000000000000..fbdc5e60cf83e51d5b2f2954ba6e11eff17beb85 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-no-memory-element.xml @@ -0,0 +1,24 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 16 + + hvm + + + + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-minimal-no-memory.xml b/tests/qemuxml2argvdata/qemuxml2argv-minimal-no-memory.xml new file mode 100644 index 0000000000000000000000000000000000000000..68246512abe848852c5b725858d27165295e8647 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-minimal-no-memory.xml @@ -0,0 +1,25 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5e7dd63f27874c006c2b968dc54a93920ef59c4b..fcf52187305432acfdb1ca6cb2ab3c3d5e71a646 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -594,6 +594,7 @@ mymain(void) unsetenv("SDL_AUDIODRIVER"); DO_TEST("minimal", QEMU_CAPS_NAME); + DO_TEST_PARSE_ERROR("minimal-no-memory", NONE); DO_TEST("minimal-msg-timestamp", QEMU_CAPS_NAME, QEMU_CAPS_MSG_TIMESTAMP); DO_TEST("minimal-s390", QEMU_CAPS_NAME); DO_TEST("machine-aliases1", NONE); @@ -1235,6 +1236,7 @@ mymain(void) DO_TEST("cpu-strict1", QEMU_CAPS_KVM); DO_TEST("cpu-numa1", NONE); DO_TEST("cpu-numa2", QEMU_CAPS_SMP_TOPOLOGY); + DO_TEST("cpu-numa-no-memory-element", QEMU_CAPS_SMP_TOPOLOGY); DO_TEST_PARSE_ERROR("cpu-numa3", NONE); DO_TEST_FAILURE("cpu-numa-disjoint", NONE); DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa-no-memory-element.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa-no-memory-element.xml new file mode 100644 index 0000000000000000000000000000000000000000..58f40b99023fd15ffd588e84ad5770b011d8196d --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa-no-memory-element.xml @@ -0,0 +1,28 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 16 + + hvm + + + + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 8e12e84fcc28c4bab1a370c92d2b8e2874467bd5..6ffe36b700e50f41f41b40aa5932f6367b6d6a25 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -409,6 +409,7 @@ mymain(void) DO_TEST_DIFFERENT("cpu-numa1"); DO_TEST_DIFFERENT("cpu-numa2"); + DO_TEST_DIFFERENT("cpu-numa-no-memory-element"); DO_TEST("cpu-numa-disjoint"); DO_TEST("cpu-numa-memshared");