It allows to set the thread pool size to optimize spawning worker threads for the default event loop in real time environment. For example: --defaultiothread thread_pool_min=8,thread_pool_max=16 Signed-off-by: Lin Ma <lma@xxxxxxxx> --- man/virt-install.rst | 15 ++++++++++++ man/virt-xml.rst | 1 + .../cli/compare/virt-install-many-devices.xml | 1 + tests/test_cli.py | 3 +++ virtinst/cli.py | 23 +++++++++++++++++++ virtinst/guest.py | 11 ++++++++- 6 files changed, 53 insertions(+), 1 deletion(-) diff --git a/man/virt-install.rst b/man/virt-install.rst index 3a6e8dcd..21cf6b10 100644 --- a/man/virt-install.rst +++ b/man/virt-install.rst @@ -498,6 +498,21 @@ Complete details at https://libvirt.org/formatdomain.html#elementsIOThreadsAlloc +``--defaultiothread`` +^^^^^^^^^^^^^^^^^^^^^ + +**Syntax:** ``--defaultiothread`` OPTIONS + +Set the lower and upper boundary for number of worker threads of the default +event loop for the domain process. Example: + +``--defaultiothread thread_pool_min=8,thread_pool_max=16`` + +Use --defaultiothread=? to see a list of all available sub options. +Complete details at https://libvirt.org/formatdomain.html#elementsIOThreadsAllocation + + + ``--features`` ^^^^^^^^^^^^^^ diff --git a/man/virt-xml.rst b/man/virt-xml.rst index ddd586bb..bcd4ae97 100644 --- a/man/virt-xml.rst +++ b/man/virt-xml.rst @@ -208,6 +208,7 @@ XML OPTIONS * ``--vcpus`` * ``--cpu`` * ``--iothreads`` +* ``--defaultiothread`` * ``--seclabel`` * ``--keywrap`` * ``--cputune`` diff --git a/tests/data/cli/compare/virt-install-many-devices.xml b/tests/data/cli/compare/virt-install-many-devices.xml index 87d48812..9826aecd 100644 --- a/tests/data/cli/compare/virt-install-many-devices.xml +++ b/tests/data/cli/compare/virt-install-many-devices.xml @@ -14,6 +14,7 @@ <iothread id="1"/> <iothread id="2" thread_pool_min="8" thread_pool_max="16"/> </iothreadids> + <defaultiothread thread_pool_min="4" thread_pool_max="32"/> <memory>65536</memory> <currentMemory>65536</currentMemory> <blkiotune> diff --git a/tests/test_cli.py b/tests/test_cli.py index ba7818bf..94dd702e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -548,6 +548,9 @@ memorytune0.vcpus=0-3,memorytune0.node0.id=0,memorytune0.node0.bandwidth=60 --iothreads iothreads=5,iothreadids.iothread0.id=1,iothreadids.iothread1.id=2,iothreadids.iothread1.thread_pool_min=8,iothreadids.iothread1.thread_pool_max=16 +--defaultiothread thread_pool_min=4,thread_pool_max=32 + + --metadata title=my-title,description=my-description,uuid=00000000-1111-2222-3333-444444444444,genid=e9392370-2917-565e-692b-d057f46512d6,genid_enable=yes diff --git a/virtinst/cli.py b/virtinst/cli.py index fadf216e..2b0f9fec 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -832,6 +832,12 @@ def add_guest_xml_options(geng): geng.add_argument("--iothreads", action="append", help=_("Set domain <iothreads> and <iothreadids> configuration.")) + ParserDefaultIOThread.register() + geng.add_argument("--defaultiothread", action="append", + help=_("Set the lower and upper boundary for number of worker\n" + "threads of the default event loop for the domain process. Ex:\n" + "--defaultiothread thread_pool_min=8,thread_pool_max=16")) + ParserSeclabel.register() geng.add_argument("--seclabel", "--security", action="append", help=_("Set domain seclabel configuration.")) @@ -2620,6 +2626,23 @@ class ParserIOThreads(VirtCLIParser): "thread_pool_max", find_inst_cb=cls.iothreads_find_inst_cb) +############################# +# --defaultiothread parsing # +############################# + +class ParserDefaultIOThread(VirtCLIParser): + cli_arg_name = "defaultiothread" + guest_propname = "defaultiothread" + remove_first = "defaultiothread" + + @classmethod + def _virtcli_class_init(cls): + VirtCLIParser._virtcli_class_init_common(cls) + + cls.add_arg("thread_pool_min", "thread_pool_min") + cls.add_arg("thread_pool_max", "thread_pool_max") + + ################### # --vcpus parsing # ################### diff --git a/virtinst/guest.py b/virtinst/guest.py index be9f0267..0b48ff7b 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -74,6 +74,13 @@ class _IOThreadID(XMLBuilder): thread_pool_max = XMLProperty("./@thread_pool_max", is_int=True) +class _DefaultIOThread(XMLBuilder): + XML_NAME = "defaultiothread" + + thread_pool_min = XMLProperty("./@thread_pool_min", is_int=True) + thread_pool_max = XMLProperty("./@thread_pool_max", is_int=True) + + class Guest(XMLBuilder): @staticmethod def validate_name(conn, name, check_collision=True, validate=True): @@ -180,7 +187,8 @@ class Guest(XMLBuilder): XML_NAME = "domain" _XML_PROP_ORDER = [ "type", "name", "uuid", "genid", "genid_enable", - "title", "description", "_metadata", "iothreads", "iothreadids", + "title", "description", "_metadata", + "iothreads", "iothreadids", "defaultiothread", "maxMemory", "maxMemorySlots", "memory", "_currentMemory", "blkiotune", "memtune", "memoryBacking", "_vcpus", "vcpu_current", "vcpu_placement", @@ -226,6 +234,7 @@ class Guest(XMLBuilder): iothreads = XMLProperty("./iothreads", is_int=True) iothreadids = XMLChildProperty(_IOThreadID, relative_xpath="./iothreadids") + defaultiothread = XMLChildProperty(_DefaultIOThread) def _set_currentMemory(self, val): if val is not None: -- 2.26.2