mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-03 07:33:50 +00:00
conf: Make specifying <memory> optional
Now that the size of guest's memory can be inferred from the NUMA configuration (if present) make it optional to specify <memory> explicitly. To make sure that memory is specified add a check that some form of memory size was specified. One side effect of this change is that it is no longer possible to specify 0KiB as memory size for the VM, but I don't think it would be any useful to do so. (I can imagine embedded systems without memory, just registers, but that's far from what libvirt is usually doing). Forbidding 0 memory for guests also fixes a few corner cases where 0 was not interpreted correctly and caused failures. (Arguments for numad when using automatic placement, size of the balloon). This fixes problems described in https://bugzilla.redhat.com/show_bug.cgi?id=1161461 Test case changes are added to verify that the schema change and code behave correctly.
This commit is contained in:
parent
caf88a3c88
commit
4bca6192f2
@ -582,14 +582,16 @@
|
||||
-->
|
||||
<define name="resources">
|
||||
<interleave>
|
||||
<element name="memory">
|
||||
<ref name='scaledInteger'/>
|
||||
<optional>
|
||||
<attribute name="dumpCore">
|
||||
<ref name="virOnOff"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
</element>
|
||||
<optional>
|
||||
<element name="memory">
|
||||
<ref name='scaledInteger'/>
|
||||
<optional>
|
||||
<attribute name="dumpCore">
|
||||
<ref name="virOnOff"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="currentMemory">
|
||||
<ref name='scaledInteger'/>
|
||||
|
@ -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 <memory> or in the "
|
||||
"<numa> 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,
|
||||
|
@ -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
|
@ -0,0 +1,24 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<currentMemory unit='KiB'>219100</currentMemory>
|
||||
<vcpu placement='static'>16</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='pc'>hvm</type>
|
||||
<boot dev='network'/>
|
||||
</os>
|
||||
<cpu>
|
||||
<topology sockets='2' cores='4' threads='2'/>
|
||||
<numa>
|
||||
<cell id='1' cpus='8-15' memory='109550' unit='KiB'/>
|
||||
<cell id='0' cpus='0-7' memory='109550' unit='KiB'/>
|
||||
</numa>
|
||||
</cpu>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
</devices>
|
||||
</domain>
|
25
tests/qemuxml2argvdata/qemuxml2argv-minimal-no-memory.xml
Normal file
25
tests/qemuxml2argvdata/qemuxml2argv-minimal-no-memory.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='usb' index='0'/>
|
||||
<controller type='ide' index='0'/>
|
||||
<controller type='pci' index='0' model='pci-root'/>
|
||||
<memballoon model='virtio'/>
|
||||
</devices>
|
||||
</domain>
|
@ -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);
|
||||
|
@ -0,0 +1,28 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219100</memory>
|
||||
<currentMemory unit='KiB'>219100</currentMemory>
|
||||
<vcpu placement='static'>16</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='pc'>hvm</type>
|
||||
<boot dev='network'/>
|
||||
</os>
|
||||
<cpu>
|
||||
<topology sockets='2' cores='4' threads='2'/>
|
||||
<numa>
|
||||
<cell id='0' cpus='0-7' memory='109550' unit='KiB'/>
|
||||
<cell id='1' cpus='8-15' memory='109550' unit='KiB'/>
|
||||
</numa>
|
||||
</cpu>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<controller type='usb' index='0'/>
|
||||
<controller type='pci' index='0' model='pci-root'/>
|
||||
<memballoon model='virtio'/>
|
||||
</devices>
|
||||
</domain>
|
@ -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");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user