From nobody Sun Feb 8 11:59:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1489075830020679.3798617761187; Thu, 9 Mar 2017 08:10:30 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v29G6te9058578; Thu, 9 Mar 2017 11:06:55 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v29G6Z9O032402 for ; Thu, 9 Mar 2017 11:06:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 551892D5C0; Thu, 9 Mar 2017 16:06:35 +0000 (UTC) Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA4562D653 for ; Thu, 9 Mar 2017 16:06:34 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 9 Mar 2017 17:06:14 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 05/17] Introduce NVDIMM memory model 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" NVDIMM is new type of memory introduced into QEMU 2.6. The idea is that we have a Non-Volatile memory module that keeps the data persistent across domain reboots. At the domain XML level, we already have some representation of 'dimm' modules. Long story short, we have element that lives under . Now, the element even has @model attribute which we can use to introduce new memory type: /tmp/nvdimm 523264 0
So far, this is just a XML parser/formatter extension. QEMU driver implementation is in the next commit. For more info on NVDIMM visit the following web page: http://pmem.io/ Signed-off-by: Michal Privoznik --- docs/formatdomain.html.in | 56 +++++++++---- docs/schemas/domaincommon.rng | 32 ++++--- src/conf/domain_conf.c | 97 ++++++++++++++++--= ---- src/conf/domain_conf.h | 2 + src/qemu/qemu_command.c | 6 ++ src/qemu/qemu_domain.c | 5 ++ .../qemuxml2argv-memory-hotplug-nvdimm.xml | 56 +++++++++++++ .../qemuxml2xmlout-memory-hotplug-nvdimm.xml | 1 + tests/qemuxml2xmltest.c | 1 + 9 files changed, 205 insertions(+), 51 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nvdi= mm.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-memory-hotplug-= nvdimm.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 3095111c4..6e89bfe3a 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -7091,7 +7091,6 @@ qemu-kvm -net nic,model=3D? /dev/null guests' memory resource needs. =20 Some hypervisors may require NUMA configured for the guest. - Since 1.2.14

=20

@@ -7116,6 +7115,15 @@ qemu-kvm -net nic,model=3D? /dev/null <node>1</node> </target> </memory> + <memory model=3D'nvdimm'> + <source> + <path>/tmp/nvdimm</path> + </source> + <target> + <size unit=3D'KiB'>524288</size> + <node>1</node> + </target> + </memory> </devices> ... @@ -7123,28 +7131,48 @@ qemu-kvm -net nic,model=3D? /dev/null

model

- Currently only the dimm model is supported in order= to - add a virtual DIMM module to the guest. + Provide dimm to add a virtual DIMM module to the gu= est. + Since 1.2.14 + Provide nvdimm model adds a Non-Volatile DIMM + module. Since 3.2.0

=20
source

- The optional source element allows to fine tune the source of the - memory used for the given memory device. If the element is not - provided defaults configured via numatune are used. + For model dimm this element is optional and allows = to + fine tune the source of the memory used for the given memory dev= ice. + If the element is not provided defaults configured via + numatune are used. If dimm is provided, + then the following optional elements can be provided as well:

-

- pagesize can optionally be used to override the def= ault - host page size used for backing the memory device. =20 - The configured value must correspond to a page size supported by= the - host. -

+
+
pagesize
+
+

+ This element can be used to override the default + host page size used for backing the memory device. + The configured value must correspond to a page size + supported by the host. +

+
+ +
nodemask
+
+

+ This element can be used to override the default + set of NUMA nodes where the memory would be + allocated. +

+
+
+

- nodemask can optionally be used to override the def= ault - set of NUMA nodes where the memory would be allocated. + 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.

