Zhang Chen <[email protected]> writes:

> Display holder information in info iothreads to aid manual debugging.
> Omit the holders line when an IOThread has no holders.
>
> 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..de37f83a72 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);
> +        if (value->holders) {
> +            monitor_printf(mon, "  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_id);
> +                    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 prints nothing when we have no holders.

If you delete the if (value->holders) guard, it prints a line

    holders=

Matter of taste.  Anyone got a preference?

>          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