From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ED01C433B4 for ; Fri, 16 Apr 2021 15:01:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E229061166 for ; Fri, 16 Apr 2021 15:01:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E229061166 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lXPy7-0001bd-Ob for qemu-devel@archiver.kernel.org; Fri, 16 Apr 2021 11:01:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXPwP-0000vN-Ob for qemu-devel@nongnu.org; Fri, 16 Apr 2021 10:59:29 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]:43843) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lXPwJ-0001DN-QV for qemu-devel@nongnu.org; Fri, 16 Apr 2021 10:59:27 -0400 Received: by mail-ej1-x630.google.com with SMTP id l4so42543876ejc.10 for ; Fri, 16 Apr 2021 07:59:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1M8AqbrE0rmOQuAlFV0hp4uriKSOI8QpkYfZ2DBfm2Y=; b=lHMh0W886jpOUO1La7jbMJeonjIszSf6G/bkP2b4mEj8yocPGf3uaqcocOFoSNb0Eh EQdxMIdFEnMcd4vQw2U0n0VCIPmAVnJfxYWPFGgGfGbakGyIO62IBP7y24JoE9GtM0JQ 2Dus4AYOMbxrbNepMfJzhcODPJtkOXXfWkxAvfTA75fuaqKak5sMDvrl5vcLQ0LaSTW9 AprecCI+OWuQLywubKwwg1c7kArC5ribvpzdJGfJNCFvjIJ7NTGn5XeqQmXyTm5mtLAt Uofvwsjh9PyCTU034Om9/Bssx9Xe8dO1eiMkkFOW7N7ZLASjSE+EpwCoGpclkOtJ0D2A smyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1M8AqbrE0rmOQuAlFV0hp4uriKSOI8QpkYfZ2DBfm2Y=; b=suj05kNkLGSHuxf63t9XiSYXbU4fDmKj3a1TnFvwTXHBIDtEiOYNvGZQaMh3b3PTxY hdMpDO8Eu31OtS7TO7DI8TRLpqa+lWCBV/hlmap3o+g5lw8aRZfNVwFVb2a7VQHsTHUV ZjgvspYXFZIf6T5qQyMfZwfCRsT2ZwHJkkprjnVg0Gpaz5WQHI9wLkAp+YDZtDJ2iyRP ZW2EguwvVmUOJ1PKlYke6wngfk8dteSTMOAAo+SqyxU8X14SpnPaJ/tFIuJXx4Fa41TL 0Nn6kBbYuhe7qG7m7ZDJqeis1k5KKf2NA6ELJ8oo5RI8MOT+QFN9xEJRtfDJXnW4Jvfl WsRA== X-Gm-Message-State: AOAM530jvO5T4fjJ5WZ42eYzmNE+7Dn8ArznZUqIP8IF6uuZfz98xT7P JLxW+agYb6jdv/DdWZHCq6PHxwXwhCpwaabqAuA= X-Google-Smtp-Source: ABdhPJwz2MFaPWLFU7dd9w+vR2z1J0Nyo3oMfIYcyJNLkR/Di475tGU1ZwQNp76pxBsy4yH687sygXT5dYLLWnnt44Q= X-Received: by 2002:a17:906:4153:: with SMTP id l19mr6001599ejk.109.1618585161535; Fri, 16 Apr 2021 07:59:21 -0700 (PDT) MIME-Version: 1.0 References: <20210413213459.629963-1-li.zhang@cloud.ionos.com> <875z0m4733.fsf@dusky.pond.sub.org> In-Reply-To: <875z0m4733.fsf@dusky.pond.sub.org> From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Fri, 16 Apr 2021 18:59:09 +0400 Message-ID: Subject: Re: [PATCHv2 1/1] Support monitor chardev hotswap with QMP To: Markus Armbruster Content-Type: multipart/alternative; boundary="00000000000097937e05c01839e3" Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=marcandre.lureau@gmail.com; helo=mail-ej1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Zhang , Li Zhang , QEMU , Pankaj Gupta Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --00000000000097937e05c01839e3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi On Fri, Apr 16, 2021 at 6:51 PM Markus Armbruster wrote= : > Marc-Andr=C3=A9, I'd like your opinion for this one, in particular the us= e of > g_source_remove(). > My opinion isn't really worth much, my review would have a bit more value. GSource has indeed some peculiar lifetime management, that I got wrong in the past. So I would be extra careful. But before spending time on review, I would also clarify the motivation and ask for testing. Markus, hot-adding/removing monitors isn't supported? > Li Zhang writes: > > > For some scenarios, it needs to hot-add a monitor device. > > But QEMU doesn't support hotplug yet. It also works by adding > > a monitor with null backend by default and then change its > > backend to socket by QMP command "chardev-change". > > > > So this patch is to support monitor chardev hotswap with QMP. > > > > Signed-off-by: Li Zhang > > Reviewed-by: Pankaj Gupta > > Your commit message starts with a brief description of the problem. > Appreciated! But I think it could be a bit clearer. What about this: > > qmp: Support chardev-change > > For some scenarios, we'd like to hot-add a monitor device. But QEMU > doesn't support that, yet. It does support hot-swapping character > backends with QMP command chardev-change. This lets us pre-add a > monitor with a null character backend, then chardev-change to a > socket backend. Except the chardev-change fails with "Chardev user > does not support chardev hotswap" because monitors don't provide the > required callback. Implement it for QMP monitors. > > > --- > > v1 -> v2: > > - Change mutex lock mon_lock section > > - Fix indentation problems > > > > monitor/monitor-internal.h | 3 +++ > > monitor/monitor.c | 2 +- > > monitor/qmp.c | 43 +++++++++++++++++++++++++++++++++++--- > > 3 files changed, 44 insertions(+), 4 deletions(-) > > > > diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h > > index 9c3a09cb01..1b80c74883 100644 > > --- a/monitor/monitor-internal.h > > +++ b/monitor/monitor-internal.h > > @@ -183,4 +183,7 @@ void help_cmd(Monitor *mon, const char *name); > > void handle_hmp_command(MonitorHMP *mon, const char *cmdline); > > int hmp_compare_cmd(const char *name, const char *list); > > > > +gboolean monitor_unblocked(GIOChannel *chan, GIOCondition cond, > > + void *opaque); > > + > > #endif > > diff --git a/monitor/monitor.c b/monitor/monitor.c > > index 636bcc81c5..16a3620d02 100644 > > --- a/monitor/monitor.c > > +++ b/monitor/monitor.c > > @@ -157,7 +157,7 @@ static inline bool > monitor_is_hmp_non_interactive(const Monitor *mon) > > > > static void monitor_flush_locked(Monitor *mon); > > > > -static gboolean monitor_unblocked(GIOChannel *chan, GIOCondition cond, > > +gboolean monitor_unblocked(GIOChannel *chan, GIOCondition cond, > > void *opaque) > > { > > Monitor *mon =3D opaque; > > diff --git a/monitor/qmp.c b/monitor/qmp.c > > index 2b0308f933..5fa65401ae 100644 > > --- a/monitor/qmp.c > > +++ b/monitor/qmp.c > > @@ -44,6 +44,7 @@ struct QMPRequest { > > Error *err; > > }; > > typedef struct QMPRequest QMPRequest; > > +static void monitor_qmp_set_handlers_bh(void *opaque); > > > > QmpCommandList qmp_commands, qmp_cap_negotiation_commands; > > > > @@ -477,7 +478,36 @@ void monitor_data_destroy_qmp(MonitorQMP *mon) > > g_queue_free(mon->qmp_requests); > > } > > > > -static void monitor_qmp_setup_handlers_bh(void *opaque) > > +static int monitor_qmp_change (void *opaque) > > +{ > > + MonitorQMP *mon =3D opaque; > > + > > + mon->common.use_io_thread =3D > qemu_chr_has_feature(mon->common.chr.chr, > > + QEMU_CHAR_FEATURE_GCONTEXT); > > + > > + if (mon->common.use_io_thread) { > > + aio_bh_schedule_oneshot(iothread_get_aio_context(mon_iothread)= , > > + monitor_qmp_set_handlers_bh, mon); > > + } else { > > + qemu_chr_fe_set_handlers(&mon->common.chr, monitor_can_read, > > + monitor_qmp_read, monitor_qmp_event, > > + monitor_qmp_change, &mon->common, > NULL, true); > > + } > > + > > + qemu_mutex_lock(&mon->common.mon_lock); > > + if (mon->common.out_watch) { > > + g_source_remove(mon->common.out_watch); > > + mon->common.out_watch =3D qemu_chr_fe_add_watch(&mon->common.c= hr, > > + G_IO_OUT | G_IO_HUP, > > + monitor_unblocked, > > + &mon->common); > > Visually align the arguments: > > mon->common.out_watch =3D qemu_chr_fe_add_watch(&mon->common.chr, > G_IO_OUT | G_IO_HUP= , > monitor_unblocked, > &mon->common); > > You may reduce argument indentation some to gain extra space, but keep > the arguments more indented than the function: > > mon->common.out_watch =3D qemu_chr_fe_add_watch(&mon->common.chr, > G_IO_OUT | G_IO_HUP, > monitor_unblocked, &mon->common); > > Do this only when you actually use the extra space for readability. > > > + } > > + qemu_mutex_unlock(&mon->common.mon_lock); > > + > > + return 0; > > +} > > As I wrote in my review of v1, this function copies from > monitor_data_init(), monitor_init_qmp(), and monitor_flush_locked(). > Feels like a refactoring would be in order. Doing it on top might be > easier. > > > + > > +static void monitor_qmp_set_handlers_bh(void *opaque) > > { > > MonitorQMP *mon =3D opaque; > > GMainContext *context; > > @@ -487,7 +517,14 @@ static void monitor_qmp_setup_handlers_bh(void > *opaque) > > assert(context); > > qemu_chr_fe_set_handlers(&mon->common.chr, monitor_can_read, > > monitor_qmp_read, monitor_qmp_event, > > - NULL, &mon->common, context, true); > > + monitor_qmp_change, &mon->common, context= , > true); > > + > > +} > > + > > +static void monitor_qmp_setup_handlers_bh(void *opaque) > > +{ > > + MonitorQMP *mon =3D opaque; > > + monitor_qmp_set_handlers_bh(mon); > > monitor_list_append(&mon->common); > > } > > > > @@ -528,7 +565,7 @@ void monitor_init_qmp(Chardev *chr, bool pretty, > Error **errp) > > } else { > > qemu_chr_fe_set_handlers(&mon->common.chr, monitor_can_read, > > monitor_qmp_read, monitor_qmp_event, > > - NULL, &mon->common, NULL, true); > > + monitor_qmp_change, &mon->common, > NULL, true); > > monitor_list_append(&mon->common); > > } > > } > > > --=20 Marc-Andr=C3=A9 Lureau --00000000000097937e05c01839e3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

