This adds the following suboptions to configure <cputune>: - vcpusched.vcpus - vcpusched.scheduler - vcpusched.priority Signed-off-by: Jonathan Schwender <schwenderjonathan@xxxxxxxxx> --- .../compare/virt-install-singleton-config-2.xml | 2 ++ tests/test_cli.py | 2 +- virtinst/cli.py | 12 ++++++++++++ virtinst/domain/cputune.py | 15 ++++++++++++++- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/data/cli/compare/virt-install-singleton-config-2.xml b/tests/data/cli/compare/virt-install-singleton-config-2.xml index b01d2317..b0d72d16 100644 --- a/tests/data/cli/compare/virt-install-singleton-config-2.xml +++ b/tests/data/cli/compare/virt-install-singleton-config-2.xml @@ -237,6 +237,7 @@ <memorytune vcpus="0-3"> <node id="0" bandwidth="60"/> </memorytune> + <vcpusched vcpus="0-3,^2" scheduler="fifo" priority="95"/> </cputune> </domain> <domain type="kvm"> @@ -481,5 +482,6 @@ <memorytune vcpus="0-3"> <node id="0" bandwidth="60"/> </memorytune> + <vcpusched vcpus="0-3,^2" scheduler="fifo" priority="95"/> </cputune> </domain> diff --git a/tests/test_cli.py b/tests/test_cli.py index 7056a05f..0e326048 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -514,7 +514,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,memorytune0.vcpus=0-3,memorytune0.node0.id=0,memorytune0.node0.bandwidth=60 +--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,vcpusched0.vcpus=0-3,^2,vcpusched0.scheduler=fifo,vcpusched0.priority=95 --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 473ab8f0..4ce3abf9 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -2350,6 +2350,12 @@ class ParserCputune(VirtCLIParser): cb = self._make_find_inst_cb(cliarg, list_propname) return cb(*args, **kwargs) + def vcpusched_find_inst_cb(self, *args, **kwargs): + cliarg = "vcpusched" # vcpusched[0-9]* + list_propname = "vcpusched" + 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" @@ -2388,6 +2394,12 @@ 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("vcpusched[0-9]*.vcpus", "vcpus", can_comma=True, + find_inst_cb=cls.vcpusched_find_inst_cb) + cls.add_arg("vcpusched[0-9]*.scheduler", "scheduler", + find_inst_cb=cls.vcpusched_find_inst_cb) + cls.add_arg("vcpusched[0-9]*.priority", "priority", + find_inst_cb=cls.vcpusched_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", diff --git a/virtinst/domain/cputune.py b/virtinst/domain/cputune.py index e00dc270..73398d22 100644 --- a/virtinst/domain/cputune.py +++ b/virtinst/domain/cputune.py @@ -63,13 +63,26 @@ class _MemoryTuneCPU(XMLBuilder): nodes = XMLChildProperty(_NodeCPU) +class _VCPUSched(XMLBuilder): + """ + Class for generating <cputune> child <vcpusched> XML + """ + XML_NAME = "vcpusched" + _XML_PROP_ORDER = ["vcpus", "scheduler", "priority"] + + vcpus = XMLProperty("./@vcpus") + scheduler = XMLProperty("./@scheduler") + priority = XMLProperty("./@priority", is_int=True) + + class DomainCputune(XMLBuilder): """ Class for generating <cpu> XML """ XML_NAME = "cputune" - _XML_PROP_ORDER = ["vcpus", "cachetune", "memorytune"] + _XML_PROP_ORDER = ["vcpus", "cachetune", "memorytune", "vcpusched"] vcpus = XMLChildProperty(_VCPUPin) cachetune = XMLChildProperty(_CacheTuneCPU) memorytune = XMLChildProperty(_MemoryTuneCPU) + vcpusched = XMLChildProperty(_VCPUSched) -- 2.29.2