Zhang Chen <[email protected]> writes:

> Exposed the iothread holders via the Human Monitor Interface (HMP)
> command 'info iothreads' to assist with manual debugging and
> performance tuning.
>
> Signed-off-by: Zhang Chen <[email protected]>
> ---
>  monitor/hmp-cmds.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index e9fb8d827a..cd2d9c1d59 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -240,11 +240,33 @@ void hmp_info_iothreads(Monitor *mon, const QDict 
> *qdict)
>      IOThreadInfoList *info_list = qmp_query_iothreads(NULL);
>      IOThreadInfoList *info;
>      IOThreadInfo *value;
> +    IOThreadHolderList *h;
>  
>      for (info = info_list; info; info = info->next) {
>          value = info->value;
>          monitor_printf(mon, "%s:\n", value->id);
>          monitor_printf(mon, "  thread_id=%" PRId64 "\n", value->thread_id);
> +        monitor_printf(mon, "  holders=");

This is unconditional.

> +        if (value->holders) {
> +            for (h = value->holders; h; h = h->next) {
> +                IOThreadHolder *holder = h->value;
> +
> +                switch (holder->type) {
> +                case IO_THREAD_HOLDER_KIND_BLOCK_EXPORT:
> +                    monitor_printf(mon, "[block-export: %s]",
> +                                   holder->u.block_export.export_name);
> +                    break;
> +                case IO_THREAD_HOLDER_KIND_QOM_OBJECT:
> +                    monitor_printf(mon, "[qom-path: %s]",
> +                                   holder->u.qom_object.qom_path);
> +                    break;
> +                default:
> +                    monitor_printf(mon, "[unknown]");
> +                    break;
> +                }
> +            }
> +            monitor_printf(mon, "\n");

This isn't.  Results in messed-up output when there are no holders:

    $ qemu-system-x86_64 -S -display none -monitor stdio -object 
iothread,id=iot0
    QEMU 11.0.90 monitor - type 'help' for more information
    (qemu) info iothreads 
    iot0:
      thread_id=1035908
      holders=  poll-max-ns=32768
      poll-grow=2
      poll-shrink=2
      poll-weight=3
      aio-max-batch=0

There's no need for a conditional here, the loop does nothing just fine
when the list is empty.

> +        }
>          monitor_printf(mon, "  poll-max-ns=%" PRId64 "\n", 
> value->poll_max_ns);
>          monitor_printf(mon, "  poll-grow=%" PRId64 "\n", value->poll_grow);
>          monitor_printf(mon, "  poll-shrink=%" PRId64 "\n", 
> value->poll_shrink);


Reply via email to