=20 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 1860f9075..07b3c52ad 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4746,6 +4746,7 @@ dimm + nvdimm @@ -4765,18 +4766,27 @@ =20 - - - - + + + + + + + + + + + + + + + + + + - - - - - - - + + =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a58f99762..e23ce0015 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -858,8 +858,11 @@ VIR_ENUM_DECL(virDomainBlockJob) VIR_ENUM_IMPL(virDomainBlockJob, VIR_DOMAIN_BLOCK_JOB_TYPE_LAST, "", "", "copy", "", "active-commit") =20 -VIR_ENUM_IMPL(virDomainMemoryModel, VIR_DOMAIN_MEMORY_MODEL_LAST, - "", "dimm") +VIR_ENUM_IMPL(virDomainMemoryModel, + VIR_DOMAIN_MEMORY_MODEL_LAST, + "", + "dimm", + "nvdimm") =20 VIR_ENUM_IMPL(virDomainShmemModel, VIR_DOMAIN_SHMEM_MODEL_LAST, "ivshmem", @@ -2418,6 +2421,7 @@ void virDomainMemoryDefFree(virDomainMemoryDefPtr def) if (!def) return; =20 + VIR_FREE(def->nvdimmPath); virBitmapFree(def->sourceNodes); virDomainDeviceInfoClear(&def->info); VIR_FREE(def); @@ -13769,20 +13773,36 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node, xmlNodePtr save =3D ctxt->node; ctxt->node =3D node; =20 - if (virDomainParseMemory("./pagesize", "./pagesize/@unit", ctxt, - &def->pagesize, false, false) < 0) - goto cleanup; - - if ((nodemask =3D virXPathString("string(./nodemask)", ctxt))) { - if (virBitmapParse(nodemask, &def->sourceNodes, - VIR_DOMAIN_CPUMASK_LEN) < 0) + switch ((virDomainMemoryModel) def->model) { + case VIR_DOMAIN_MEMORY_MODEL_DIMM: + if (virDomainParseMemory("./pagesize", "./pagesize/@unit", ctxt, + &def->pagesize, false, false) < 0) goto cleanup; =20 - if (virBitmapIsAllClear(def->sourceNodes)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Invalid value of 'nodemask': %s"), nodemask); + if ((nodemask =3D virXPathString("string(./nodemask)", ctxt))) { + if (virBitmapParse(nodemask, &def->sourceNodes, + VIR_DOMAIN_CPUMASK_LEN) < 0) + goto cleanup; + + if (virBitmapIsAllClear(def->sourceNodes)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Invalid value of 'nodemask': %s"), nodem= ask); + goto cleanup; + } + } + break; + + case VIR_DOMAIN_MEMORY_MODEL_NVDIMM: + if (!(def->nvdimmPath =3D virXPathString("string(./path)", ctxt)))= { + virReportError(VIR_ERR_XML_DETAIL, "%s", + _("path is required for model nvdimm'")); goto cleanup; } + break; + + case VIR_DOMAIN_MEMORY_MODEL_NONE: + case VIR_DOMAIN_MEMORY_MODEL_LAST: + break; } =20 ret =3D 0; @@ -15187,12 +15207,25 @@ virDomainMemoryFindByDefInternal(virDomainDefPtr = def, tmp->size !=3D mem->size) continue; =20 - /* source stuff -> match with device */ - if (tmp->pagesize !=3D mem->pagesize) - continue; + switch ((virDomainMemoryModel) mem->model) { + case VIR_DOMAIN_MEMORY_MODEL_DIMM: + /* source stuff -> match with device */ + if (tmp->pagesize !=3D mem->pagesize) + continue; =20 - if (!virBitmapEqual(tmp->sourceNodes, mem->sourceNodes)) - continue; + if (!virBitmapEqual(tmp->sourceNodes, mem->sourceNodes)) + continue; + break; + + case VIR_DOMAIN_MEMORY_MODEL_NVDIMM: + if (STRNEQ(tmp->nvdimmPath, mem->nvdimmPath)) + continue; + break; + + case VIR_DOMAIN_MEMORY_MODEL_NONE: + case VIR_DOMAIN_MEMORY_MODEL_LAST: + break; + } =20 break; } @@ -22585,23 +22618,35 @@ virDomainMemorySourceDefFormat(virBufferPtr buf, char *bitmap =3D NULL; int ret =3D -1; =20 - if (!def->pagesize && !def->sourceNodes) + if (!def->pagesize && !def->sourceNodes && !def->nvdimmPath) return 0; =20 virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); =20 - if (def->sourceNodes) { - if (!(bitmap =3D virBitmapFormat(def->sourceNodes))) - goto cleanup; + switch ((virDomainMemoryModel) def->model) { + case VIR_DOMAIN_MEMORY_MODEL_DIMM: + if (def->sourceNodes) { + if (!(bitmap =3D virBitmapFormat(def->sourceNodes))) + goto cleanup; =20 - virBufferAsprintf(buf, "%s\n", bitmap); + virBufferAsprintf(buf, "%s\n", bitmap); + } + + if (def->pagesize) + virBufferAsprintf(buf, "%llu= \n", + def->pagesize); + break; + + case VIR_DOMAIN_MEMORY_MODEL_NVDIMM: + virBufferEscapeString(buf, "%s\n", def->nvdimmPath); + break; + + case VIR_DOMAIN_MEMORY_MODEL_NONE: + case VIR_DOMAIN_MEMORY_MODEL_LAST: + break; } =20 - if (def->pagesize) - virBufferAsprintf(buf, "%llu\n", - def->pagesize); - virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1e53cc328..823582253 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1996,6 +1996,7 @@ struct _virDomainRNGDef { typedef enum { VIR_DOMAIN_MEMORY_MODEL_NONE, VIR_DOMAIN_MEMORY_MODEL_DIMM, /* dimm hotpluggable memory device */ + VIR_DOMAIN_MEMORY_MODEL_NVDIMM, /* nvdimm memory device */ =20 VIR_DOMAIN_MEMORY_MODEL_LAST } virDomainMemoryModel; @@ -2004,6 +2005,7 @@ struct _virDomainMemoryDef { /* source */ virBitmapPtr sourceNodes; unsigned long long pagesize; /* kibibytes */ + char *nvdimmPath; =20 /* target */ int model; /* virDomainMemoryModel */ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0cca99567..07178f839 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3416,6 +3416,12 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem) =20 break; =20 + case VIR_DOMAIN_MEMORY_MODEL_NVDIMM: + virReportError(VIR_ERR_NO_SUPPORT, "%s", + _("nvdimm not supported yet")); + return NULL; + break; + case VIR_DOMAIN_MEMORY_MODEL_NONE: case VIR_DOMAIN_MEMORY_MODEL_LAST: break; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1a42fcf1b..66c0e5911 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5951,6 +5951,11 @@ qemuDomainDefValidateMemoryHotplugDevice(const virDo= mainMemoryDef *mem, } break; =20 + case VIR_DOMAIN_MEMORY_MODEL_NVDIMM: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("nvdimm hotplug not supported yet")); + return -1; + case VIR_DOMAIN_MEMORY_MODEL_NONE: case VIR_DOMAIN_MEMORY_MODEL_LAST: return -1; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nvdimm.xml = b/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nvdimm.xml new file mode 100644 index 000000000..1578db453 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nvdimm.xml @@ -0,0 +1,56 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1099511627776 + 1267710 + 1267710 + 2 + + hvm + + + + + + + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + +
+ + +
+ + + + + +
+ + + + /tmp/nvdimm + + + 523264 + 0 + +
+ + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-memory-hotplug-nvdimm.= xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-memory-hotplug-nvdimm.xml new file mode 120000 index 000000000..4cac477a9 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-memory-hotplug-nvdimm.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/qemuxml2argv-memory-hotplug-nvdimm.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 4353ad245..e1c341dd5 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1078,6 +1078,7 @@ mymain(void) DO_TEST("memory-hotplug", NONE); DO_TEST("memory-hotplug-nonuma", NONE); DO_TEST("memory-hotplug-dimm", NONE); + DO_TEST("memory-hotplug-nvdimm", NONE); DO_TEST("net-udp", NONE); =20 DO_TEST("video-virtio-gpu-device", NONE); --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list