Re: [PATCH v4 02/11] nvdimm: introduce 'pmem' element into xml for NVDIMM memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2018/12/17 下午7:05, Daniel P. Berrangé wrote:
On Mon, Dec 17, 2018 at 05:26:12PM +0800, Luyao Zhong wrote:
The 'pmem' option allows users to specify whether the backend
storage of memory-backend-file is a real persistent memory:

What does this actually do in practice ?  Why does it matter and if it
does, why can't libvirt set the right value automatically instad of
needing the user to set the XML.

When 'pmem' is 'on' and QEMU is built with libpmem [2] support (configured with --enable-libpmem), QEMU will take necessary operations to guarantee the persistence of its own writes to the vNVDIMM backend.If 'pmem' is 'on' while there is no libpmem support, qemu will exit and report a "lack of libpmem support" message to ensure the persistence is available.

So user must have some knowledge about QEMU, also NVDIMM, then they can use this option correctly.

<devices>
   ...
   <memory model='nvdimm' access='shared'>
       <source>
           <path>/dev/dax0.0</path>
           <pmem/>
       </source>
       <target>
           <size unit='MiB'>4094</size>
           <node>0</node>
           <label>
               <size unit='MiB'>2</size>
           </label>
       </target>
   </memory>
   ...
</devices>

Signed-off-by: Luyao Zhong <luyao.zhong@xxxxxxxxx>
---
  docs/formatdomain.html.in                          | 12 +++++
  docs/schemas/domaincommon.rng                      |  5 ++
  src/conf/domain_conf.c                             | 13 +++++
  src/conf/domain_conf.h                             |  1 +
  .../memory-hotplug-nvdimm-pmem.xml                 | 58 ++++++++++++++++++++++
  .../memory-hotplug-nvdimm-unarmed.xml              | 58 ++++++++++++++++++++++
  tests/qemuxml2xmltest.c                            |  1 +
  7 files changed, 148 insertions(+)
  create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.xml
  create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 74e02a4..0f50da6 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -8323,6 +8323,7 @@ qemu-kvm -net nic,model=? /dev/null
      &lt;source&gt;
        &lt;path&gt;/tmp/nvdimm&lt;/path&gt;
        &lt;alignsize unit='KiB'&gt;2048&lt;/alignsize&gt;
+      &lt;pmem/&gt;
      &lt;/source&gt;
      &lt;target&gt;
        &lt;size unit='KiB'&gt;524288&lt;/size&gt;
@@ -8423,6 +8424,17 @@ qemu-kvm -net nic,model=? /dev/null
                <span class="since">Since 5.0.0</span>
              </p>
            </dd>
+
+          <dt><code>pmem</code></dt>
+          <dd>
+            <p>
+              This element can be used to specify whether the backend storage
+              of memory-backend-file is a real persistent memory. If the
+              backend is a real persistence memory and <code>pmem</code> is set,
+              QEMU will guarantee the persistence of its own writes to the
+              vNVDIMM backend. <span class="since">Since 5.0.0</span>
+            </p>
+          </dd>
          </dl>
        </dd>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 395a7ea..734589e 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5393,6 +5393,11 @@
                  <ref name="scaledInteger"/>
                </element>
              </optional>
+            <optional>
+              <element name="pmem">
+                <empty/>
+              </element>
+            </optional>
            </interleave>
          </group>
        </choice>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7e59d8c..9edaf6d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15785,6 +15785,9 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node,
                                   &def->alignsize, false, false) < 0)
              goto cleanup;
+ if (virXPathBoolean("boolean(./pmem)", ctxt))
+            def->nvdimmPmem = true;
+
          break;
case VIR_DOMAIN_MEMORY_MODEL_NONE:
@@ -22756,6 +22759,13 @@ virDomainMemoryDefCheckABIStability(virDomainMemoryDefPtr src,
                             src->alignsize, dst->alignsize);
              return false;
          }
+
+        if (src->nvdimmPmem != dst->nvdimmPmem) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("Target NVDIMM pmem flag doesn't match "
+                             "source NVDIMM pmem flag"));
+            return false;
+        }
      }
return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info);
@@ -26296,6 +26306,9 @@ virDomainMemorySourceDefFormat(virBufferPtr buf,
          if (def->alignsize)
              virBufferAsprintf(buf, "<alignsize unit='KiB'>%llu</alignsize>\n",
                                def->alignsize);
+
+        if (def->nvdimmPmem)
+            virBufferAddLit(buf, "<pmem/>\n");
          break;
case VIR_DOMAIN_MEMORY_MODEL_NONE:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 848bd94..a63afdc 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2148,6 +2148,7 @@ struct _virDomainMemoryDef {
      unsigned long long pagesize; /* kibibytes */
      char *nvdimmPath;
      unsigned long long alignsize; /* kibibytes; valid only for NVDIMM */
+    bool nvdimmPmem; /* valid only for NVDIMM */
/* target */
      int model; /* virDomainMemoryModel */
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.xml b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.xml
new file mode 100644
index 0000000..060d75c
--- /dev/null
+++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.xml
@@ -0,0 +1,58 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <maxMemory slots='16' unit='KiB'>1099511627776</maxMemory>
+  <memory unit='KiB'>1267710</memory>
+  <currentMemory unit='KiB'>1267710</currentMemory>
+  <vcpu placement='static' cpuset='0-1'>2</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <idmap>
+    <uid start='0' target='1000' count='10'/>
+    <gid start='0' target='1000' count='10'/>
+  </idmap>
+  <cpu>
+    <topology sockets='2' cores='1' threads='1'/>
+    <numa>
+      <cell id='0' cpus='0-1' memory='219136' unit='KiB'/>
+    </numa>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </memballoon>
+    <memory model='nvdimm' access='private'>
+      <source>
+        <path>/tmp/nvdimm</path>
+        <pmem/>
+      </source>
+      <target>
+        <size unit='KiB'>523264</size>
+        <node>0</node>
+      </target>
+      <address type='dimm' slot='0'/>
+    </memory>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.xml b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.xml
new file mode 100644
index 0000000..7ddbb01
--- /dev/null
+++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.xml
@@ -0,0 +1,58 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <maxMemory slots='16' unit='KiB'>1099511627776</maxMemory>
+  <memory unit='KiB'>1267710</memory>
+  <currentMemory unit='KiB'>1267710</currentMemory>
+  <vcpu placement='static' cpuset='0-1'>2</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <idmap>
+    <uid start='0' target='1000' count='10'/>
+    <gid start='0' target='1000' count='10'/>
+  </idmap>
+  <cpu>
+    <topology sockets='2' cores='1' threads='1'/>
+    <numa>
+      <cell id='0' cpus='0-1' memory='219136' unit='KiB'/>
+    </numa>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </memballoon>
+    <memory model='nvdimm' access='private'>
+      <source>
+        <path>/tmp/nvdimm</path>
+      </source>
+      <target>
+        <size unit='KiB'>523264</size>
+        <node>0</node>
+        <unarmed/>
+      </target>
+      <address type='dimm' slot='0'/>
+    </memory>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 5161f4a..ef3ece8 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1117,6 +1117,7 @@ mymain(void)
      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("net-udp", NONE);
DO_TEST("video-virtio-gpu-device", NONE);
--
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

Regards,
Daniel

Thanks,
Luyao

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux