From 0e4ca433110efa286285d442fb531ba046b16bc9 Mon Sep 17 00:00:00 2001 From: LuyaoZhong Date: Thu, 5 Sep 2019 06:41:04 +0000 Subject: [PATCH] libvirt: Enable driver configuring PMEM namespaces Add one configuration option CONF.libvirt.pmem_namespaces: "$LABEL:$NSNAME[|$NSNAME][,$LABEL:$NSNAME[|$NSNAME]]" e.g. "128G:ns0|ns1|ns2|ns3,262144MB:ns4|ns5,MEDIUM:ns6|ns7" Change-Id: I98e5ddbd7a9f2211a16221b5049bc36452a49a75 Partially-Implements: blueprint virtual-persistent-memory Co-Authored-By: He Jie Xu --- nova/conf/libvirt.py | 27 +++++++++++++++++++ nova/virt/libvirt/driver.py | 3 ++- ...rt-for-vpmem-libvirt-8b66add5b2d8f5f5.yaml | 24 +++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/add-support-for-vpmem-libvirt-8b66add5b2d8f5f5.yaml diff --git a/nova/conf/libvirt.py b/nova/conf/libvirt.py index d141594d93..0ee880af47 100644 --- a/nova/conf/libvirt.py +++ b/nova/conf/libvirt.py @@ -1335,6 +1335,32 @@ maximum number of retry attempts that can be made to discover the NVMe device. """), ] + +libvirt_pmem_opts = [ + cfg.ListOpt('pmem_namespaces', + item_type=cfg.types.String(), + default=[], + help=""" +Configure persistent memory(pmem) namespaces. + +These namespaces must have been already created on the host. This config +option is in the following format:: + + "$LABEL:$NSNAME[|$NSNAME][,$LABEL:$NSNAME[|$NSNAME]]" + +* ``$NSNAME`` is the name of the pmem namespace. +* ``$LABEL`` represents one resource class, this is used to generate + the resource class name as ``CUSTOM_PMEM_NAMESPACE_$LABEL``. + +For example:: + + [libvirt] + pmem_namespaces=128G:ns0|ns1|ns2|ns3,262144MB:ns4|ns5,MEDIUM:ns6|ns7 + +"""), +] + + ALL_OPTS = list(itertools.chain( libvirt_general_opts, libvirt_imagebackend_opts, @@ -1354,6 +1380,7 @@ ALL_OPTS = list(itertools.chain( libvirt_volume_vzstorage_opts, libvirt_virtio_queue_sizes, libvirt_volume_nvmeof_opts, + libvirt_pmem_opts, )) diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index ed31c5c024..c9d5d3c67b 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -435,7 +435,8 @@ class LibvirtDriver(driver.ComputeDriver): self.cpu_models_mapping = {} self.cpu_model_flag_mapping = {} - self._vpmems_by_name, self._vpmems_by_rc = self._discover_vpmems() + self._vpmems_by_name, self._vpmems_by_rc = self._discover_vpmems( + vpmem_conf=CONF.libvirt.pmem_namespaces) def _discover_vpmems(self, vpmem_conf=None): """Discover vpmems on host and configuration. diff --git a/releasenotes/notes/add-support-for-vpmem-libvirt-8b66add5b2d8f5f5.yaml b/releasenotes/notes/add-support-for-vpmem-libvirt-8b66add5b2d8f5f5.yaml new file mode 100644 index 0000000000..c9e9975c6c --- /dev/null +++ b/releasenotes/notes/add-support-for-vpmem-libvirt-8b66add5b2d8f5f5.yaml @@ -0,0 +1,24 @@ +--- +features: + - | + The libvirt driver now supports booting instances with virtual persistent + memory (vPMEM), also called persistent memory (PMEM) namespaces. + To enable vPMEM support, the user should specify the PMEM namespaces + in the ``nova.conf`` by using the configuration option + ``[libvirt]/pmem_namespaces``. For example:: + + [libvirt] + # pmem_namespaces=$LABEL:$NSNAME[|$NSNAME][,$LABEL:$NSNAME[|$NSNAME]] + pmem_namespaces = 128G:ns0|ns1|ns2|ns3,262144MB:ns4|ns5,MEDIUM:ns6|ns7 + + Only PMEM namespaces listed in the configuration file can be used by + instances. To identify the available PMEM namespaces on the host or create + new namespaces, the ``ndctl`` utility can be used:: + + ndctl create-namespace -m devdax -s $SIZE -M mem -n $NSNAME + + Nova will invoke this utility to identify available PMEM namespaces. + Then users can specify vPMEM resources in a flavor by adding flavor's + extra specs:: + + openstack flavor set --property hw:pmem=6GB,64GB