On Fri, Apr 16, 2021 at 6:51 PM Markus Armbru= ster <armbru@redhat.com> wro= te:
Marc-Andr=C3= =A9, I'd like your opinion for this one, in particular the use of
g_source_remove().

My opinion isn't= really worth much, my review would have a bit more value.=C2=A0
=
GSource has indeed some peculiar lifetime management, that I= got wrong in the past. So I would be extra careful.

But before spending time on review, I would also clarify the motivation = and ask for testing.

Markus, hot-adding/removing m= onitors isn't supported?


Li Zhang <zhlcin= dy@gmail.com> writes:

> For some scenarios, it needs to hot-add a monitor device.
> But QEMU doesn't support hotplug yet. It also works by adding
> a monitor with null backend by default and then change its
> backend to socket by QMP command "chardev-change".
>
> So this patch is to support monitor chardev hotswap with QMP.
>
> Signed-off-by: Li Zhang <li.zhang@cloud.ionos.com>
> Reviewed-by: Pankaj Gupta <pankaj.gupta@ionos.com>

Your commit message starts with a brief description of the problem.
Appreciated!=C2=A0 But I think it could be a bit clearer.=C2=A0 What about = this:

=C2=A0 =C2=A0 qmp: Support chardev-change

=C2=A0 =C2=A0 For some scenarios, we'd like to hot-add a monitor device= .=C2=A0 But QEMU
=C2=A0 =C2=A0 doesn't support that, yet.=C2=A0 It does support hot-swap= ping character
=C2=A0 =C2=A0 backends with QMP command chardev-change.=C2=A0 This lets us = pre-add a
=C2=A0 =C2=A0 monitor with a null character backend, then chardev-change to= a
=C2=A0 =C2=A0 socket backend.=C2=A0 Except the chardev-change fails with &q= uot;Chardev user
=C2=A0 =C2=A0 does not support chardev hotswap" because monitors don&#= 39;t provide the
=C2=A0 =C2=A0 required callback.=C2=A0 Implement it for QMP monitors.

