[virt-tools-list] [virt-manager PATCH] cli: Add --cputune cachetune options

athina.plaskasoviti at gmail.com athina.plaskasoviti at gmail.com
Fri Aug 9 09:14:05 UTC 2019


From: Athina Plaskasoviti <athina.plaskasoviti at gmail.com>

- cachetune[0-9]*.vcpus
- cachetune[0-9]*.cache[0-9]*.level
- cachetune[0-9]*.cache[0-9]*.id
- cachetune[0-9]*.cache[0-9]*.type
- cachetune[0-9]*.cache[0-9]*.size
- cachetune[0-9]*.cache[0-9]*.unit

XML Mapping:

<domain>
...
  <cputune>
  ...
    <cachetune vcpus="X">
      <cache level="X" id="X" type="X" size="X" unit="X"/>
    </cachetune>
  ...
  </cputune>
...
</domain>

Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti at gmail.com>
---
 .../virt-install-singleton-config-2.xml       |  6 ++++
 tests/clitest.py                              |  2 +-
 virtinst/cli.py                               | 27 ++++++++++++++++++
 virtinst/domain/cputune.py                    | 28 +++++++++++++++++++
 4 files changed, 62 insertions(+), 1 deletion(-)

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 0d202de8..000c94c0 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
@@ -217,6 +217,9 @@
   <on_lockfailure>ignore</on_lockfailure>
   <cputune>
     <vcpupin vcpu="0" cpuset="0-3"/>
+    <cachetune vcpus="0-3">
+      <cache level="3" id="0" type="both" size="3" unit="MiB"/>
+    </cachetune>
   </cputune>
 </domain>
 <domain type="kvm">
@@ -441,5 +444,8 @@
   <on_lockfailure>ignore</on_lockfailure>
   <cputune>
     <vcpupin vcpu="0" cpuset="0-3"/>
+    <cachetune vcpus="0-3">
+      <cache level="3" id="0" type="both" size="3" unit="MiB"/>
+    </cachetune>
   </cputune>
 </domain>
diff --git a/tests/clitest.py b/tests/clitest.py
index 6818612d..06c580dc 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -513,7 +513,7 @@ cell0.distances.sibling1.id=1,cell0.distances.sibling1.value=21,\
 numa.cell1.distances.sibling0.id=0,numa.cell1.distances.sibling0.value=21,\
 cell1.distances.sibling1.id=1,cell1.distances.sibling1.value=10,\
 cache.mode=emulate,cache.level=3
---cputune vcpupin0.vcpu=0,vcpupin0.cpuset=0-3
+--cputune vcpupin0.vcpu=0,vcpupin0.cpuset=0-3,cachetune0.vcpus=0-3,cachetune0.cache0.level=3,cachetune0.cache0.id=0,cachetune0.cache0.type=both,cachetune0.cache0.size=3,cachetune0.cache0.unit=MiB
 --iothreads iothreads=2,iothreadids.iothread1.id=1,iothreadids.iothread2.id=2
 --metadata title=my-title,description=my-description,uuid=00000000-1111-2222-3333-444444444444,genid=e9392370-2917-565e-692b-d057f46512d6
 --boot cdrom,fd,hd,network,menu=off,loader=/foo/bar,emulator=/new/emu,bootloader=/new/bootld,rebootTimeout=3,initargs="foo=bar baz=woo",initdir=/my/custom/cwd,inituser=tester,initgroup=1000,firmware=efi
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 0affe513..6caab475 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -2097,6 +2097,21 @@ class ParserCputune(VirtCLIParser):
         cb = self._make_find_inst_cb(cliarg, list_propname)
         return cb(*args, **kwargs)
 
+    def cachetune_find_inst_cb(self, *args, **kwargs):
+        cliarg = "cachetune"  # cachetune[0-9]*
+        list_propname = "cachetune"
+        cb = self._make_find_inst_cb(cliarg, list_propname)
+        return cb(*args, **kwargs)
+
+    def cache_find_inst_cb(self, inst, *args, **kwargs):
+        cachetune = self.cachetune_find_inst_cb(inst, *args, **kwargs)
+        inst = cachetune
+
+        cliarg = "cache"  # cachetune[0-9]*.cache[0-9]*
+        list_propname = "caches"  # cachetune.caches
+        cb = self._make_find_inst_cb(cliarg, list_propname)
+        return cb(inst, *args, **kwargs)
+
     @classmethod
     def _init_class(cls, **kwargs):
         VirtCLIParser._init_class(**kwargs)
@@ -2105,6 +2120,18 @@ class ParserCputune(VirtCLIParser):
                     find_inst_cb=cls.vcpu_find_inst_cb)
         cls.add_arg("vcpupin[0-9]*.cpuset", "cpuset", can_comma=True,
                     find_inst_cb=cls.vcpu_find_inst_cb)
+        cls.add_arg("cachetune[0-9]*.vcpus", "vcpus",
+                    find_inst_cb=cls.cachetune_find_inst_cb)
+        cls.add_arg("cachetune[0-9]*.cache[0-9]*.level", "level",
+                    find_inst_cb=cls.cache_find_inst_cb)
+        cls.add_arg("cachetune[0-9]*.cache[0-9]*.id", "id",
+                    find_inst_cb=cls.cache_find_inst_cb)
+        cls.add_arg("cachetune[0-9]*.cache[0-9]*.type", "type",
+                    find_inst_cb=cls.cache_find_inst_cb)
+        cls.add_arg("cachetune[0-9]*.cache[0-9]*.size", "size",
+                    find_inst_cb=cls.cache_find_inst_cb)
+        cls.add_arg("cachetune[0-9]*.cache[0-9]*.unit", "unit",
+                    find_inst_cb=cls.cache_find_inst_cb)
 
 
 #######################
diff --git a/virtinst/domain/cputune.py b/virtinst/domain/cputune.py
index 67a76476..4d761ebf 100644
--- a/virtinst/domain/cputune.py
+++ b/virtinst/domain/cputune.py
@@ -17,9 +17,37 @@ class _VCPUPin(XMLBuilder):
     cpuset = XMLProperty("./@cpuset")
 
 
+class _CacheCPU(XMLBuilder):
+    """
+    Class for generating <cachetune> child <cache> XML
+    """
+    XML_NAME = "cache"
+    _XML_PROP_ORDER = ["level", "id", "type", "size", "unit"]
+
+    level = XMLProperty("./@level", is_int=True)
+    id = XMLProperty("./@id", is_int=True)
+    type = XMLProperty("./@type")
+    size = XMLProperty("./@size", is_int=True)
+    unit = XMLProperty("./@unit")
+
+
+class _CacheTuneCPU(XMLBuilder):
+    """
+    Class for generating <cputune> child <cachetune> XML
+    """
+    XML_NAME = "cachetune"
+    _XML_PROP_ORDER = ["vcpus", "caches"]
+
+    vcpus = XMLProperty("./@vcpus")
+    caches = XMLChildProperty(_CacheCPU)
+
+
 class DomainCputune(XMLBuilder):
     """
     Class for generating <cpu> XML
     """
     XML_NAME = "cputune"
+    _XML_PROP_ORDER = ["vcpus", "cachetune"]
+
     vcpus = XMLChildProperty(_VCPUPin)
+    cachetune = XMLChildProperty(_CacheTuneCPU)
-- 
2.21.0




More information about the virt-tools-list mailing list