Bug 2117475

Summary: Can't set thread_pool_min/thread_pool_max by setIOThreadParams()
Product: Red Hat Enterprise Linux 9 Reporter: lcheng
Component: libvirt-pythonAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: lcheng
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.1CC: jdenemar, lmen, pkrempa, virt-maint
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-python-8.5.0-2.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 10:09:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description lcheng 2022-08-11 06:10:48 UTC
Description of problem:
Can't set thread_pool_min/thread_pool_max by setIOThreadParams()

Version-Release number of selected component (if applicable):
python3-libvirt-8.5.0-1.el9.x86_64
libvirt-8.5.0-5.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
# python
Python 3.9.13 (main, Jun  9 2022, 00:00:00)
[GCC 11.3.1 20220421 (Red Hat 11.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> conn = libvirt.open()
>>> dom = conn.lookupByName('test')
>>> dom.info()
[1, 2097152, 2097152, 2, 64240000000]
>>> dom.setIOThreadParams(300, {'thread_pool_max': int(10)}, 0)
libvirt:  error : invalid argument: invalid type 'ullong' for parameter 'thread_pool_max', expected 'int'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.9/site-packages/libvirt.py", line 2689, in setIOThreadParams
    raise libvirtError('virDomainSetIOThreadParams() failed')
libvirt.libvirtError: invalid argument: invalid type 'ullong' for parameter 'thread_pool_max', expected 'int'
>>> dom.setIOThreadParams(300, {'thread_pool_min': int(5)}, 0)
libvirt:  error : invalid argument: invalid type 'ullong' for parameter 'thread_pool_min', expected 'int'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.9/site-packages/libvirt.py", line 2689, in setIOThreadParams
    raise libvirtError('virDomainSetIOThreadParams() failed')
libvirt.libvirtError: invalid argument: invalid type 'ullong' for parameter 'thread_pool_min', expected 'int'
>>>


Actual results:
Set failed.

Expected results:
Set thread_pool_min/thread_pool_max successful.

Comment 1 Peter Krempa 2022-08-11 11:46:20 UTC
This bug is fixed in libvirt-python v8.6.0 by:

commit b943a5bd18b4cc765719c0dbc628a077c3db4d52
Author: Michal Privoznik <mprivozn>
Date:   Thu Jul 7 16:04:10 2022 +0200

    Add VIR_DOMAIN_IOTHREAD_THREAD_POOL_{MIN,MAX} macros
    
    The python version of virDomainSetIOThreadParams
    (setIOThreadParams()), expects two arguments on input: the thread
    ID and a dictionary which is then translated into our typed
    parameters. During this translation we use a helper array which
    holds type for each typed parameter supported
    (virPyDomainSetIOThreadParams[]). Otherwise we guess what the
    correct type is. Now, when introducing
    VIR_DOMAIN_IOTHREAD_THREAD_POOL_{MIN,MAX} typed params into
    libvirt I forgot to update the array. Do that now.
    
    Signed-off-by: Michal Privoznik <mprivozn>

diff --git a/libvirt-override.c b/libvirt-override.c
index cba67d9..2a2a7dd 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -1695,6 +1695,10 @@ static virPyTypedParamsHint virPyDomainSetIOThreadParams[] = {
     { VIR_DOMAIN_IOTHREAD_POLL_MAX_NS, VIR_TYPED_PARAM_ULLONG },
     { VIR_DOMAIN_IOTHREAD_POLL_GROW, VIR_TYPED_PARAM_UINT },
     { VIR_DOMAIN_IOTHREAD_POLL_SHRINK, VIR_TYPED_PARAM_UINT },
+# if LIBVIR_CHECK_VERSION(8, 5, 0)
+    { VIR_DOMAIN_IOTHREAD_THREAD_POOL_MIN, VIR_TYPED_PARAM_INT },
+    { VIR_DOMAIN_IOTHREAD_THREAD_POOL_MAX, VIR_TYPED_PARAM_INT },
+# endif /*  LIBVIR_CHECK_VERSION(8, 5, 0) */
 };

v8.5.0-2-gb943a5b

Comment 2 Michal Privoznik 2022-08-11 13:15:29 UTC
To POST:

https://gitlab.com/redhat/rhel/src/libvirt-python/-/merge_requests/1

Comment 4 lcheng 2022-08-22 09:48:00 UTC
Verified on python3-libvirt-8.5.0-2.el9.x86_64.
 

1. Set thread_pool_min/thread_pool_max.
# python
Python 3.9.13 (main, Jul 25 2022, 00:00:00) 
[GCC 11.3.1 20220421 (Red Hat 11.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> conn = libvirt.open()
>>> dom = conn.lookupByName('vm1')
>>> dom.setIOThreadParams(300, {'thread_pool_min': 6}, 0)
0
>>> dom.setIOThreadParams(300, {'thread_pool_max': 15}, 0)
0


2. Check thread_pool_min/thread_pool_max in xml.
# virsh dumpxml vm1
...
  <iothreads>1</iothreads>
  <iothreadids>
    <iothread id='300' thread_pool_min='6' thread_pool_max='15'/>
  </iothreadids>

Comment 7 lcheng 2022-08-23 12:15:42 UTC
According to Comment 4, move to VERIFIED.

Comment 9 errata-xmlrpc 2022-11-15 10:09:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (libvirt-python bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:8007