From nobody Sat May 4 09:49:32 2024 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.zohomail.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 1527605558996680.7354400642724; Tue, 29 May 2018 07:52:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0039130BE826; Tue, 29 May 2018 14:52:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C04230012BD; Tue, 29 May 2018 14:52:36 +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 3A9656B4C3; Tue, 29 May 2018 14:52:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4TEqXvp001432 for ; Tue, 29 May 2018 10:52:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 25D9B4FA40; Tue, 29 May 2018 14:52:33 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9AD2417C4D; Tue, 29 May 2018 14:52:28 +0000 (UTC) Received: from huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 183CD30C2119; Tue, 29 May 2018 14:52:27 +0000 (UTC) Received: from DGGEML401-HUB.china.huawei.com (unknown [172.30.72.56]) by Forcepoint Email with ESMTP id 5E7968E2A8736; Tue, 29 May 2018 22:52:18 +0800 (CST) Received: from localhost.localdomain (10.175.104.211) by DGGEML401-HUB.china.huawei.com (10.3.17.32) with Microsoft SMTP Server id 14.3.382.0; Tue, 29 May 2018 22:52:12 +0800 From: Jie Wang To: , , , Date: Tue, 29 May 2018 20:38:52 +0800 Message-ID: <1527597532-37999-1-git-send-email-wangjie88@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.211] X-CFilter-Loop: Reflected X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 29 May 2018 14:52:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 29 May 2018 14:52:27 +0000 (UTC) for IP:'45.249.212.188' DOMAIN:'szxga02-in.huawei.com' HELO:'huawei.com' FROM:'wangjie88@huawei.com' RCPT:'' X-RedHat-Spam-Score: -0.012 (RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS) 45.249.212.188 szxga02-in.huawei.com 45.249.212.188 szxga02-in.huawei.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: chenxian4@huawei.com, eric.fangyi@huawei.com, wu.wubin@huawei.com, wangjie88@huawei.com Subject: [libvirt] [PATCH] conf: Introduce align for hostmem-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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 29 May 2018 14:52:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" QEMU has add the 'align' option to 'memory-backend-file'. Expose this option to users by new element align. Signed-off-by: Jie Wang --- docs/formatdomain.html.in | 18 +++++++ docs/schemas/domaincommon.rng | 7 +++ src/conf/domain_conf.c | 14 +++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 4 ++ .../memory-hotplug-nvdimm-align.args | 31 +++++++++++ .../memory-hotplug-nvdimm-align.xml | 63 ++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 3 ++ .../memory-hotplug-nvdimm-align.xml | 1 + tests/qemuxml2xmltest.c | 1 + 10 files changed, 143 insertions(+) create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.args create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml create mode 100644 tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0d0fd3b..29fe145 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -7932,6 +7932,9 @@ qemu-kvm -net nic,model=3D? /dev/null </target> </memory> <memory model=3D'nvdimm'> + <align> + <sieze unit=3D'KiB'>2048</size> + </align> <source> <path>/tmp/nvdimm</path> </source> @@ -7983,6 +7986,21 @@ qemu-kvm -net nic,model=3D? /dev/null

=20 +
align
+
+

+ For NVDIMM type devices one can optionally use + align and its subelement size + to configure the size of alignment within the NVDIMM module. + The size element has usual meaning described + here. + For QEMU domains the following restrictions apply: +

+
    +
  1. the alignment must be multiples of page size 4KiB,
  2. +
+
+
source

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 71ac3d0..9e994b1 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5145,6 +5145,13 @@ + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3689ac0..bf91167 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15739,6 +15739,12 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr x= mlopt, } VIR_FREE(tmp); =20 + if ((node =3D virXPathNode("./align", ctxt))) { + if (virDomainParseMemory("./align/size", "./align/size/@unit", ctx= t, + &def->align, true, false) < 0) + goto error; + } + /* source */ if ((node =3D virXPathNode("./source", ctxt)) && virDomainMemorySourceDefParseXML(node, ctxt, def) < 0) @@ -25334,6 +25340,14 @@ virDomainMemoryDefFormat(virBufferPtr buf, virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); =20 + if (def->align) { + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, "%llu\n", def->al= ign); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + if (virDomainMemorySourceDefFormat(buf, def) < 0) return -1; =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a78fdee..1155c84 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2107,6 +2107,7 @@ typedef enum { struct _virDomainMemoryDef { virDomainMemoryAccess access; virTristateBool discard; + unsigned long long align; =20 /* source */ virBitmapPtr sourceNodes; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c423733..5862457 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3186,6 +3186,10 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendPr= ops, if (virJSONValueObjectAdd(props, "U:size", mem->size * 1024, NULL) < 0) goto cleanup; =20 + if (mem->align && + virJSONValueObjectAdd(props, "u:align", mem->align * 1024, NULL) <= 0) + goto cleanup; + if (mem->sourceNodes) { nodemask =3D mem->sourceNodes; } else { diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.args b/test= s/qemuxml2argvdata/memory-hotplug-nvdimm-align.args new file mode 100644 index 0000000..e6fcf58 --- /dev/null +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.args @@ -0,0 +1,31 @@ +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 \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff,nvdimm=3Don \ +-m size=3D219136k,slots=3D16,maxmem=3D1099511627776k \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-numa node,nodeid=3D0,cpus=3D0-1,mem=3D214 \ +-object memory-backend-file,id=3Dmemnvdimm0,prealloc=3Dyes,mem-path=3D/tmp= /nvdimm,\ +share=3Dno,size=3D536870912,align=3D2097152 \ +-device nvdimm,node=3D0,label-size=3D131072,memdev=3Dmemnvdimm0,id=3Dnvdim= m0,slot=3D0 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-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/memory-hotplug-nvdimm-align.xml b/tests= /qemuxml2argvdata/memory-hotplug-nvdimm-align.xml new file mode 100644 index 0000000..aa9e99b --- /dev/null +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml @@ -0,0 +1,63 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1099511627776 + 1267710 + 1267710 + 2 + + hvm + + + + + + + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +

+ + +
+ + +
+ + + + + +
+ + + + 2048 + + + /tmp/nvdimm + + + 523264 + 0 + + +
+ + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 07e5ba1..4674ded 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2588,6 +2588,9 @@ mymain(void) DO_TEST("memory-hotplug-nvdimm-label", QEMU_CAPS_DEVICE_NVDIMM, QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_= MEMORY_FILE); + DO_TEST("memory-hotplug-nvdimm-align", + QEMU_CAPS_DEVICE_NVDIMM, + QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_= MEMORY_FILE); =20 DO_TEST("machine-aeskeywrap-on-caps", QEMU_CAPS_AES_KEY_WRAP, diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml b/tes= ts/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml new file mode 100644 index 0000000..9fc6001 --- /dev/null +++ b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/memory-hotplug-nvdimm-align.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 7cedc2b..822e98a 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1098,6 +1098,7 @@ mymain(void) DO_TEST("memory-hotplug-nvdimm", NONE); DO_TEST("memory-hotplug-nvdimm-access", NONE); DO_TEST("memory-hotplug-nvdimm-label", NONE); + DO_TEST("memory-hotplug-nvdimm-align", NONE); DO_TEST("net-udp", NONE); =20 DO_TEST("video-virtio-gpu-device", NONE); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list