From nobody Fri May 16 08:26:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1497364026929845.3111913328722; Tue, 13 Jun 2017 07:27:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 331ADC01A688; Tue, 13 Jun 2017 14:27:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01F14A3941; Tue, 13 Jun 2017 14:27:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 71DBE1841C44; Tue, 13 Jun 2017 14:27:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5DER1QA026694 for ; Tue, 13 Jun 2017 10:27:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2D1C0904E0; Tue, 13 Jun 2017 14:27:01 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6CB4904FA for ; Tue, 13 Jun 2017 14:27:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 331ADC01A688 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 331ADC01A688 From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 13 Jun 2017 16:26:54 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] qemu: Prefer hugepages over mem source='file' X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 13 Jun 2017 14:27:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1214369 Consider the following XML: The following cmd line is generated: -object memory-backend-file,id=3Dram-node0,mem-path=3D/var/lib/libvirt/qemu/ram, share=3Dyes,size=3D524288000 -numa node,nodeid=3D0,cpus=3D0-3,memdev=3Dra= m-node0 -object memory-backend-file,id=3Dram-node1,mem-path=3D/var/lib/libvirt/qemu/ram, share=3Dyes,size=3D524288000 -numa node,nodeid=3D1,cpus=3D4-7,memdev=3Dra= m-node1 This is obviously wrong as for node 1 hugepages should have been used. The hugepages configuration is more specific than . Signed-off-by: Michal Privoznik --- src/qemu/qemu_command.c | 6 +-- .../qemuxml2argv-hugepages-memaccess2.args | 39 ++++++++++++++ .../qemuxml2argv-hugepages-memaccess2.xml | 62 ++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 3 ++ .../qemuxml2xmlout-hugepages-memaccess2.xml | 1 + tests/qemuxml2xmltest.c | 1 + 6 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess= 2.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess= 2.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memac= cess2.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 088fc7911..3e1552a1b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3414,9 +3414,9 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendPro= ps, if (VIR_STRDUP(memPath, mem->nvdimmPath) < 0) goto cleanup; prealloc =3D true; - } else if (def->mem.source =3D=3D VIR_DOMAIN_MEMORY_SOURCE_FILE) { - /* We can have both pagesize and mem source, - * then check mem source first. */ + } else if (!pagesize && def->mem.source =3D=3D VIR_DOMAIN_MEMORY_S= OURCE_FILE) { + /* We can have both pagesize and mem source. If that's the cas= e, + * prefer hugepages as those are more specific. */ if (VIR_STRDUP(memPath, cfg->memoryBackingDir) < 0) goto cleanup; } else { diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args = b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args new file mode 100644 index 000000000..11985232a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args @@ -0,0 +1,39 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i686 \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m size=3D4194304k,slots=3D16,maxmem=3D8388608k \ +-smp 4,sockets=3D4,cores=3D1,threads=3D1 \ +-object memory-backend-file,id=3Dram-node0,mem-path=3D/var/lib/libvirt/qem= u/ram,\ +share=3Dno,size=3D1073741824,host-nodes=3D0-3,policy=3Dbind \ +-numa node,nodeid=3D0,cpus=3D0,memdev=3Dram-node0 \ +-object memory-backend-file,id=3Dram-node1,prealloc=3Dyes,\ +mem-path=3D/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=3Dyes,size=3D= 1073741824,\ +host-nodes=3D0-3,policy=3Dbind \ +-numa node,nodeid=3D1,cpus=3D1,memdev=3Dram-node1 \ +-object memory-backend-file,id=3Dram-node2,mem-path=3D/var/lib/libvirt/qem= u/ram,\ +share=3Dno,size=3D1073741824,host-nodes=3D0-3,policy=3Dbind \ +-numa node,nodeid=3D2,cpus=3D2,memdev=3Dram-node2 \ +-object memory-backend-file,id=3Dram-node3,mem-path=3D/var/lib/libvirt/qem= u/ram,\ +share=3Dno,size=3D1073741824,host-nodes=3D3,policy=3Dbind \ +-numa node,nodeid=3D3,cpus=3D3,memdev=3Dram-node3 \ +-object memory-backend-file,id=3Dmemdimm0,prealloc=3Dyes,\ +mem-path=3D/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=3Dyes,size=3D= 536870912,\ +host-nodes=3D0-3,policy=3Dbind \ +-device pc-dimm,node=3D1,memdev=3Dmemdimm0,id=3Ddimm0,slot=3D0,addr=3D4294= 967296 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-usb \ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ +-device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml b= /tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml new file mode 100644 index 000000000..c0011285c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml @@ -0,0 +1,62 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 8388608 + 4194304 + 4194304 + + + + + + + + 4 + + + + + + hvm + + + + + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + +
+ + +
+ + +
+ + + + + +
+ + + + 524288 + 1 + +
+ + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a1f19437b..43d3f1bd3 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -822,6 +822,9 @@ mymain(void) DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA); + DO_TEST("hugepages-memaccess2", QEMU_CAPS_OBJECT_MEMORY_FILE, + QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM, + QEMU_CAPS_NUMA); DO_TEST("nosharepages", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MEM_MERGE); DO_TEST("disk-cdrom", NONE); DO_TEST("disk-iscsi", NONE); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess2.x= ml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess2.xml new file mode 120000 index 000000000..3f7a38333 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess2.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index c804d8a01..1bdd383a5 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -420,6 +420,7 @@ mymain(void) DO_TEST("hugepages-pages6", NONE); DO_TEST("hugepages-shared", NONE); DO_TEST("hugepages-memaccess", NONE); + DO_TEST("hugepages-memaccess2", NONE); DO_TEST("nosharepages", NONE); DO_TEST("restore-v2", NONE); DO_TEST("migrate", NONE); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list