diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5325f48dbb..83105a557e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3102,6 +3102,7 @@ qemuBuildMemoryBackendStr(unsigned long long size, int ret = -1; virJSONValuePtr props = NULL; bool nodeSpecified = virDomainNumatuneNodeSpecified(def->numa, guestNode); + bool needHugepage = !!pagesize; *backendProps = NULL; *backendType = NULL; @@ -3124,10 +3125,10 @@ qemuBuildMemoryBackendStr(unsigned long long size, mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT; if (pagesize == 0) { + bool thisHugepage = false; + /* Find the huge page size we want to use */ for (i = 0; i < def->mem.nhugepages; i++) { - bool thisHugepage = false; - hugepage = &def->mem.hugepages[i]; if (!hugepage->nodemask) { @@ -3149,6 +3150,7 @@ qemuBuildMemoryBackendStr(unsigned long long size, if (thisHugepage) { /* Hooray, we've found the page size */ + needHugepage = true; break; } } @@ -3255,7 +3257,7 @@ qemuBuildMemoryBackendStr(unsigned long long size, } /* If none of the following is requested... */ - if (!pagesize && !userNodeset && !memAccess && !nodeSpecified && !force) { + if (!needHugepage && !userNodeset && !memAccess && !nodeSpecified && !force) { /* report back that using the new backend is not necessary * to achieve the desired configuration */ ret = 1; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages2.args b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages2.args index 447bb52d00..a37f03d0d2 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages2.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages2.args @@ -10,12 +10,10 @@ QEMU_AUDIO_DRV=none \ -M pc \ -m 1024 \ -smp 2,sockets=2,cores=1,threads=1 \ --object memory-backend-file,id=ram-node0,prealloc=yes,\ -mem-path=/dev/hugepages2M/libvirt/qemu,size=268435456 \ --numa node,nodeid=0,cpus=0,memdev=ram-node0 \ --object memory-backend-file,id=ram-node1,prealloc=yes,\ -mem-path=/dev/hugepages2M/libvirt/qemu,size=805306368 \ --numa node,nodeid=1,cpus=1,memdev=ram-node1 \ +-mem-prealloc \ +-mem-path /dev/hugepages2M/libvirt/qemu \ +-numa node,nodeid=0,cpus=0,mem=256 \ +-numa node,nodeid=1,cpus=1,mem=768 \ -uuid ef1bdff4-27f3-4e85-a807-5fb4d58463cc \ -nographic \ -nodefaults \