[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] qemu: Don't try to use hugepages if not enabled



On Wed, Jun 14, 2017 at 10:48:33AM +0200, Michal Privoznik wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1214369
>
> My fix 671d18594f4 was incomplete. If domain doesn't have
> hugepages enalbed, because of missing condition we would still be

s/enalbed/enabled

> putting hugepages path onto qemu cmd line. Clean up the
> conditions so that it's more visible next time.
>
> Signed-off-by: Michal Privoznik <mprivozn redhat com>
> ---
>  src/qemu/qemu_command.c                            | 12 +++++-----
>  .../qemuxml2argv-cpu-numa-memshared.args           | 26 ++++++++++++++++++++++
>  tests/qemuxml2argvtest.c                           |  1 +
>  3 files changed, 33 insertions(+), 6 deletions(-)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
>
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 3e1552a1b..8c12b2be0 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -3408,23 +3408,23 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
>
>      if (pagesize || mem->nvdimmPath || memAccess ||
>          def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
>          *backendType = "memory-backend-file";
>
> -        if (mem->nvdimmPath) {
> +        if (pagesize) {
> +            if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &memPath) < 0)
> +                goto cleanup;
> +            prealloc = true;
> +        } else if (mem->nvdimmPath) {
>              if (VIR_STRDUP(memPath, mem->nvdimmPath) < 0)
>                  goto cleanup;
>              prealloc = true;
> -        } else if (!pagesize && def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
> +        } else {
>              /* We can have both pagesize and mem source. If that's the case,
>               * prefer hugepages as those are more specific. */
>              if (VIR_STRDUP(memPath, cfg->memoryBackingDir) < 0)
>                  goto cleanup;
> -        } else {
> -            if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &memPath) < 0)
> -                goto cleanup;
> -            prealloc = true;
>          }
>
>          if (virJSONValueObjectAdd(props,
>                                    "B:prealloc", prealloc,
>                                    "s:mem-path", memPath,
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
> new file mode 100644
> index 000000000..cceffce3a
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
> @@ -0,0 +1,26 @@
> +LC_ALL=C \
> +PATH=/bin \
> +HOME=/home/test \
> +USER=test \
> +LOGNAME=test \
> +QEMU_AUDIO_DRV=none \
> +/usr/bin/qemu-system-x86_64 \
> +-name QEMUGuest1 \
> +-S \
> +-M pc \
> +-m 214 \
> +-smp 16,sockets=2,cores=4,threads=2 \
> +-object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
> +share=yes,size=112197632 \
> +-numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
> +-object memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram,\
> +share=no,size=112197632 \
> +-numa node,nodeid=1,cpus=8-15,memdev=ram-node1 \
> +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
> +-nographic \
> +-nodefaults \
> +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
> +-no-acpi \
> +-boot n \
> +-usb \
> +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 43d3f1bd3..799aea9fa 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -1539,10 +1539,11 @@ mymain(void)
>      DO_TEST_PARSE_ERROR("cpu-numa3", NONE);
>      DO_TEST_FAILURE("cpu-numa-disjoint", NONE);
>      DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA);
>      DO_TEST_FAILURE("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_RAM);
>      DO_TEST_FAILURE("cpu-numa-memshared", NONE);
> +    DO_TEST("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_FILE);
>      DO_TEST("cpu-host-model", NONE);
>      DO_TEST("cpu-host-model-vendor", NONE);
>      skipLegacyCPUs = true;
>      DO_TEST("cpu-host-model-fallback", NONE);
>      DO_TEST_FAILURE("cpu-host-model-nofallback", NONE);

Fixes the issue described by
https://bugzilla.redhat.com/show_bug.cgi?id=1214369#c16.
ACK

Erik


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]