[PATCH v4 03/11] nvdimm: introduce 'unarmed' element into xml for NVDIMM memory

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

 



The 'unarmed' option allows users to mark vNVDIMM read-only:

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

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

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0f50da6..a8cf220 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -8331,6 +8331,7 @@ qemu-kvm -net nic,model=? /dev/null
       &lt;label&gt;
         &lt;size unit='KiB'&gt;128&lt;/size&gt;
       &lt;/label&gt;
+      &lt;unarmed/&gt;
     &lt;/target&gt;
   &lt;/memory&gt;
 &lt;/devices&gt;
@@ -8454,19 +8455,39 @@ qemu-kvm -net nic,model=? /dev/null
           NUMA nodes configured.
         </p>
         <p>
-          For NVDIMM type devices one can optionally use
-          <code>label</code> and its subelement <code>size</code>
-          to configure the size of namespaces label storage
-          within the NVDIMM module. The <code>size</code> element
-          has usual meaning described
-          <a href="#elementsMemoryAllocation">here</a>.
-          For QEMU domains the following restrictions apply:
+          Besides, the following optional elements can be provided as well for
+          NVDIMM type devices:
         </p>
-        <ol>
-          <li>the minimum label size is 128KiB,</li>
-          <li>the remaining size (total-size - label-size) has to be aligned to
-            4KiB</li>
-        </ol>
+
+        <dl>
+          <dt><code>label</code></dt>
+          <dd>
+            <p>
+              For NVDIMM type devices one can optionally use
+              <code>label</code> and its subelement <code>size</code>
+              to configure the size of namespaces label storage
+              within the NVDIMM module. The <code>size</code> element
+              has usual meaning described
+              <a href="#elementsMemoryAllocation">here</a>.
+              For QEMU domains the following restrictions apply:
+            </p>
+            <ol>
+              <li>the minimum label size is 128KiB,</li>
+              <li>the remaining size (total-size - label-size) will be aligned to
+                4KiB as default.</li>
+            </ol>
+          </dd>
+
+          <dt><code>unarmed</code></dt>
+          <dd>
+            <p>
+              The <code>unarmed</code> element can be used to mark vNVDIMM read-only.
+              Currently, only real NVDIMM device backend can guarantee the guest write
+              persistence, so please set <code>unarmed</code> when using other types
+              of backends. <span class="since">Since 5.0.0</span>
+            </p>
+          </dd>
+        </dl>
       </dd>
     </dl>
 
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 734589e..de098a5 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5422,6 +5422,11 @@
             </element>
           </element>
         </optional>
+        <optional>
+          <element name="unarmed">
+            <empty/>
+          </element>
+        </optional>
       </interleave>
     </element>
   </define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9edaf6d..ef7156d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15844,6 +15844,9 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node,
                            _("label size must be smaller than NVDIMM size"));
             goto cleanup;
         }
+
+        if (virXPathBoolean("boolean(./unarmed)", ctxt))
+            def->nvdimmUnarmed = true;
     }
 
     ret = 0;
@@ -22766,6 +22769,13 @@ virDomainMemoryDefCheckABIStability(virDomainMemoryDefPtr src,
                              "source NVDIMM pmem flag"));
             return false;
         }
+
+        if (src->nvdimmUnarmed != dst->nvdimmUnarmed) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("Target NVDIMM unarmed flag doesn't match "
+                             "source NVDIMM unarmed flag"));
+            return false;
+        }
     }
 
     return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info);
@@ -26344,6 +26354,8 @@ virDomainMemoryTargetDefFormat(virBufferPtr buf,
         virBufferAdjustIndent(buf, -2);
         virBufferAddLit(buf, "</label>\n");
     }
+    if (def->nvdimmUnarmed)
+        virBufferAddLit(buf, "<unarmed/>\n");
 
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</target>\n");
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a63afdc..8538d89 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2155,6 +2155,7 @@ struct _virDomainMemoryDef {
     int targetNode;
     unsigned long long size; /* kibibytes */
     unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */
+    bool nvdimmUnarmed; /* valid only for NVDIMM */
 
     virDomainDeviceInfo info;
 };
diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-pmem.xml b/tests/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/tests/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 ef3ece8..493ce1d 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1118,6 +1118,7 @@ mymain(void)
     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-unarmed", 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



[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