[libvirt] [PATCH 3/3] tests: add numa -memdev testing and docs support

Chen Fan chen.fan.fnst at cn.fujitsu.com
Wed Jun 25 06:42:32 UTC 2014


Signed-off-by: Chen Fan <chen.fan.fnst at cn.fujitsu.com>
---
 docs/formatdomain.html.in                          | 71 +++++++++++++++++++-
 docs/schemas/domaincommon.rng                      | 76 +++++++++++++++++++++-
 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.args |  9 +++
 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.xml  | 35 ++++++++++
 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.args | 10 +++
 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.xml  | 35 ++++++++++
 tests/qemuxml2argvtest.c                           |  2 +
 7 files changed, 233 insertions(+), 5 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 1b6ced8..5313c76 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1032,6 +1032,9 @@
     <numa>
       <cell cpus='0-3' memory='512000'/>
       <cell cpus='4-7' memory='512000'/>
+      <!-- OR -->
+      <cell cpus='0-3' memdev='ram0'/>
+      <cell cpus='4-7' memdev='ram1'/>
     </numa>
     ...
   </cpu>
@@ -1041,8 +1044,11 @@
       Each <code>cell</code> element specifies a NUMA cell or a NUMA node.
       <code>cpus</code> specifies the CPU or range of CPUs that are part of
       the node. <code>memory</code> specifies the node memory in kibibytes
-      (i.e. blocks of 1024 bytes). Each cell or node is assigned cellid
-      or nodeid in the increasing order starting from 0.
+      (i.e. blocks of 1024 bytes). <span class="since">Since 2.1</span>,
+      <code>memdev</code> specifies the Host NUMA node that the Guest NUMA
+      node bind to. if <code>memdev</code> specified for one node, it must
+      be specified for all nodes. Each cell or node is assigned cellid or
+      nodeid in the increasing order starting from 0.
     </p>
 
     <p>
@@ -5249,6 +5255,67 @@ qemu-kvm -net nic,model=? /dev/null
     </dd>
   </dl>
 
+    <h4><a name="elementsMemdev">memory device</a></h4>
+    <p>
+      A memory device can be added to guest via memdev element.
+      <span class="since">Since 2.1, QEMU and KVM only</span>
+    </p>
+    <p>
+      Example: usage of memory device configuration
+    </p>
+<pre>
+  ...
+  <devices>
+    <memdev type='ram' merge='yes' dump='yes' prealloc='yes'>
+      <name>ram0</name>
+      <capacity unit='KiB'>102400</capacity>
+      <source host-nodes='0-1' policy='bind'/>
+    </memdev>
+  </devices>
+  ...
+</pre>
+  <dl>
+    <dt><code>type</code></dt>
+    <dd>
+      <p>
+        The required type attribute specifies what type of memory device
+        is provided. Valid type are:
+      </p>
+        <ul>
+          <li>'ram' — memory ram backend.</li>
+          <li>'file' — memory file backend.</li>
+        </ul>
+    </dd>
+    <dt><code>merge</code></dt>
+    <dd>
+      <p>
+        The optional merge attribute enables memory merge support.
+      </p>
+    </dd>
+    <dt><code>dump</code></dt>
+    <dd>
+      <p>
+        The optional dump attribute enables to dump memory device's memory in a
+        core dump file.
+      </p>
+    </dd>
+    <dt><code>prealloc</code></dt>
+    <dd>
+      <p>
+        The optional prealloc attribute enables memory preallocation.
+      </p>
+    </dd>
+     <dt><code>source</code></dt>
+      <dd>The source element describes the device as seen from the host.
+      the optional <code>mem-path</code> element is required when specified type = 'file'.
+      the optional <code>host-nodes</code> element specified the Host nodes ids that the
+      Guest memory device binds to. the optional <code>policy</code> element specified the
+      memory policy of memory device. the <code>policy</code> is either "default", "preferred",
+      "bind", "interleave". defaults to "default".
+      </dd>
+  </dl>
+
+
     <h3><a name="seclabel">Security label</a></h3>
 
     <p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 6cc922c..0334b28 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3148,6 +3148,32 @@
       </optional>
     </element>
   </define>
+  <define name="memdev">
+    <element name="memdev">
+      <attribute name="type">
+        <choice>
+           <value>ram</value>
+           <value>file</value>
+        </choice>
+      </attribute>
+      <optional>
+        <attribute name='merge'>
+          <value>yes</value>
+        </attribute>
+      </optional>
+      <optional>
+        <attribute name='dump'>
+          <value>yes</value>
+        </attribute>
+      </optional>
+      <optional>
+        <attribute name='prealloc'>
+          <value>yes</value>
+        </attribute>
+      </optional>
+      <ref name="memorybackend"/>
+    </element>
+  </define>
   <define name="parallel">
     <element name="parallel">
       <ref name="qemucdev"/>
@@ -3671,6 +3697,7 @@
             <ref name="redirfilter"/>
             <ref name="rng"/>
             <ref name="tpm"/>
+            <ref name="memdev"/>
           </choice>
         </zeroOrMore>
         <optional>
@@ -3895,9 +3922,18 @@
       <attribute name="cpus">
         <ref name="cpuset"/>
       </attribute>
