From nobody Mon Feb 9 13:57:24 2026 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; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1545297285483703.5461830816869; Thu, 20 Dec 2018 01:14:45 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7EB44A0490; Thu, 20 Dec 2018 09:14:43 +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 440EA68D58; Thu, 20 Dec 2018 09:14:43 +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 EF4B7181B9EB; Thu, 20 Dec 2018 09:14:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wBK9Efc7030327 for ; Thu, 20 Dec 2018 04:14:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id A180F5D738; Thu, 20 Dec 2018 09:14:41 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 998A85D6B3 for ; Thu, 20 Dec 2018 09:14:34 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 A5A5789ACA for ; Thu, 20 Dec 2018 09:14:33 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Dec 2018 01:14:33 -0800 Received: from zly-optiplex-9020.bj.intel.com ([10.238.135.151]) by fmsmga001.fm.intel.com with ESMTP; 20 Dec 2018 01:14:32 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,376,1539673200"; d="scan'208";a="131518375" From: Luyao Zhong To: libvir-list@redhat.com Date: Thu, 20 Dec 2018 17:14:40 +0800 Message-Id: <1545297290-25463-2-git-send-email-luyao.zhong@intel.com> In-Reply-To: <1545297290-25463-1-git-send-email-luyao.zhong@intel.com> References: <1545297290-25463-1-git-send-email-luyao.zhong@intel.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 20 Dec 2018 09:14:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 20 Dec 2018 09:14:33 +0000 (UTC) for IP:'192.55.52.120' DOMAIN:'mga04.intel.com' HELO:'mga04.intel.com' FROM:'luyao.zhong@intel.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 192.55.52.120 mga04.intel.com 192.55.52.120 mga04.intel.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v5 01/11] nvdimm: introduce 'alignsize' element into xml for NVDIMM memory 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 20 Dec 2018 09:14:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" NVDIMM emulation will mmap the backend file, it uses host pagesize as the alignment of mapping address before, but some backends may require alignments different from the pagesize. So the 'alignsize' option will be introduced to allow users specifying the proper alignment: ... /dev/dax0.0 2 4094 0 ... Signed-off-by: Luyao Zhong Reviewed-by: John Ferlan --- docs/formatdomain.html.in | 23 +++++++-- docs/schemas/domaincommon.rng | 13 +++-- src/conf/domain_conf.c | 32 +++++++++--- src/conf/domain_conf.h | 1 + .../memory-hotplug-nvdimm-align.xml | 58 ++++++++++++++++++= ++++ .../memory-hotplug-nvdimm-align.xml | 1 + tests/qemuxml2xmltest.c | 1 + 7 files changed, 116 insertions(+), 13 deletions(-) create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml create mode 120000 tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index a18d063..515e656 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -8322,6 +8322,7 @@ qemu-kvm -net nic,model=3D? /dev/null <memory model=3D'nvdimm'> <source> <path>/tmp/nvdimm</path> + <alignsize unit=3D'KiB'>2048</alignsize> </source> <target> <size unit=3D'KiB'>524288</size> @@ -8403,10 +8404,26 @@ qemu-kvm -net nic,model=3D? /dev/null =20

- For model nvdimm this element is mandatory and has a - single child element path that represents a path - in the host that backs the nvdimm module in the guest. + For model nvdimm this element is mandatory. The + mandatory child element path represents a path in + the host that backs the nvdimm module in the guest. If + nvdimm is provided, then the following optional + elements can be provided as well:

+ +
+
alignsize
+
+

+ This element can be used to specify a proper alignment. + When mmap(2) the backend files, QEMU uses the host page + size by default as the alignment of mapping address. However, + some backends may require alignments different from the page. + For example, mmap a real NVDIMM device maybe 2M-aligned requ= ired. + Since 5.0.0 +

+
+
=20
target
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 76b49aa..21006c3 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5384,9 +5384,16 @@ - - - + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d8dfd16..7e59d8c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15780,6 +15780,11 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node, _("path is required for model 'nvdimm'")); goto cleanup; } + + if (virDomainParseMemory("./alignsize", "./alignsize/@unit", ctxt, + &def->alignsize, false, false) < 0) + goto cleanup; + break; =20 case VIR_DOMAIN_MEMORY_MODEL_NONE: @@ -22735,13 +22740,22 @@ virDomainMemoryDefCheckABIStability(virDomainMemo= ryDefPtr src, return false; } =20 - if (src->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && - src->labelsize !=3D dst->labelsize) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target NVDIMM label size '%llu' doesn't match " - "source NVDIMM label size '%llu'"), - src->labelsize, dst->labelsize); - return false; + if (src->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM) { + if (src->labelsize !=3D dst->labelsize) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target NVDIMM label size '%llu' doesn't matc= h " + "source NVDIMM label size '%llu'"), + src->labelsize, dst->labelsize); + return false; + } + + if (src->alignsize !=3D dst->alignsize) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target NVDIMM alignment '%llu' doesn't match= " + "source NVDIMM alignment '%llu'"), + src->alignsize, dst->alignsize); + return false; + } } =20 return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); @@ -26278,6 +26292,10 @@ virDomainMemorySourceDefFormat(virBufferPtr buf, =20 case VIR_DOMAIN_MEMORY_MODEL_NVDIMM: virBufferEscapeString(buf, "%s\n", def->nvdimmPath); + + if (def->alignsize) + virBufferAsprintf(buf, "%llu\n", + def->alignsize); break; =20 case VIR_DOMAIN_MEMORY_MODEL_NONE: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 5814997..848bd94 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2147,6 +2147,7 @@ struct _virDomainMemoryDef { virBitmapPtr sourceNodes; unsigned long long pagesize; /* kibibytes */ char *nvdimmPath; + unsigned long long alignsize; /* kibibytes; valid only for NVDIMM */ =20 /* target */ int model; /* virDomainMemoryModel */ diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml b/tests= /qemuxml2argvdata/memory-hotplug-nvdimm-align.xml new file mode 100644 index 0000000..a8c5198 --- /dev/null +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml @@ -0,0 +1,58 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1099511627776 + 1267710 + 1267710 + 2 + + hvm + + + + + + + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
+ + +
+ + +
+ + + + + +
+ + + + /tmp/nvdimm + 2048 + + + 523264 + 0 + +
+ + + diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml b/tes= ts/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml new file mode 120000 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 1062dee..5161f4a 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1116,6 +1116,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 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list