]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf, docs, schema: Add support for 'restrictive' mode in numatune
authorLuyao Zhong <luyao.zhong@intel.com>
Tue, 13 Apr 2021 06:38:06 +0000 (14:38 +0800)
committerMartin Kletzander <mkletzan@redhat.com>
Mon, 19 Apr 2021 09:39:13 +0000 (11:39 +0200)
This allows users to restrict memory nodes without setting any specific
memory policy, then 'restrictive' mode is useful.

Signed-off-by: Luyao Zhong <luyao.zhong@intel.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 files changed:
docs/formatdomain.rst
docs/schemas/domaincommon.rng
include/libvirt/libvirt-domain.h
src/conf/numa_conf.c
src/qemu/qemu_command.c
src/util/virnuma.c
tests/qemuxml2argvdata/numatune-memnode-invalid-mode.err [new file with mode: 0644]
tests/qemuxml2argvdata/numatune-memnode-invalid-mode.xml [new file with mode: 0644]
tests/qemuxml2argvdata/numatune-memnode-restrictive-mode.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/numatune-memnode-restrictive-mode.x86_64-latest.xml [new symlink]
tests/qemuxml2xmltest.c

index d2344c894a777888583ff70cf7e418dc146320cb..4388ad545fe57f3d5c447d7a851d237eeb9d230e 100644 (file)
@@ -1112,8 +1112,11 @@ NUMA Node Tuning
 ``memory``
    The optional ``memory`` element specifies how to allocate memory for the
    domain process on a NUMA host. It contains several optional attributes.
-   Attribute ``mode`` is either 'interleave', 'strict', or 'preferred', defaults
-   to 'strict'. Attribute ``nodeset`` specifies the NUMA nodes, using the same
+   Attribute ``mode`` is either 'interleave', 'strict', 'preferred', or
+   'restrictive', defaults to 'strict'. The value 'restrictive' specifies
+   using system default policy and only cgroups is used to restrict the
+   memory nodes, and it requires setting mode to 'restrictive' in ``memnode``
+   elements. Attribute ``nodeset`` specifies the NUMA nodes, using the same
    syntax as attribute ``cpuset`` of element ``vcpu``. Attribute ``placement`` (
    :since:`since 0.9.12` ) can be used to indicate the memory placement mode for
    domain process, its value can be either "static" or "auto", defaults to
index 99cd873832340f4736404fe9565fa104b649533b..20a43148b102f6cc39dcf3e721522899a5bcaf9a 100644 (file)
                   <value>strict</value>
                   <value>preferred</value>
                   <value>interleave</value>
+                  <value>restrictive</value>
                 </choice>
               </attribute>
             </optional>
                 <value>strict</value>
                 <value>preferred</value>
                 <value>interleave</value>
+                <value>restrictive</value>
               </choice>
             </attribute>
             <attribute name="nodeset">
index 03c119fe268295ef68135f863ae75e25815b771b..e99bfb7654c50a5be0390b412f9e5d15bbad45c8 100644 (file)
@@ -1527,6 +1527,7 @@ typedef enum {
     VIR_DOMAIN_NUMATUNE_MEM_STRICT      = 0,
     VIR_DOMAIN_NUMATUNE_MEM_PREFERRED   = 1,
     VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE  = 2,
+    VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE = 3,
 
 # ifdef VIR_ENUM_SENTINELS
     VIR_DOMAIN_NUMATUNE_MEM_LAST /* This constant is subject to change */
index e28c86284f3877fc1f695b5ece8d0c37a8de6806..932af4a18595827975ad3bc6b94c217037a9ed5b 100644 (file)
@@ -43,6 +43,7 @@ VIR_ENUM_IMPL(virDomainNumatuneMemMode,
               "strict",
               "preferred",
               "interleave",
+              "restrictive",
 );
 
 VIR_ENUM_IMPL(virDomainNumatunePlacement,
@@ -230,6 +231,14 @@ virDomainNumatuneNodeParseXML(virDomainNuma *numa,
                                _("Invalid mode attribute in memnode element"));
                 goto cleanup;
             }
+
+            if (numa->memory.mode == VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE &&
+                mode != VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) {
+                virReportError(VIR_ERR_XML_ERROR, "%s",
+                               _("'restrictive' mode is required in memnode element "
+                                 "when mode is 'restrictive' in memory element"));
+                goto cleanup;
+            }
             VIR_FREE(tmp);
             mem_node->mode = mode;
         }
index 77d8e3f38cca51e7e2c869c8dd344cf4ebe4f20a..6d40983ce1ea9efc6fca0aef356c97de3f93bdc6 100644 (file)
@@ -175,6 +175,7 @@ VIR_ENUM_IMPL(qemuNumaPolicy,
               "bind",
               "preferred",
               "interleave",
+              "restrictive",
 );
 
 VIR_ENUM_DECL(qemuAudioDriver);
index 0c9599003a60518924918e854974e4ac692ab7d6..31f65d89022035ad59662727d4da31f2c600c51a 100644 (file)
@@ -152,6 +152,9 @@ virNumaSetupMemoryPolicy(virDomainNumatuneMemMode mode,
         numa_set_interleave_mask(&mask);
         break;
 
+    case VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE:
+        break;
+
     case VIR_DOMAIN_NUMATUNE_MEM_LAST:
         break;
     }
