mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-03 15:43:51 +00:00
qemuBuildMemoryBackendStr: Honour passed @pagesize
So far the argument has not much meaning and was practically ignored. This is not good since when doing memory hotplug, the size of desired hugepage backing is passed in that argument. Taking closer look at the tests I'm fixing reveals the bug. For instance, while the following is in the test: <memory model='dimm'> <source> <nodemask>1-3</nodemask> <pagesize unit='KiB'>4096</pagesize> </source> <target> <size unit='KiB'>524287</size> <node>0</node> </target> <address type='dimm' slot='0' base='0x100000000'/> </memory> the generated commandline corresponding to this XML was: -object memory-backend-ram,id=memdimm0,size=536870912,\ host-nodes=1-3,policy=bind Have you noticed? Yes, memory-backend-ram! Nothing can be further away from the right answer. The hugepage backing is requested in the XML and we happily ignore it. This is just not right. It's memory-backend-file which should have been used: -object memory-backend-file,id=memdimm0,prealloc=yes,\ mem-path=/dev/hugepages4M/libvirt/qemu,size=536870912,\ host-nodes=1-3,policy=bind The problem is, that @pagesize passed to qemuBuildMemoryBackendStr (where this part of commandline is built) was ignored. The hugepage to back memory was searched only and only by NUMA nodes pinning. This works only for regular guest NUMA nodes. Then, I'm changing the hugepages size in the test XMLs too. This is simply because in the test suite we create dummy mount points just for 2M and 1G hugepages. And in the test 4M was requested. I'm sticking to 2M, but 1G should just work too. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
f8e9deb1d4
commit
70d75ffc79
@ -4727,7 +4727,7 @@ qemuBuildMemoryBackendStr(unsigned long long size,
|
|||||||
virDomainNumatuneGetMode(def->numa, -1, &mode) < 0)
|
virDomainNumatuneGetMode(def->numa, -1, &mode) < 0)
|
||||||
mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
|
mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
|
||||||
|
|
||||||
if (pagesize == 0 || pagesize != system_page_size) {
|
if (pagesize == 0) {
|
||||||
/* Find the huge page size we want to use */
|
/* Find the huge page size we want to use */
|
||||||
for (i = 0; i < def->mem.nhugepages; i++) {
|
for (i = 0; i < def->mem.nhugepages; i++) {
|
||||||
bool thisHugepage = false;
|
bool thisHugepage = false;
|
||||||
@ -4762,34 +4762,35 @@ qemuBuildMemoryBackendStr(unsigned long long size,
|
|||||||
|
|
||||||
if (hugepage)
|
if (hugepage)
|
||||||
pagesize = hugepage->size;
|
pagesize = hugepage->size;
|
||||||
|
}
|
||||||
|
|
||||||
if (hugepage && hugepage->size == system_page_size) {
|
if (pagesize == system_page_size) {
|
||||||
/* However, if user specified to use "huge" page
|
/* However, if user specified to use "huge" page
|
||||||
* of regular system page size, it's as if they
|
* of regular system page size, it's as if they
|
||||||
* hasn't specified any huge pages at all. */
|
* hasn't specified any huge pages at all. */
|
||||||
|
pagesize = 0;
|
||||||
hugepage = NULL;
|
hugepage = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (hugepage) {
|
if (pagesize || hugepage) {
|
||||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("this qemu doesn't support hugepage memory backing"));
|
_("this qemu doesn't support hugepage memory backing"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hugepage->size) {
|
if (pagesize) {
|
||||||
/* Now lets see, if the huge page we want to use is even mounted
|
/* Now lets see, if the huge page we want to use is even mounted
|
||||||
* and ready to use */
|
* and ready to use */
|
||||||
for (i = 0; i < cfg->nhugetlbfs; i++) {
|
for (i = 0; i < cfg->nhugetlbfs; i++) {
|
||||||
if (cfg->hugetlbfs[i].size == hugepage->size)
|
if (cfg->hugetlbfs[i].size == pagesize)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == cfg->nhugetlbfs) {
|
if (i == cfg->nhugetlbfs) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unable to find any usable hugetlbfs mount for %llu KiB"),
|
_("Unable to find any usable hugetlbfs mount for %llu KiB"),
|
||||||
hugepage->size);
|
pagesize);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4856,7 +4857,7 @@ qemuBuildMemoryBackendStr(unsigned long long size,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hugepage) {
|
if (!hugepage && !pagesize) {
|
||||||
bool nodeSpecified = virDomainNumatuneNodeSpecified(def->numa, guestNode);
|
bool nodeSpecified = virDomainNumatuneNodeSpecified(def->numa, guestNode);
|
||||||
|
|
||||||
if ((userNodeset || nodeSpecified || force) &&
|
if ((userNodeset || nodeSpecified || force) &&
|
||||||
|
@ -3,11 +3,14 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
|
|||||||
-S \
|
-S \
|
||||||
-M pc-i440fx-2.3 \
|
-M pc-i440fx-2.3 \
|
||||||
-cpu Haswell \
|
-cpu Haswell \
|
||||||
-m 1024 \
|
-m size=1048576k,slots=16,maxmem=1099511627776k \
|
||||||
-smp 2 \
|
-smp 2 \
|
||||||
-object memory-backend-file,id=ram-node0,prealloc=yes,\
|
-object memory-backend-file,id=ram-node0,prealloc=yes,\
|
||||||
mem-path=/dev/hugepages2M/libvirt/qemu,size=1073741824 \
|
mem-path=/dev/hugepages2M/libvirt/qemu,size=1073741824 \
|
||||||
-numa node,nodeid=0,cpus=0-1,memdev=ram-node0 \
|
-numa node,nodeid=0,cpus=0-1,memdev=ram-node0 \
|
||||||
|
-object memory-backend-file,id=memdimm0,prealloc=yes,\
|
||||||
|
mem-path=/dev/hugepages1G/libvirt/qemu,size=1073741824,host-nodes=1-3,policy=bind \
|
||||||
|
-device pc-dimm,node=0,memdev=memdimm0,id=dimm0 \
|
||||||
-nodefaults \
|
-nodefaults \
|
||||||
-monitor unix:/tmp/test-monitor,server,nowait \
|
-monitor unix:/tmp/test-monitor,server,nowait \
|
||||||
-rtc base=utc,driftfix=slew \
|
-rtc base=utc,driftfix=slew \
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<domain type='qemu'>
|
<domain type='qemu'>
|
||||||
<name>fedora</name>
|
<name>fedora</name>
|
||||||
<uuid>63840878-0deb-4095-97e6-fc444d9bc9fa</uuid>
|
<uuid>63840878-0deb-4095-97e6-fc444d9bc9fa</uuid>
|
||||||
|
<maxMemory slots='16' unit='KiB'>1099511627776</maxMemory>
|
||||||
<memory unit='KiB'>1572863</memory>
|
<memory unit='KiB'>1572863</memory>
|
||||||
<currentMemory unit='KiB'>1048576</currentMemory>
|
<currentMemory unit='KiB'>1048576</currentMemory>
|
||||||
<memoryBacking>
|
<memoryBacking>
|
||||||
@ -103,5 +104,15 @@
|
|||||||
<memballoon model='virtio'>
|
<memballoon model='virtio'>
|
||||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
|
||||||
</memballoon>
|
</memballoon>
|
||||||
|
<memory model='dimm'>
|
||||||
|
<source>
|
||||||
|
<nodemask>1-3</nodemask>
|
||||||
|
<pagesize unit='KiB'>1048576</pagesize>
|
||||||
|
</source>
|
||||||
|
<target>
|
||||||
|
<size unit='KiB'>1048576</size>
|
||||||
|
<node>0</node>
|
||||||
|
</target>
|
||||||
|
</memory>
|
||||||
</devices>
|
</devices>
|
||||||
</domain>
|
</domain>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||||
/usr/bin/qemu -S -M pc -m size=219136k,slots=16,maxmem=1099511627776k -smp 2 \
|
/usr/bin/qemu -S -M pc -m size=219136k,slots=16,maxmem=1099511627776k -smp 2 \
|
||||||
-numa node,nodeid=0,cpus=0-1,mem=214 \
|
-numa node,nodeid=0,cpus=0-1,mem=214 \
|
||||||
-object memory-backend-ram,id=memdimm0,size=536870912,host-nodes=1-3,\
|
-object memory-backend-file,id=memdimm0,prealloc=yes,\
|
||||||
policy=bind \
|
mem-path=/dev/hugepages2M/libvirt/qemu,size=536870912,host-nodes=1-3,policy=bind \
|
||||||
-device pc-dimm,node=0,memdev=memdimm0,id=dimm0,slot=0,addr=4294967296 \
|
-device pc-dimm,node=0,memdev=memdimm0,id=dimm0,slot=0,addr=4294967296 \
|
||||||
-nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait \
|
-nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait \
|
||||||
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 \
|
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 \
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<memory model='dimm'>
|
<memory model='dimm'>
|
||||||
<source>
|
<source>
|
||||||
<nodemask>1-3</nodemask>
|
<nodemask>1-3</nodemask>
|
||||||
<pagesize unit='KiB'>4096</pagesize>
|
<pagesize unit='KiB'>2048</pagesize>
|
||||||
</source>
|
</source>
|
||||||
<target>
|
<target>
|
||||||
<size unit='KiB'>524287</size>
|
<size unit='KiB'>524287</size>
|
||||||
|
@ -3,8 +3,8 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
|||||||
-numa node,nodeid=0,cpus=0-1,mem=214 \
|
-numa node,nodeid=0,cpus=0-1,mem=214 \
|
||||||
-object memory-backend-ram,id=memdimm0,size=536870912 \
|
-object memory-backend-ram,id=memdimm0,size=536870912 \
|
||||||
-device pc-dimm,node=0,memdev=memdimm0,id=dimm0 \
|
-device pc-dimm,node=0,memdev=memdimm0,id=dimm0 \
|
||||||
-object memory-backend-ram,id=memdimm1,size=536870912,host-nodes=1-3,\
|
-object memory-backend-file,id=memdimm1,prealloc=yes,\
|
||||||
policy=bind \
|
mem-path=/dev/hugepages2M/libvirt/qemu,size=536870912,host-nodes=1-3,policy=bind \
|
||||||
-device pc-dimm,node=0,memdev=memdimm1,id=dimm1 \
|
-device pc-dimm,node=0,memdev=memdimm1,id=dimm1 \
|
||||||
-nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait \
|
-nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait \
|
||||||
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 \
|
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 \
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
<memory model='dimm'>
|
<memory model='dimm'>
|
||||||
<source>
|
<source>
|
||||||
<nodemask>1-3</nodemask>
|
<nodemask>1-3</nodemask>
|
||||||
<pagesize unit='KiB'>4096</pagesize>
|
<pagesize unit='KiB'>2048</pagesize>
|
||||||
</source>
|
</source>
|
||||||
<target>
|
<target>
|
||||||
<size unit='KiB'>524287</size>
|
<size unit='KiB'>524287</size>
|
||||||
|
@ -690,6 +690,7 @@ mymain(void)
|
|||||||
QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC,
|
QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC,
|
||||||
QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
|
QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
|
||||||
QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_USB_REDIR,
|
QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_USB_REDIR,
|
||||||
|
QEMU_CAPS_DEVICE_PC_DIMM,
|
||||||
QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_FILE);
|
QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_FILE);
|
||||||
DO_TEST_LINUX("hugepages-pages", QEMU_CAPS_MEM_PATH,
|
DO_TEST_LINUX("hugepages-pages", QEMU_CAPS_MEM_PATH,
|
||||||
QEMU_CAPS_OBJECT_MEMORY_RAM,
|
QEMU_CAPS_OBJECT_MEMORY_RAM,
|
||||||
@ -1605,9 +1606,9 @@ mymain(void)
|
|||||||
DO_TEST_FAILURE("memory-hotplug", NONE);
|
DO_TEST_FAILURE("memory-hotplug", NONE);
|
||||||
DO_TEST("memory-hotplug", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA);
|
DO_TEST("memory-hotplug", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA);
|
||||||
DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
|
DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
|
||||||
QEMU_CAPS_DEVICE, QEMU_CAPS_OBJECT_MEMORY_RAM);
|
QEMU_CAPS_DEVICE, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
|
||||||
DO_TEST("memory-hotplug-dimm-addr", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
|
DO_TEST("memory-hotplug-dimm-addr", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
|
||||||
QEMU_CAPS_DEVICE, QEMU_CAPS_OBJECT_MEMORY_RAM);
|
QEMU_CAPS_DEVICE, QEMU_CAPS_OBJECT_MEMORY_FILE);
|
||||||
|
|
||||||
DO_TEST("machine-aeskeywrap-on-caps",
|
DO_TEST("machine-aeskeywrap-on-caps",
|
||||||
QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP,
|
QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user