]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Introduce @access to <memory/>
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 1 Aug 2016 12:59:38 +0000 (14:59 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 15 Mar 2017 13:18:58 +0000 (14:18 +0100)
Now that NVDIMM has found its way into libvirt, users might want
to fine tune some settings for each module separately. One such
setting is 'share=on|off' for the memory-backend-file object.
This setting - just like its name suggest already - enables
sharing the nvdimm module with other applications. Under the hood
it controls whether qemu mmaps() the file as MAP_PRIVATE or
MAP_SHARED.

Yet again, we have such config knob in domain XML, but it's just
an attribute to numa <cell/>. This does not give fine enough
tuning on per-memdevice basis so we need to have the attribute
for each device too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nvdimm-access.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/qemuxml2xmlout-memory-hotplug-nvdimm-access.xml [new symlink]
tests/qemuxml2xmltest.c

index 0189920a84e7fa6e12a599c41431a9535a2cc922..a8a4191081da305c899a65c96a3b8466b5d87c40 100644 (file)
       <span class='since'>Since 1.2.9</span> the optional attribute
       <code>memAccess</code> can control whether the memory is to be
       mapped as "shared" or "private".  This is valid only for
-      hugepages-backed memory.
+      hugepages-backed memory and nvdimm modules.
     </p>
 
     <p>
@@ -7100,7 +7100,7 @@ qemu-kvm -net nic,model=? /dev/null
 <pre>
 ...
 &lt;devices&gt;
-  &lt;memory model='dimm'&gt;
+  &lt;memory model='dimm' access='private'&gt;
     &lt;target&gt;
       &lt;size unit='KiB'&gt;524287&lt;/size&gt;
       &lt;node&gt;0&lt;/node&gt;
@@ -7139,6 +7139,18 @@ qemu-kvm -net nic,model=? /dev/null
         </p>
       </dd>
 
+      <dt><code>access</code></dt>
+      <dd>
+        <p>
+          An optional attribute <code>access</code>
+          (<span class="since">since 3.2.0</span>) that provides
+          capability to fine tune mapping of the memory on per
+          module basis. Values are the same as
+          <a href="#elementsMemoryBacking">Memory Backing</a>:
+          <code>shared</code> and <code>private</code>.
+        </p>
+      </dd>
+
       <dt><code>source</code></dt>
       <dd>
         <p>
index 2f6a6db8e89eca50f7be4fe6f0c9a5a8d4be61b8..1b7b3c79386d234ddc38ac923521de7eec9d955a 100644 (file)
           <value>nvdimm</value>
         </choice>
       </attribute>
+      <optional>
+        <attribute name="access">
+          <choice>
+            <value>shared</value>
+            <value>private</value>
+          </choice>
+        </attribute>
+      </optional>
       <interleave>
         <optional>
           <ref name="memorydev-source"/>
index 9713bfc40239234109dd4e4b8e6c7f958b62dad3..7f6eeafbe637010892e3ff59b9633cab56d49689 100644 (file)
@@ -13821,6 +13821,15 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode,
     }
     VIR_FREE(tmp);
 
+    tmp = virXMLPropString(memdevNode, "access");
+    if (tmp &&
+        (def->access = virDomainMemoryAccessTypeFromString(tmp)) <= 0) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("invalid access mode '%s'"), tmp);
+        goto error;
+    }
+    VIR_FREE(tmp);
+
     /* source */
     if ((node = virXPathNode("./source", ctxt)) &&
         virDomainMemorySourceDefParseXML(node, ctxt, def) < 0)
@@ -22627,7 +22636,11 @@ virDomainMemoryDefFormat(virBufferPtr buf,
 {
     const char *model = virDomainMemoryModelTypeToString(def->model);
 
-    virBufferAsprintf(buf, "<memory model='%s'>\n", model);
+    virBufferAsprintf(buf, "<memory model='%s'", model);
+    if (def->access)
+        virBufferAsprintf(buf, " access='%s'",
+                          virDomainMemoryAccessTypeToString(def->access));
+    virBufferAddLit(buf, ">\n");
     virBufferAdjustIndent(buf, 2);
 
     if (virDomainMemorySourceDefFormat(buf, def) < 0)
index 2eff9f74a4f1bc265ae5d91469a8f61753dc7497..16e14321985090d82f77c494274df2f97ab84002 100644 (file)
@@ -2003,6 +2003,8 @@ typedef enum {
 } virDomainMemoryModel;
 
 struct _virDomainMemoryDef {
+    virDomainMemoryAccess access;
+
     /* source */
     virBitmapPtr sourceNodes;
     unsigned long long pagesize; /* kibibytes */
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nvdimm-access.xml b/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nvdimm-access.xml
new file mode 100644 (file)
index 0000000..700e961
--- /dev/null
@@ -0,0 +1,56 @@
+<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</emulator>
+    <disk type='block' device='disk'>
+      <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>
+      </target>
+      <address type='dimm' slot='0'/>
+    </memory>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-memory-hotplug-nvdimm-access.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-memory-hotplug-nvdimm-access.xml
new file mode 120000 (symlink)
index 0000000..898283a
--- /dev/null
@@ -0,0 +1 @@
+../qemuxml2argvdata/qemuxml2argv-memory-hotplug-nvdimm-access.xml
\ No newline at end of file
index e1c341dd5c918a6acc110fef9a046ab41609ec75..ef49a79ca5b371422923f9b764ca51f501390da9 100644 (file)
@@ -1079,6 +1079,7 @@ mymain(void)
     DO_TEST("memory-hotplug-nonuma", NONE);
     DO_TEST("memory-hotplug-dimm", NONE);
     DO_TEST("memory-hotplug-nvdimm", NONE);
+    DO_TEST("memory-hotplug-nvdimm-access", NONE);
     DO_TEST("net-udp", NONE);
 
     DO_TEST("video-virtio-gpu-device", NONE);