[virt-tools-list] [virt-manager PATCH] cli: Add --numatune options memnode[0-9]*.cellid, memnode[0-9]*.mode, memnode[0-9]*.nodeset

Athina Plaskasoviti athina.plaskasoviti at gmail.com
Mon Jun 17 19:32:54 UTC 2019


XML Mapping:

<numatune>
...
  <memnode cellid="X" mode="X" nodeset="X"/>
...
</numatune>

Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti at gmail.com>
---
 .../compare/virt-install-singleton-config-2.xml   |  2 ++
 tests/clitest.py                                  |  3 ++-
 virtinst/cli.py                                   | 13 +++++++++++++
 virtinst/domain/numatune.py                       | 15 +++++++++++++--
 4 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml b/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
index 5cfb469d..04f720cd 100644
--- a/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
+++ b/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
@@ -44,6 +44,7 @@
   <vcpu>9</vcpu>
   <numatune>
     <memory mode="strict" nodeset="1-3,4"/>
+    <memnode cellid="1" mode="strict" nodeset="2"/>
   </numatune>
   <resource>
     <partition>/virtualmachines/production</partition>
@@ -258,6 +259,7 @@
   <vcpu>9</vcpu>
   <numatune>
     <memory mode="strict" nodeset="1-3,4"/>
+    <memnode cellid="1" mode="strict" nodeset="2"/>
   </numatune>
   <resource>
     <partition>/virtualmachines/production</partition>
diff --git a/tests/clitest.py b/tests/clitest.py
index 4d2eff3b..ef09491f 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -511,7 +511,8 @@ cache.mode=emulate,cache.level=3
 --idmap uid_start=0,uid_target=1000,uid_count=10,gid_start=0,gid_target=1000,gid_count=10
 --seclabel type=static,label='system_u:object_r:svirt_image_t:s0:c100,c200',relabel=yes,baselabel=baselabel
 --seclabel type=dynamic,label=012:345
---numatune 1-3,4,mode=strict
+--numatune 1-3,4,mode=strict,\
+memnode0.cellid=1,memnode0.mode=strict,memnode0.nodeset=2
 --memtune hard_limit=10,soft_limit=20,swap_hard_limit=30,min_guarantee=40
 --blkiotune weight=100,device_path=/home/test/1.img,device_weight=200
 --memorybacking size=1,unit='G',nodeset=0,1,nosharepages=yes,locked=yes,discard=yes,allocation.mode=immediate,access_mode=shared,source_type=file,hugepages.page.size=12,hugepages.page1.size=1234,hugepages.page1.unit=MB,hugepages.page1.nodeset=2
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 4b985097..97a6fc81 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -1737,6 +1737,12 @@ class ParserNumatune(VirtCLIParser):
         "memory.nodeset": "nodeset",
     }
 
+    def memnode_find_inst_cb(self, *args, **kwargs):
+        cliarg = "memnode"  # memnode[0-9]*
+        list_propname = "memnode"
+        cb = self._make_find_inst_cb(cliarg, list_propname)
+        return cb(*args, **kwargs)
+
     @classmethod
     def _init_class(cls, **kwargs):
         VirtCLIParser._init_class(**kwargs)
@@ -1744,6 +1750,13 @@ class ParserNumatune(VirtCLIParser):
         cls.add_arg("memory.mode", "memory_mode")
         cls.add_arg("memory.placement", "memory_placement")
 
+        cls.add_arg("memnode[0-9]*.cellid", "cellid", can_comma=True,
+                find_inst_cb=cls.memnode_find_inst_cb)
+        cls.add_arg("memnode[0-9]*.mode", "mode",
+                find_inst_cb=cls.memnode_find_inst_cb)
+        cls.add_arg("memnode[0-9]*.nodeset", "nodeset", can_comma=True,
+                find_inst_cb=cls.memnode_find_inst_cb)
+
 
 ####################
 # --memory parsing #
diff --git a/virtinst/domain/numatune.py b/virtinst/domain/numatune.py
index 5a7d743e..5f36fe51 100644
--- a/virtinst/domain/numatune.py
+++ b/virtinst/domain/numatune.py
@@ -4,7 +4,17 @@
 # This work is licensed under the GNU GPLv2 or later.
 # See the COPYING file in the top-level directory.
 
-from ..xmlbuilder import XMLBuilder, XMLProperty
+from ..xmlbuilder import XMLBuilder, XMLProperty, XMLChildProperty
+
+
+class _Numatune(XMLBuilder):
+
+    XML_NAME = "memnode"
+    _XML_PROP_ORDER = ["cellid", "mode", "nodeset"]
+
+    cellid = XMLProperty("./@cellid", is_int=True)
+    mode = XMLProperty("./@mode")
+    nodeset = XMLProperty("./@nodeset")
 
 
 class DomainNumatune(XMLBuilder):
@@ -12,8 +22,9 @@ class DomainNumatune(XMLBuilder):
     Class for generating <numatune> XML
     """
     XML_NAME = "numatune"
-    _XML_PROP_ORDER = ["memory_mode", "memory_nodeset", "memory_placement"]
+    _XML_PROP_ORDER = ["memory_mode", "memory_nodeset", "memory_placement", "memnode"]
 
     memory_nodeset = XMLProperty("./memory/@nodeset")
     memory_mode = XMLProperty("./memory/@mode")
     memory_placement = XMLProperty("./memory/@placement")
+    memnode = XMLChildProperty(_Numatune)
-- 
2.20.1




More information about the virt-tools-list mailing list