[virt-tools-list] [virt-manager PATCH] cli: Add --cputune memorytune options
athina.plaskasoviti at gmail.com
athina.plaskasoviti at gmail.com
Wed Aug 14 15:50:40 UTC 2019
From: Athina Plaskasoviti <athina.plaskasoviti at gmail.com>
--memorytune[0-9]*.vcpus
--memorytune[0-9]*.node[0-9]*.id
--memorytune[0-9]*.node[0-9]*.bandwidth
XML Mapping:
<cputune>
...
<memorytune vcpus="X">
<node id="X" bandwidth="X"/>
</memorytune>
...
</cputune>
Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti at gmail.com>
---
.../virt-install-singleton-config-2.xml | 6 +++++
tests/clitest.py | 2 +-
virtinst/cli.py | 21 ++++++++++++++++
virtinst/domain/cputune.py | 24 ++++++++++++++++++-
4 files changed, 51 insertions(+), 2 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 000c94c0..a1725724 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
@@ -220,6 +220,9 @@
<cachetune vcpus="0-3">
<cache level="3" id="0" type="both" size="3" unit="MiB"/>
</cachetune>
+ <memorytune vcpus="0-3">
+ <node id="0" bandwidth="60"/>
+ </memorytune>
</cputune>
</domain>
<domain type="kvm">
@@ -447,5 +450,8 @@
<cachetune vcpus="0-3">
<cache level="3" id="0" type="both" size="3" unit="MiB"/>
</cachetune>
+ <memorytune vcpus="0-3">
+ <node id="0" bandwidth="60"/>
+ </memorytune>
</cputune>
</domain>
diff --git a/tests/clitest.py b/tests/clitest.py
index 06c580dc..f4fd82d3 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,cachetune0.vcpus=0-3,cachetune0.cache0.level=3,cachetune0.cache0.id=0,cachetune0.cache0.type=both,cachetune0.cache0.size=3,cachetune0.cache0.unit=MiB
+--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,memorytune0.vcpus=0-3,memorytune0.node0.id=0,memorytune0.node0.bandwidth=60
--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 6caab475..47ed55b4 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -2112,6 +2112,21 @@ class ParserCputune(VirtCLIParser):
cb = self._make_find_inst_cb(cliarg, list_propname)
return cb(inst, *args, **kwargs)
+ def memorytune_find_inst_cb(self, *args, **kwargs):
+ cliarg = "memorytune" # memorytune[0-9]*
+ list_propname = "memorytune"
+ cb = self._make_find_inst_cb(cliarg, list_propname)
+ return cb(*args, **kwargs)
+
+ def node_find_inst_cb(self, inst, *args, **kwargs):
+ memorytune = self.memorytune_find_inst_cb(inst, *args, **kwargs)
+ inst = memorytune
+
+ cliarg = "node" # memorytune[0-9]*.node[0-9]*
+ list_propname = "nodes" # memorytune.nodes
+ cb = self._make_find_inst_cb(cliarg, list_propname)
+ return cb(inst, *args, **kwargs)
+
@classmethod
def _init_class(cls, **kwargs):
VirtCLIParser._init_class(**kwargs)
@@ -2132,6 +2147,12 @@ class ParserCputune(VirtCLIParser):
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)
+ cls.add_arg("memorytune[0-9]*.vcpus", "vcpus",
+ find_inst_cb=cls.memorytune_find_inst_cb)
+ cls.add_arg("memorytune[0-9]*.node[0-9]*.id", "id",
+ find_inst_cb=cls.node_find_inst_cb)
+ cls.add_arg("memorytune[0-9]*.node[0-9]*.bandwidth", "bandwidth",
+ find_inst_cb=cls.node_find_inst_cb)
#######################
diff --git a/virtinst/domain/cputune.py b/virtinst/domain/cputune.py
index 4d761ebf..e00dc270 100644
--- a/virtinst/domain/cputune.py
+++ b/virtinst/domain/cputune.py
@@ -42,12 +42,34 @@ class _CacheTuneCPU(XMLBuilder):
caches = XMLChildProperty(_CacheCPU)
+class _NodeCPU(XMLBuilder):
+ """
+ Class for generating <memorytune> child <node> XML
+ """
+ XML_NAME = "node"
+ _XML_PROP_ORDER = ["id", "bandwidth"]
+
+ id = XMLProperty("./@id", is_int=True)
+ bandwidth = XMLProperty("./@bandwidth", is_int=True)
+
+
+class _MemoryTuneCPU(XMLBuilder):
+ """
+ Class for generating <cputune> child <memorytune> XML
+ """
+ XML_NAME = "memorytune"
+
+ vcpus = XMLProperty("./@vcpus")
+ nodes = XMLChildProperty(_NodeCPU)
+
+
class DomainCputune(XMLBuilder):
"""
Class for generating <cpu> XML
"""
XML_NAME = "cputune"
- _XML_PROP_ORDER = ["vcpus", "cachetune"]
+ _XML_PROP_ORDER = ["vcpus", "cachetune", "memorytune"]
vcpus = XMLChildProperty(_VCPUPin)
cachetune = XMLChildProperty(_CacheTuneCPU)
+ memorytune = XMLChildProperty(_MemoryTuneCPU)
--
2.21.0
More information about the virt-tools-list
mailing list