On Sat, Aug 01, 2026 at 12:04:25 -0500, Jaehoon Kim wrote:
> Extend iothreadset to allow configuring the iothread poll-weight value
> from the command line.
> 
> Add a --poll-weight option to opts_iothreadset and wire it up in
> cmdIOThreadSet. The value is validated against the accepted range
> [0, 63] before being passed to the backend as
> VIR_DOMAIN_IOTHREAD_POLL_WEIGHT. If the option is omitted the parameter
> is not added to the list and the backend leaves the value unchanged.
> 
> Document --poll-weight in the iothreadset section of the virsh manpage
> and update the syntax synopsis to include the new option. Extend the
> virsh test suite with an iothreadset --poll-weight 3 call followed by
> a domstats check that confirms the updated value is reflected.
> 
> Signed-off-by: Jaehoon Kim <[email protected]>
> ---
>  docs/manpages/virsh.rst           | 16 ++++++++++------
>  tests/virshtestdata/iothreads.in  |  2 ++
>  tests/virshtestdata/iothreads.out | 14 ++++++++++++++
>  tools/virsh-domain.c              | 17 +++++++++++++++++
>  4 files changed, 43 insertions(+), 6 deletions(-)

[...]

> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index 0f177fb69a..c5158889cc 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -8271,6 +8271,11 @@ static const vshCmdOptDef opts_iothreadset[] = {
>       .unwanted_positional = true,
>       .help = N_("set the value for reduction of the IOThread polling time")
>      },
> +    {.name = "poll-weight",
> +     .type = VSH_OT_INT,
> +     .unwanted_positional = true,

As the name of the property suggests it's not wanted. This is a
compatibility for old properties that were positional but we didn't want
them to be positional. So you *must not* add any of these ever for any
new property.

And even if you would for any reason want to add a positional argument
you definitely can't add it *before* any other existing positional
argument as it breaks existing commandlines which specify it as
positional rather than with explicit flag name.


> +     .help = N_("set the adaptive polling weight factor")
> +    },
>      {.name = "thread-pool-min",
>       .type = VSH_OT_INT,
>       .unwanted_positional = true,

^^^^


> @@ -8300,6 +8305,7 @@ cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd)
>      virTypedParameterPtr par;
>      size_t npar = 0;
>      unsigned long long poll_val;
> +    unsigned int poll_weight;
>      int thread_val;
>      int rc;
>  
> @@ -8336,6 +8342,17 @@ cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd)
>      if (rc > 0)
>          virTypedParamListAddUnsigned(params, poll_val, 
> VIR_DOMAIN_IOTHREAD_POLL_SHRINK);
>  
> +    if ((rc = vshCommandOptUInt(ctl, cmd, "poll-weight", &poll_weight)) < 0)
> +        return false;
> +    if (rc > 0) {
> +        if (poll_weight > 63) {
> +            vshError(ctl, _("poll-weight value %1$u is out of range [0, 
> 63]"),
> +                     poll_weight);
> +            return false;

I don't think a client side check is needed here.


> +        }
> +        virTypedParamListAddUInt(params, poll_weight, 
> VIR_DOMAIN_IOTHREAD_POLL_WEIGHT);
> +    }
> +
>      if ((rc = vshCommandOptInt(ctl, cmd, "thread-pool-min", &thread_val)) < 
> 0)
>          return false;
>      if (rc > 0)
> -- 
> 2.54.0
> 

With the 'unwanted_positional' flag removed and the client side check
removed:

Reviewed-by: Peter Krempa <[email protected]>

Reply via email to