cli: Add --cputune memorytune options

--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>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
This commit is contained in:
Athina Plaskasoviti 2019-08-14 18:50:40 +03:00 committed by Cole Robinson
parent 9cea262b85
commit cc60d558c0
4 changed files with 51 additions and 2 deletions

View File

@ -227,6 +227,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">
@ -461,5 +464,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>

View File

@ -505,7 +505,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

View File

@ -2099,6 +2099,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)
@ -2119,6 +2134,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)
#######################

View File

@ -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)