> ---
>=C2=A0 v1 -> v2:
>=C2=A0 =C2=A0- Change mutex lock mon_lock section
>=C2=A0 =C2=A0- Fix indentation problems
>
>=C2=A0 monitor/monitor-internal.h |=C2=A0 3 +++
>=C2=A0 monitor/monitor.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 2 +-=
>=C2=A0 monitor/qmp.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | = 43 +++++++++++++++++++++++++++++++++++---
>=C2=A0 3 files changed, 44 insertions(+), 4 deletions(-)
>
> diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h > index 9c3a09cb01..1b80c74883 100644
> --- a/monitor/monitor-internal.h
> +++ b/monitor/monitor-internal.h
> @@ -183,4 +183,7 @@ void help_cmd(Monitor *mon, const char *name);
>=C2=A0 void handle_hmp_command(MonitorHMP *mon, const char *cmdline); >=C2=A0 int hmp_compare_cmd(const char *name, const char *list);
>=C2=A0
> +gboolean monitor_unblocked(GIOChannel *chan, GIOCondition cond,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0void *opaque);
> +
>=C2=A0 #endif
> diff --git a/monitor/monitor.c b/monitor/monitor.c
> index 636bcc81c5..16a3620d02 100644
> --- a/monitor/monitor.c
> +++ b/monitor/monitor.c
> @@ -157,7 +157,7 @@ static inline bool monitor_is_hmp_non_interactive(= const Monitor *mon)
>=C2=A0
>=C2=A0 static void monitor_flush_locked(Monitor *mon);
>=C2=A0
> -static gboolean monitor_unblocked(GIOChannel *chan, GIOCondition cond= ,
> +gboolean monitor_unblocked(GIOChannel *chan, GIOCondition cond,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 void *opaque)
>=C2=A0 {
>=C2=A0 =C2=A0 =C2=A0 Monitor *mon =3D opaque;
> diff --git a/monitor/qmp.c b/monitor/qmp.c
> index 2b0308f933..5fa65401ae 100644
> --- a/monitor/qmp.c
> +++ b/monitor/qmp.c
> @@ -44,6 +44,7 @@ struct QMPRequest {
>=C2=A0 =C2=A0 =C2=A0 Error *err;
>=C2=A0 };
>=C2=A0 typedef struct QMPRequest QMPRequest;
> +static void monitor_qmp_set_handlers_bh(void *opaque);
>=C2=A0
>=C2=A0 QmpCommandList qmp_commands, qmp_cap_negotiation_commands;
>=C2=A0
> @@ -477,7 +478,36 @@ void monitor_data_destroy_qmp(MonitorQMP *mon) >=C2=A0 =C2=A0 =C2=A0 g_queue_free(mon->qmp_requests);
>=C2=A0 }
>=C2=A0
> -static void monitor_qmp_setup_handlers_bh(void *opaque)
> +static int monitor_qmp_change=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (void *opaque)
> +{
> +=C2=A0 =C2=A0 MonitorQMP *mon =3D opaque;
> +
> +=C2=A0 =C2=A0 mon->common.use_io_thread =3D qemu_chr_has_feature(m= on->common.chr.chr,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 QEMU_CHAR_FEATURE_GCONTEXT);
> +
> +=C2=A0 =C2=A0 if (mon->common.use_io_thread) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 aio_bh_schedule_oneshot(iothread_get_aio_= context(mon_iothread),
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 monitor_qmp_set_handlers_bh, mon= );
> +=C2=A0 =C2=A0 } else {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 qemu_chr_fe_set_handlers(&mon->com= mon.chr, monitor_can_read,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0monitor_qmp_read, monitor_= qmp_event,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0monitor_qmp_change, &m= on->common, NULL, true);
> +=C2=A0 =C2=A0 }
> +
> +=C2=A0 =C2=A0 qemu_mutex_lock(&mon->common.mon_lock);
> +=C2=A0 =C2=A0 if (mon->common.out_watch) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 g_source_remove(mon->common.out_watch)= ;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 mon->common.out_watch =3D qemu_chr_fe_= add_watch(&mon->common.chr,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 G_IO_OUT | G_IO_HUP,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 monitor_unblocked,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &mon->common);

Visually align the arguments:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 mon->common.out_watch =3D qemu_chr_fe_add_wa= tch(&mon->common.chr,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 G_IO_OUT | G_IO_HUP,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 monitor_unblocked,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &mon->common);

You may reduce argument indentation some to gain extra space, but keep
the arguments more indented than the function:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 mon->common.out_watch =3D qemu_chr_fe_add_wa= tch(&mon->common.chr,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 G_IO_OUT= | G_IO_HUP,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 monitor_= unblocked, &mon->common);

Do this only when you actually use the extra space for readability.

> +=C2=A0 =C2=A0 }
> +=C2=A0 =C2=A0 qemu_mutex_unlock(&mon->common.mon_lock);
> +
> +=C2=A0 =C2=A0 return 0;
> +}

