From nobody Tue May 13 09:02:17 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.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 1539743102569193.50027521625532; Tue, 16 Oct 2018 19:25:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 84F8930832CA; Wed, 17 Oct 2018 02:25:00 +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 47B897F8E4; Wed, 17 Oct 2018 02:25:00 +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 DE5444BB79; Wed, 17 Oct 2018 02:24:59 +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 w9H2NSYw022750 for ; Tue, 16 Oct 2018 22:23:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 596F6768DC; Wed, 17 Oct 2018 02:23:28 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4CCB97F8F1 for ; Wed, 17 Oct 2018 02:23:28 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 8C708C0587CE for ; Wed, 17 Oct 2018 02:23:26 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2018 19:23:26 -0700 Received: from zly-optiplex-9020.bj.intel.com ([10.238.135.151]) by FMSMGA003.fm.intel.com with ESMTP; 16 Oct 2018 19:23:25 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,389,1534834800"; d="scan'208";a="88901813" From: Luyao Zhong To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 10:21:44 +0800 Message-Id: <1539742905-15644-3-git-send-email-luyao.zhong@intel.com> In-Reply-To: <1539742905-15644-1-git-send-email-luyao.zhong@intel.com> References: <1539742905-15644-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.32]); Wed, 17 Oct 2018 02:23:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 17 Oct 2018 02:23:26 +0000 (UTC) for IP:'192.55.52.115' DOMAIN:'mga14.intel.com' HELO:'mga14.intel.com' FROM:'luyao.zhong@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.115 mga14.intel.com 192.55.52.115 mga14.intel.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Luyao Zhong , Zhong@redhat.com Subject: [libvirt] [RFC 2/3] xml: update xml parsing and formating about 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 17 Oct 2018 02:25:01 +0000 (UTC) X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Four new parameters were introduced into libvirt xml, including 'align', 'pmem', 'persistence' and 'unarmed', which are related to NVDIMM memory device. So we need parse and format the xml to save these configurations.Besides, more testcases related to these parameters were added to verify the xml2xml process. Signed-off-by: Zhong,Luyao --- src/conf/domain_conf.c | 115 +++++++++++++++++= ++-- src/conf/domain_conf.h | 14 +++ src/libvirt_private.syms | 2 + .../memory-hotplug-nvdimm-align.xml | 1 + .../memory-hotplug-nvdimm-persistence.xml | 1 + .../memory-hotplug-nvdimm-pmem.xml | 1 + .../memory-hotplug-nvdimm-unarmed.xml | 1 + tests/qemuxml2xmltest.c | 4 + 8 files changed, 132 insertions(+), 7 deletions(-) create mode 120000 tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml create mode 120000 tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-persiste= nce.xml create mode 120000 tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-pmem.xml create mode 120000 tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-unarmed.= xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9911d56..1326116 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -932,6 +932,12 @@ VIR_ENUM_IMPL(virDomainMemoryModel, "dimm", "nvdimm") =20 +VIR_ENUM_IMPL(virDomainMemoryPersistence, + VIR_DOMAIN_MEMORY_PERSISTENCE_LAST, + "", + "mem-ctrl", + "cpu") + VIR_ENUM_IMPL(virDomainShmemModel, VIR_DOMAIN_SHMEM_MODEL_LAST, "ivshmem", "ivshmem-plain", @@ -15656,7 +15662,9 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node, virDomainMemoryDefPtr def) { int ret =3D -1; + int val; char *nodemask =3D NULL; + char *ndPmem =3D NULL; xmlNodePtr save =3D ctxt->node; ctxt->node =3D node; =20 @@ -15685,6 +15693,21 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node, _("path is required for model 'nvdimm'")); goto cleanup; } + + if (virDomainParseMemory("./alignsize", "./alignsize/@unit", ctxt, + &def->alignsize, false, false) < 0) + goto cleanup; + + if ((ndPmem =3D virXPathString("string(./pmem)", ctxt))) { + if ((val =3D virTristateSwitchTypeFromString(ndPmem)) < 0) { + virReportError(VIR_ERR_XML_DETAIL, + _("Invalid value of nvdimm 'pmem': %s"), + ndPmem); + goto cleanup; + } + def->nvdimmPmem =3D val; + } + VIR_FREE(ndPmem); break; =20 case VIR_DOMAIN_MEMORY_MODEL_NONE: @@ -15696,6 +15719,7 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node, =20 cleanup: VIR_FREE(nodemask); + VIR_FREE(ndPmem); ctxt->node =3D save; return ret; } @@ -15710,6 +15734,9 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node, xmlNodePtr save =3D ctxt->node; ctxt->node =3D node; int rv; + int val; + char *ndPrst =3D NULL; + char *ndUnarmed =3D NULL; =20 /* initialize to value which marks that the user didn't specify it */ def->targetNode =3D -1; @@ -15741,11 +15768,35 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node, _("label size must be smaller than NVDIMM size"= )); goto cleanup; } + + if ((ndPrst =3D virXPathString("string(./persistence)", ctxt))) { + if ((val =3D virDomainMemoryPersistenceTypeFromString(ndPrst)) = < 0) { + virReportError(VIR_ERR_XML_DETAIL, + _("Invalid value of nvdimm 'persistence': %s= "), + ndPrst); + goto cleanup; + } + def->nvdimmPersistence =3D val; + } + VIR_FREE(ndPrst); + + if ((ndUnarmed =3D virXPathString("string(./unarmed)", ctxt))) { + if ((val =3D virTristateSwitchTypeFromString(ndUnarmed)) < 0) { + virReportError(VIR_ERR_XML_DETAIL, + _("Invalid value of nvdimm 'unarmed': %s"), + ndUnarmed); + goto cleanup; + } + def->nvdimmUnarmed =3D val; + } + VIR_FREE(ndUnarmed); } =20 ret =3D 0; =20 cleanup: + VIR_FREE(ndPrst); + VIR_FREE(ndUnarmed); ctxt->node =3D save; return ret; } @@ -22447,13 +22498,49 @@ 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; + } + + if (src->nvdimmPmem !=3D dst->nvdimmPmem) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target NVDIMM pmem flag '%s' doesn't match " + "source NVDIMM pmem flag '%s'"), + virTristateSwitchTypeToString(src->nvdimmPmem), + virTristateSwitchTypeToString(dst->nvdimmPmem)); + return false; + } + + if (src->nvdimmPersistence !=3D dst->nvdimmPersistence) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target NVDIMM persistence value '%s' doesn't= match " + "source NVDIMM persistence value '%s'"), + virDomainMemoryPersistenceTypeToString(src->nvd= immPersistence), + virDomainMemoryPersistenceTypeToString(dst->nvd= immPersistence)); + return false; + } + + if (src->nvdimmUnarmed !=3D dst->nvdimmUnarmed) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target NVDIMM unarmed flag '%s' doesn't matc= h " + "source NVDIMM unarmed flag '%s'"), + virTristateSwitchTypeToString(src->nvdimmUnarme= d), + virTristateSwitchTypeToString(dst->nvdimmUnarme= d)); + return false; + } } =20 return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); @@ -25939,6 +26026,14 @@ 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); + + if (def->nvdimmPmem) + virBufferEscapeString(buf, "%s\n", + virTristateSwitchTypeToString(def->nvdim= mPmem)); break; =20 case VIR_DOMAIN_MEMORY_MODEL_NONE: @@ -25974,6 +26069,12 @@ virDomainMemoryTargetDefFormat(virBufferPtr buf, virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } + if (def->nvdimmPersistence) + virBufferEscapeString(buf, "%s\n", + virDomainMemoryPersistenceTypeToString(def->= nvdimmPersistence)); + if (def->nvdimmUnarmed) + virBufferEscapeString(buf, "%s\n", + virTristateSwitchTypeToString(def->nvdimmUna= rmed)); =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e30a4b2..057aaea 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2133,6 +2133,14 @@ typedef enum { VIR_DOMAIN_MEMORY_MODEL_LAST } virDomainMemoryModel; =20 +typedef enum { + VIR_DOMAIN_MEMORY_PERSISTENCE_NONE, + VIR_DOMAIN_MEMORY_PERSISTENCE_MEMCTRL, + VIR_DOMAIN_MEMORY_PERSISTENCE_CPU, + + VIR_DOMAIN_MEMORY_PERSISTENCE_LAST, +} virDomainMemoryPersistence; + struct _virDomainMemoryDef { virDomainMemoryAccess access; virTristateBool discard; @@ -2141,12 +2149,17 @@ struct _virDomainMemoryDef { virBitmapPtr sourceNodes; unsigned long long pagesize; /* kibibytes */ char *nvdimmPath; + unsigned long long alignsize; /* kibibytes; valid only for NVDIMM */ + int nvdimmPmem; /* enum virTristateSwitch; valid only for NVDIMM */ =20 /* target */ int model; /* virDomainMemoryModel */ int targetNode; unsigned long long size; /* kibibytes */ unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */ + int nvdimmPersistence; /* enum virDomainMemoryPersistence; + valid only for NVDIMM*/ + int nvdimmUnarmed; /* enum virTristateSwitch; valid only for NVDIMM */ =20 virDomainDeviceInfo info; }; @@ -3448,6 +3461,7 @@ VIR_ENUM_DECL(virDomainTPMVersion) VIR_ENUM_DECL(virDomainMemoryModel) VIR_ENUM_DECL(virDomainMemoryBackingModel) VIR_ENUM_DECL(virDomainMemorySource) +VIR_ENUM_DECL(virDomainMemoryPersistence) VIR_ENUM_DECL(virDomainMemoryAllocation) VIR_ENUM_DECL(virDomainIOMMUModel) VIR_ENUM_DECL(virDomainVsockModel) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9236391..e925f7b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -436,6 +436,8 @@ virDomainMemoryFindByDef; virDomainMemoryFindInactiveByDef; virDomainMemoryInsert; virDomainMemoryModelTypeToString; +virDomainMemoryPersistenceTypeFromString; +virDomainMemoryPersistenceTypeToString; virDomainMemoryRemove; virDomainMemorySourceTypeFromString; virDomainMemorySourceTypeToString; 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/qemuxml2xmloutdata/memory-hotplug-nvdimm-persistence.xml= b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-persistence.xml new file mode 120000 index 0000000..0c0de1b --- /dev/null +++ b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-persistence.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/memory-hotplug-nvdimm-persistence.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-pmem.xml b/test= s/qemuxml2xmloutdata/memory-hotplug-nvdimm-pmem.xml new file mode 120000 index 0000000..3e57c1e --- /dev/null +++ b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-pmem.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/memory-hotplug-nvdimm-pmem.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-unarmed.xml b/t= ests/qemuxml2xmloutdata/memory-hotplug-nvdimm-unarmed.xml new file mode 120000 index 0000000..1793347 --- /dev/null +++ b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-unarmed.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 89640f6..4a931f2 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1089,6 +1089,10 @@ 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("memory-hotplug-nvdimm-pmem", NONE); + DO_TEST("memory-hotplug-nvdimm-persistence", NONE); + DO_TEST("memory-hotplug-nvdimm-unarmed", 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