cli: --cputune: add scheduling options

This includes support for the following options:
* `emulatorsched.scheduler`
* `emulatorsched.priority`
* `iothreadsched.iothreads`
* `iothreadsched.scheduler`
* `iothreadsched.priority`
This commit is contained in:
Hugues Fafard 2021-08-06 17:42:43 +02:00 committed by Cole Robinson
parent 95721ae8d7
commit 563a97f022
4 changed files with 62 additions and 18 deletions

View File

@ -250,13 +250,15 @@
<vcpupin vcpu="0" cpuset="0-3"/>
<emulatorpin cpuset="1,7"/>
<iothreadpin iothread="1" cpuset="1,7"/>
<emulatorsched scheduler="rr" priority="99"/>
<vcpusched vcpus="0-3,^2" scheduler="fifo" priority="95"/>
<iothreadsched iothreads="1,2" scheduler="fifo" priority="90"/>
<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>
<vcpusched vcpus="0-3,^2" scheduler="fifo" priority="95"/>
</cputune>
</domain>
<domain type="kvm">
@ -514,12 +516,14 @@
<vcpupin vcpu="0" cpuset="0-3"/>
<emulatorpin cpuset="1,7"/>
<iothreadpin iothread="1" cpuset="1,7"/>
<emulatorsched scheduler="rr" priority="99"/>
<vcpusched vcpus="0-3,^2" scheduler="fifo" priority="95"/>
<iothreadsched iothreads="1,2" scheduler="fifo" priority="90"/>
<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>
<vcpusched vcpus="0-3,^2" scheduler="fifo" priority="95"/>
</cputune>
</domain>

View File

@ -517,9 +517,9 @@ cell1.distances.sibling1.id=1,cell1.distances.sibling1.value=10,\
cache.mode=emulate,cache.level=3
--cputune shares=2048,period=1000000,quota=-1,global_period=1000000,global_quota=-1,emulator_period=1000000,emulator_quota=-1,iothread_period=1000000,iothread_quota=-1,\
vcpupin0.vcpu=0,vcpupin0.cpuset=0-3,emulatorpin.cpuset=1,7,iothreadpin0.iothread=1,iothreadpin0.cpuset=1,7,\
emulatorsched.scheduler=rr,emulatorsched.priority=99,vcpusched0.vcpus=0-3,^2,vcpusched0.scheduler=fifo,vcpusched0.priority=95,iothreadsched0.iothreads=1,2,iothreadsched0.scheduler=fifo,iothreadsched0.priority=90,\
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
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

@ -2367,6 +2367,12 @@ class ParserCputune(VirtCLIParser):
cb = self._make_find_inst_cb(cliarg, list_propname)
return cb(*args, **kwargs)
def iothreadsched_find_inst_cb(self, *args, **kwargs):
cliarg = "iothreadsched" # iothreadsched[0-9]*
list_propname = "iothreadscheds" # cputune.iothreadscheds
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 = "cachetunes" # cputune.cachetunes
@ -2421,12 +2427,23 @@ class ParserCputune(VirtCLIParser):
find_inst_cb=cls.iothreadpin_find_inst_cb)
cls.add_arg("iothreadpin[0-9]*.cpuset", "cpuset", can_comma=True,
find_inst_cb=cls.iothreadpin_find_inst_cb)
# Scheduling
cls.add_arg("emulatorsched.scheduler", "emulatorsched_scheduler")
cls.add_arg("emulatorsched.priority", "emulatorsched_priority")
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("iothreadsched[0-9]*.iothreads", "iothreads", can_comma=True,
find_inst_cb=cls.iothreadsched_find_inst_cb)
cls.add_arg("iothreadsched[0-9]*.scheduler", "scheduler",
find_inst_cb=cls.iothreadsched_find_inst_cb)
cls.add_arg("iothreadsched[0-9]*.priority", "priority",
find_inst_cb=cls.iothreadsched_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",

View File

@ -32,6 +32,34 @@ class _IOThreadPin(XMLBuilder):
cpuset = XMLProperty("./@cpuset")
##############
# Scheduling #
##############
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 _IOThreadSched(XMLBuilder):
"""
Class for generating <cputune> child <iothreadsched> XML
"""
XML_NAME = "iothreadsched"
_XML_PROP_ORDER = ["iothreads", "scheduler", "priority"]
iothreads = XMLProperty("./@iothreads")
scheduler = XMLProperty("./@scheduler")
priority = XMLProperty("./@priority", is_int=True)
class _CacheCPU(XMLBuilder):
"""
Class for generating <cachetune> child <cache> XML
@ -78,18 +106,6 @@ 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
@ -98,7 +114,8 @@ class DomainCputune(XMLBuilder):
_XML_PROP_ORDER = ["shares", "period", "quota", "global_period", "global_quota",
"emulator_period", "emulator_quota", "iothread_period", "iothread_quota",
"vcpupins", "emulatorpin_cpuset", "iothreadpins",
"cachetunes", "memorytunes", "vcpuscheds"]
"emulatorsched_scheduler", "emulatorsched_priority", "vcpuscheds", "iothreadscheds",
"cachetunes", "memorytunes"]
# Resource quotas
shares = XMLProperty("./shares", is_int=True)
@ -115,6 +132,12 @@ class DomainCputune(XMLBuilder):
vcpupins = XMLChildProperty(_VCPUPin)
emulatorpin_cpuset = XMLProperty("./emulatorpin/@cpuset")
iothreadpins = XMLChildProperty(_IOThreadPin)
# Scheduling
emulatorsched_scheduler = XMLProperty("./emulatorsched/@scheduler")
emulatorsched_priority = XMLProperty("./emulatorsched/@priority", is_int=True)
vcpuscheds = XMLChildProperty(_VCPUSched)
iothreadscheds = XMLChildProperty(_IOThreadSched)
cachetunes = XMLChildProperty(_CacheTuneCPU)
memorytunes = XMLChildProperty(_MemoryTuneCPU)
vcpuscheds = XMLChildProperty(_VCPUSched)