diff --git a/tests/qemuxml2argvdata/numatune-memnode-invalid-mode.err b/tests/qemuxml2argvdata/numatune-memnode-invalid-mode.err
new file mode 100644 (file)
index 0000000..180e64d
--- /dev/null
@@ -0,0 +1 @@
+XML error: 'restrictive' mode is required in memnode element when mode is 'restrictive' in memory element
diff --git a/tests/qemuxml2argvdata/numatune-memnode-invalid-mode.xml b/tests/qemuxml2argvdata/numatune-memnode-invalid-mode.xml
new file mode 100644 (file)
index 0000000..a7c18d4
--- /dev/null
@@ -0,0 +1,33 @@
+<domain type='qemu'>
+  <name>QEMUGuest</name>
+  <uuid>9f4b6512-e73a-4a25-93e8-5307802821ce</uuid>
+  <memory unit='KiB'>24682468</memory>
+  <currentMemory unit='KiB'>24682468</currentMemory>
+  <vcpu placement='static'>32</vcpu>
+  <numatune>
+    <memory mode='restrictive' nodeset='0-7'/>
+    <memnode cellid='0' mode='restrictive' nodeset='3'/>
+    <memnode cellid='2' mode='strict' nodeset='1-2,5-7,^6'/>
+  </numatune>
+  <os>
+    <type arch='x86_64' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu>
+    <numa>
+      <cell id='0' cpus='0' memory='20002' unit='KiB'/>
+      <cell id='1' cpus='1-27,29' memory='660066' unit='KiB'/>
+      <cell id='2' cpus='28,30-31' memory='24002400' 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-x86_64</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/numatune-memnode-restrictive-mode.xml b/tests/qemuxml2argvdata/numatune-memnode-restrictive-mode.xml
new file mode 100644 (file)
index 0000000..012c526
--- /dev/null
@@ -0,0 +1,41 @@
+<domain type='qemu'>
+  <name>QEMUGuest</name>
+  <uuid>9f4b6512-e73a-4a25-93e8-5307802821ce</uuid>
+  <memory unit='KiB'>24682468</memory>
+  <currentMemory unit='KiB'>24682468</currentMemory>
+  <vcpu placement='static'>32</vcpu>
+  <numatune>
+    <memory mode='restrictive' nodeset='0-7'/>
+    <memnode cellid='0' mode='restrictive' nodeset='3'/>
+    <memnode cellid='2' mode='restrictive' nodeset='1-2,5,7'/>
+  </numatune>
+  <os>
+    <type arch='x86_64' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu mode='custom' match='exact' check='none'>
+    <model fallback='forbid'>qemu64</model>
+    <numa>
+      <cell id='0' cpus='0' memory='20002' unit='KiB'/>
+      <cell id='1' cpus='1-27,29' memory='660066' unit='KiB'/>
+      <cell id='2' cpus='28,30-31' memory='24002400' 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-x86_64</emulator>
+    <controller type='usb' index='0' model='piix3-uhci'>
+      <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'/>
+    <audio id='1' type='none'/>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </memballoon>
+  </devices>
+</domain>
index 475a3dbdfcf89f46b6ca2dac0bd32ae6f78a04e2..e919bef9865076a0622e985001d7eabc3a157e99 100644 (file)
@@ -2171,6 +2171,7 @@ mymain(void)
     DO_TEST_PARSE_ERROR("numatune-memnode", NONE);
     DO_TEST_CAPS_VER("numatune-memnode", "5.2.0");
     DO_TEST_CAPS_LATEST("numatune-memnode");
+    DO_TEST_PARSE_ERROR("numatune-memnode-invalid-mode", NONE);
 
     DO_TEST("numatune-memnode-no-memory",
             QEMU_CAPS_NUMA,
diff --git a/tests/qemuxml2xmloutdata/numatune-memnode-restrictive-mode.x86_64-latest.xml b/tests/qemuxml2xmloutdata/numatune-memnode-restrictive-mode.x86_64-latest.xml
new file mode 120000 (symlink)
index 0000000..df405a8
--- /dev/null
@@ -0,0 +1 @@
+../qemuxml2argvdata/numatune-memnode-restrictive-mode.xml
\ No newline at end of file
index a5343cd6f8caa0f6b68cddfd8f3884ff51ff9a48..32b68fcfb0c05ddf34ed39c16af893ce06faa4ab 100644 (file)
@@ -1125,6 +1125,7 @@ mymain(void)
     DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST);
     DO_TEST("numatune-no-vcpu", QEMU_CAPS_NUMA);
     DO_TEST("numatune-hmat", QEMU_CAPS_NUMA_HMAT, QEMU_CAPS_OBJECT_MEMORY_RAM);
+    DO_TEST_CAPS_LATEST("numatune-memnode-restrictive-mode");
 
     DO_TEST("bios-nvram", NONE);
     DO_TEST("bios-nvram-os-interleave", NONE);