[PATCH 12/16] qemu: Wire up new virDomainSetIOThreadParams parameters

Peter Krempa pkrempa at redhat.com
Thu Jun 2 08:44:21 UTC 2022


On Thu, Jun 02, 2022 at 09:18:02 +0200, Michal Privoznik wrote:
> Introduced in previous commit, QEMU driver needs to be taught how
> to set VIR_DOMAIN_IOTHREAD_THREAD_POOL_MIN and
> VIR_DOMAIN_IOTHREAD_THREAD_POOL_MAX parameters on given IOThread.
> Fortunately, this is fairly trivial to do and since these two
> parameters are exposed in domain XML too the update of inactive
> XML can be wired up too.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/qemu/qemu_driver.c       | 63 +++++++++++++++++++++++++++++++++---
>  src/qemu/qemu_monitor.h      |  4 +++
>  src/qemu/qemu_monitor_json.c |  2 ++
>  3 files changed, 64 insertions(+), 5 deletions(-)

[...]

One more thing

> diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
> index be341d5196..6ce38ffe86 100644
> --- a/src/qemu/qemu_monitor.h
> +++ b/src/qemu/qemu_monitor.h
> @@ -1308,9 +1308,13 @@ struct _qemuMonitorIOThreadInfo {
>      unsigned long long poll_max_ns;
>      unsigned int poll_grow;
>      unsigned int poll_shrink;
> +    long long thread_pool_min;
> +    long long thread_pool_max;

These are 'long long', but ...

>      bool set_poll_max_ns;
>      bool set_poll_grow;
>      bool set_poll_shrink;
> +    bool set_thread_pool_min;
> +    bool set_thread_pool_max;
>  };
>  int qemuMonitorGetIOThreads(qemuMonitor *mon,
>                              qemuMonitorIOThreadInfo ***iothreads,
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index dc05dfd047..e8fe1eceae 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -7431,6 +7431,8 @@ qemuMonitorJSONSetIOThread(qemuMonitor *mon,
>      VIR_IOTHREAD_SET_PROP("poll-max-ns", poll_max_ns);
>      VIR_IOTHREAD_SET_PROP("poll-grow", poll_grow);
>      VIR_IOTHREAD_SET_PROP("poll-shrink", poll_shrink);
> +    VIR_IOTHREAD_SET_PROP("thread-pool-min", thread_pool_min);
> +    VIR_IOTHREAD_SET_PROP("thread-pool-max", thread_pool_max);

This macro is defined as:

#define VIR_IOTHREAD_SET_PROP(propName, propVal) \
    if (iothreadInfo->set_##propVal) { \
        memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty)); \
        prop.type = QEMU_MONITOR_OBJECT_PROPERTY_INT; \
        prop.val.iv = iothreadInfo->propVal; \
        if (qemuMonitorJSONSetObjectProperty(mon, path, propName, &prop) < 0) \
            return -1; \
    }

So with your use you have an unchecked overflow possibility when
down-converting the number into an int.

I think all of the above headache can be solved by simply using 'int'
for the thread count.


More information about the libvir-list mailing list