-      <attribute name="memory">
-        <ref name="memoryKB"/>
-      </attribute>
+      <choice>
+        <group>
+          <attribute name="memory">
+            <ref name="memoryKB"/>
+          </attribute>
+        </group>
+        <group>
+          <attribute name='memdev'>
+            <ref name='aliasName'/>
+          </attribute>
+        </group>
+      </choice>
     </element>
   </define>
 
@@ -4527,6 +4563,40 @@
     </element>
     <empty/>
   </define>
+  <define name='memorybackend'>
+    <element name='name'>
+      <ref name='aliasName'/>
+    </element>
+    <element name='capacity'>
+      <ref name='scaledInteger'/>
+    </element>
+    <optional>
+      <element name='source'>
+        <optional>
+          <attribute name='mem-path'>
+            <ref name='absFilePath'/>
+          </attribute>
+        </optional>
+        <optional>
+          <attribute name='host-nodes'>
+            <data type="string">
+              <param name='pattern'>[a-zA-Z0-9\-_]+</param>
+            </data>
+          </attribute>
+        </optional>
+        <optional>
+          <attribute name='policy'>
+            <choice>
+               <value>default</value>
+               <value>preferred</value>
+               <value>bind</value>
+               <value>interleave</value>
+             </choice>
+          </attribute>
+        </optional>
+      </element>
+    </optional>
+  </define>
   <define name="ccwCssidRange">
     <choice>
       <data type="string">
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.args
new file mode 100644
index 0000000..1057adc
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.args
@@ -0,0 +1,9 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc \
+-m 214 \
+-object memory-backend-ram,id=ram0,size=109568K,merge=yes,dump=yes,prealloc=yes,host-nodes=0,policy=bind \
+-object memory-backend-ram,id=ram1,size=109568K,host-nodes=0,policy=bind \
+-smp 16 -numa node,nodeid=0,cpus=0-7,memdev=ram0 \
+-numa node,nodeid=1,cpus=8-15,memdev=ram1 -nographic -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -usb -net none -serial none \
+-parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.xml
new file mode 100644
index 0000000..7a299af
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.xml
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>16</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc'>hvm</type>
+    <boot dev='network'/>
+  </os>
+  <cpu>
+    <topology sockets="2" cores="4" threads="2"/>
+    <numa>
+      <cell cpus="0-7" memdev="ram0"/>
+      <cell cpus="8-15" memdev="ram1"/>
+    </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>
+    <memdev type='ram' merge='yes' dump='yes' prealloc='yes'>
+      <name>ram0</name>
+      <capacity unit='KiB'>109550</capacity>
+      <source host-nodes='0' policy='bind'/>
+    </memdev>
+    <memdev type='ram'>
+      <name>ram1</name>
+      <capacity unit='KiB'>109550</capacity>
+      <source host-nodes='0' policy='bind'/>
+    </memdev>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.args
new file mode 100644
index 0000000..3a1cd94
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.args
@@ -0,0 +1,10 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc \
+-m 214 \
+-object memory-backend-file,id=ram0,size=109568K,merge=yes,dump=yes,prealloc=yes,mem-path=/hugepages,\
+host-nodes=0,policy=bind \
+-object memory-backend-file,id=ram1,size=109568K,mem-path=/hugepages,host-nodes=0,policy=bind \
+-smp 16 -numa node,nodeid=0,cpus=0-7,memdev=ram0 \
+-numa node,nodeid=1,cpus=8-15,memdev=ram1 -nographic -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -usb -net none -serial none \
+-parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.xml
new file mode 100644
index 0000000..03e3a28
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.xml
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>16</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc'>hvm</type>
+    <boot dev='network'/>
+  </os>
+  <cpu>
+    <topology sockets="2" cores="4" threads="2"/>
+    <numa>
+      <cell cpus="0-7" memdev="ram0"/>
+      <cell cpus="8-15" memdev="ram1"/>
+    </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>
+    <memdev type='file' merge='yes' dump='yes' prealloc='yes'>
+      <name>ram0</name>
+      <capacity unit='KiB'>109550</capacity>
+      <source mem-path='/hugepages' host-nodes='0' policy='bind'/>
+    </memdev>
+    <memdev type='file'>
+      <name>ram1</name>
+      <capacity unit='KiB'>109550</capacity>
+      <source mem-path='/hugepages' host-nodes='0' policy='bind'/>
+    </memdev>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 24d104e..1b9e48a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1169,6 +1169,8 @@ mymain(void)
     DO_TEST("cpu-strict1", NONE);
     DO_TEST("cpu-numa1", NONE);
     DO_TEST("cpu-numa2", QEMU_CAPS_SMP_TOPOLOGY);
+    DO_TEST("cpu-numa3", QEMU_CAPS_MEMORY_BACKEND_RAM);
+    DO_TEST("cpu-numa4", QEMU_CAPS_MEMORY_BACKEND_FILE);
     DO_TEST("cpu-host-model", NONE);
     skipLegacyCPUs = true;
     DO_TEST("cpu-host-model-fallback", NONE);
-- 
1.9.3




More information about the libvir-list mailing list