mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-05 04:41:20 +00:00
198c1eb6b4
qemuDomainAlignMemorySizes() has an operation order problem. We are calculating 'initialmem' without aligning the memory modules first. Since we're aligning the dimms afterwards this can create inconsistencies in the end result. x86 has alignment of 1-2MiB and it's not severely impacted by it, but pSeries works with 256MiB alignment and the difference is noticeable. This is the case of the existing 'memory-hotplug-ppc64-nonuma' test. The test consists of a 2GiB (aligned value) guest with 2 ~520MiB dimms, both unaligned. 'initialmem' is calculated by taking total_mem and subtracting the dimms size (via virDomainDefGetMemoryInitial()), which wil give us 2GiB - 520MiB - 520MiB, ending up with a little more than an 1GiB of 'initialmem'. Note that this value is now unaligned, and will be aligned up via VIR_ROUND_UP(), and we'll end up with 'initialmem' of 1GiB + 256MiB. Given that the dimms are aligned later on, the end result for QEMU is that the guest will have a 'mem' size of 1310720k, plus the two 512 MiB dimms, exceeding in 256MiB the desired 2GiB memory and currentMemory specified in the XML. Existing guests can't be fixed without breaking ABI, but we have code already in place to align pSeries NVDIMM modules for new guests. Let's extend it to align all pSeries mem modules. A new test, 'memory-hotplug-ppc64-nonuma-abi-update', a copy of the existing 'memory-hotplug-ppc64-nonuma', was added to demonstrate the result for new pSeries guests. For the same unaligned XML mentioned above, after applying this patch: - starting QEMU mem size without PARSE_ABI_UPDATE: -m size=1310720k,slots=16,maxmem=4194304k \ (no changes) - starting QEMU mem size with PARSE_ABI_UPDATE: -m size=1048576k,slots=16,maxmem=4194304k \ (size fixed) Reviewed-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
30 lines
973 B
Plaintext
30 lines
973 B
Plaintext
LC_ALL=C \
|
|
PATH=/bin \
|
|
HOME=/tmp/lib/domain--1-QEMUGuest1 \
|
|
USER=test \
|
|
LOGNAME=test \
|
|
XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
|
|
XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
|
|
XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
|
|
QEMU_AUDIO_DRV=none \
|
|
/usr/bin/qemu-system-ppc64 \
|
|
-name QEMUGuest1 \
|
|
-S \
|
|
-machine pseries,accel=kvm,usb=off,dump-guest-core=off \
|
|
-m size=1048576k,slots=16,maxmem=4194304k \
|
|
-realtime mlock=off \
|
|
-smp 1,sockets=1,cores=1,threads=1 \
|
|
-object memory-backend-ram,id=memdimm0,size=536870912 \
|
|
-device pc-dimm,memdev=memdimm0,id=dimm0,slot=0 \
|
|
-object memory-backend-ram,id=memdimm1,size=536870912 \
|
|
-device pc-dimm,memdev=memdimm1,id=dimm1,slot=1 \
|
|
-uuid 49545eb3-75e1-2d0a-acdd-f0294406c99e \
|
|
-display none \
|
|
-no-user-config \
|
|
-nodefaults \
|
|
-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
|
|
server,nowait \
|
|
-mon chardev=charmonitor,id=monitor,mode=control \
|
|
-rtc base=utc \
|
|
-no-shutdown
|