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 b680f6da5..a551c729a 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 @@ -224,6 +224,9 @@ ignore + + + @@ -455,5 +458,8 @@ ignore + + + diff --git a/tests/clitest.py b/tests/clitest.py index e56656303..ac82fcd2d 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -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 +--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 d9b4d0836..b3452b08f 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -2084,6 +2084,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) @@ -2092,6 +2107,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 67a76476e..4d761ebf1 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 child 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 child XML + """ + XML_NAME = "cachetune" + _XML_PROP_ORDER = ["vcpus", "caches"] + + vcpus = XMLProperty("./@vcpus") + caches = XMLChildProperty(_CacheCPU) + + class DomainCputune(XMLBuilder): """ Class for generating XML """ XML_NAME = "cputune" + _XML_PROP_ORDER = ["vcpus", "cachetune"] + vcpus = XMLChildProperty(_VCPUPin) + cachetune = XMLChildProperty(_CacheTuneCPU)