[virt-manager] [PATCH v2] cli: Add --iothreads defaultiothread.thread_pool_{min, max}
Lin Ma
lma at suse.com
Tue Aug 2 05:02:30 UTC 2022
It allows to set the thread pool size to optimize spawning worker threads
for the default event loop in real time environment. For example:
--iothreads defaultiothread.thread_pool_min=8,\
defaultiothread.thread_pool_max=16
Signed-off-by: Lin Ma <lma at suse.com>
---
tests/data/cli/compare/virt-install-many-devices.xml | 1 +
tests/test_cli.py | 2 +-
virtinst/cli.py | 10 ++++++++++
virtinst/guest.py | 11 ++++++++++-
4 files changed, 22 insertions(+), 2 deletions(-)
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 f401fc06..47b59055 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -545,7 +545,7 @@ memorytune0.vcpus=0-3,memorytune0.node0.id=0,memorytune0.node0.bandwidth=60
--memorybacking size=1,unit='G',nodeset=0,1,nosharepages=yes,locked=yes,discard=yes,allocation.mode=immediate,access_mode=shared,source_type=file,hugepages.page.size=12,hugepages.page1.size=1234,hugepages.page1.unit=MB,hugepages.page1.nodeset=2,allocation.threads=8
---iothreads iothreads=5,iothreadids.iothread0.id=1,iothreadids.iothread1.id=2,iothreadids.iothread1.thread_pool_min=8,iothreadids.iothread1.thread_pool_max=16
+--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,defaultiothread.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 b513c3c3..6179c436 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -2608,6 +2608,12 @@ class ParserIOThreads(VirtCLIParser):
cb = self._make_find_inst_cb(cliarg, list_propname)
return cb(*args, **kwargs)
+ def defaultiothread_find_inst_cb(self, *args, **kwargs):
+ cliarg = "defaultiothread"
+ list_propname = "defaultiothread"
+ cb = self._make_find_inst_cb(cliarg, list_propname)
+ return cb(*args, **kwargs)
+
@classmethod
def _virtcli_class_init(cls):
VirtCLIParser._virtcli_class_init_common(cls)
@@ -2619,6 +2625,10 @@ class ParserIOThreads(VirtCLIParser):
"thread_pool_min", find_inst_cb=cls.iothreads_find_inst_cb)
cls.add_arg("iothreadids.iothread[0-9]*.thread_pool_max",
"thread_pool_max", find_inst_cb=cls.iothreads_find_inst_cb)
+ cls.add_arg("defaultiothread.thread_pool_min", "thread_pool_min",
+ find_inst_cb=cls.defaultiothread_find_inst_cb)
+ cls.add_arg("defaultiothread.thread_pool_max", "thread_pool_max",
+ find_inst_cb=cls.defaultiothread_find_inst_cb)
###################
diff --git a/virtinst/guest.py b/virtinst/guest.py
index 4323394b..e6636022 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.35.3
More information about the virt-tools-list
mailing list