As I wrote in my review of v1, this function copies from
monitor_data_init(), monitor_init_qmp(), and monitor_flush_locked().
Feels like a refactoring would be in order.=C2=A0 Doing it on top might be<= br> easier.

> +
> +static void monitor_qmp_set_handlers_bh(void *opaque)
>=C2=A0 {
>=C2=A0 =C2=A0 =C2=A0 MonitorQMP *mon =3D opaque;
>=C2=A0 =C2=A0 =C2=A0 GMainContext *context;
> @@ -487,7 +517,14 @@ static void monitor_qmp_setup_handlers_bh(void *o= paque)
>=C2=A0 =C2=A0 =C2=A0 assert(context);
>=C2=A0 =C2=A0 =C2=A0 qemu_chr_fe_set_handlers(&mon->common.chr, = monitor_can_read,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0monitor_qmp_read, monitor_qmp_even= t,
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0NULL, &mon->common, context, true= );
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0monitor_qmp_change, &mon->common,= context, true);
> +
> +}
> +
> +static void monitor_qmp_setup_handlers_bh(void *opaque)
> +{
> +=C2=A0 =C2=A0 MonitorQMP *mon =3D opaque;
> +=C2=A0 =C2=A0 monitor_qmp_set_handlers_bh(mon);
>=C2=A0 =C2=A0 =C2=A0 monitor_list_append(&mon->common);
>=C2=A0 }
>=C2=A0
> @@ -528,7 +565,7 @@ void monitor_init_qmp(Chardev *chr, bool pretty, E= rror **errp)
>=C2=A0 =C2=A0 =C2=A0 } else {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 qemu_chr_fe_set_handlers(&mon-&g= t;common.chr, monitor_can_read,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0monitor_qmp_read, mo= nitor_qmp_event,
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0NULL, &mon->common,= NULL, true);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0monitor_qmp_change, &m= on->common, NULL, true);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 monitor_list_append(&mon->com= mon);
>=C2=A0 =C2=A0 =C2=A0 }
>=C2=A0 }




--
Marc-Andr=C3=A9 Lureau
--00000000000097937e05c01839e3--