From: Michal Privoznik Date: Thu, 30 Aug 2018 11:43:33 +0000 (+0200) Subject: qemuBuildMemPathStr: Produce -mem-path more frequently X-Git-Tag: v4.8.0-rc1~261 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65a547aa8e6362c0f37f873bd7d03ebdbb5c4be2;p=thirdparty%2Flibvirt.git qemuBuildMemPathStr: Produce -mem-path more frequently https://bugzilla.redhat.com/show_bug.cgi?id=1622455 If a domain is configured to use under we have to honour that setting and produce -mem-path on the command line. We are not doing so if domain has no guest NUMA nodes nor hugepages. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b72506f4e1..877269f52e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7531,21 +7531,22 @@ qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg, const long system_page_size = virGetSystemPageSizeKB(); char *mem_path = NULL; - /* - * No-op if hugepages were not requested. - */ - if (!def->mem.nhugepages) - return 0; - - /* There is one special case: if user specified "huge" - * pages of regular system pages size. - * And there is nothing to do in this case. - */ - if (def->mem.hugepages[0].size == system_page_size) + /* There are two cases where we want to put -mem-path onto + * the command line: First one is when there are no guest + * NUMA nodes and hugepages are configured. The second one is + * if user requested file allocation. */ + if (def->mem.nhugepages && + def->mem.hugepages[0].size != system_page_size) { + if (qemuGetDomainHupageMemPath(def, cfg, + def->mem.hugepages[0].size, + &mem_path) < 0) + return -1; + } else if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) { + if (qemuGetMemoryBackingPath(def, cfg, "ram", &mem_path) < 0) + return -1; + } else { return 0; - - if (qemuGetDomainHupageMemPath(def, cfg, def->mem.hugepages[0].size, &mem_path) < 0) - return -1; + } if (def->mem.allocation != VIR_DOMAIN_MEMORY_ALLOCATION_IMMEDIATE) virCommandAddArgList(cmd, "-mem-prealloc", NULL); diff --git a/tests/qemuxml2argvdata/fd-memory-no-numa-topology.args b/tests/qemuxml2argvdata/fd-memory-no-numa-topology.args index 0e0d0830e8..76c7556468 100644 --- a/tests/qemuxml2argvdata/fd-memory-no-numa-topology.args +++ b/tests/qemuxml2argvdata/fd-memory-no-numa-topology.args @@ -10,6 +10,7 @@ QEMU_AUDIO_DRV=none \ -machine pc-i440fx-wily,accel=kvm,usb=off,dump-guest-core=off \ -m 14336 \ -mem-prealloc \ +-mem-path /var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram \ -smp 8,sockets=8,cores=1,threads=1 \ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ -display none \