From: Kevin Wolf <kwolf@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: marcandre.lureau@gmail.com, qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH v5 3/4] qmp: Move dispatcher to a coroutine
Date: Mon, 23 Mar 2020 18:41:08 +0100 [thread overview]
Message-ID: <20200323174108.GD8049@linux.fritz.box> (raw)
In-Reply-To: <87d09965g3.fsf@dusky.pond.sub.org>
Am 18.03.2020 um 16:36 hat Markus Armbruster geschrieben:
> Kevin Wolf <kwolf@redhat.com> writes:
>
> > This moves the QMP dispatcher to a coroutine and runs all QMP command
> > handlers that declare 'coroutine': true in coroutine context so they
> > can avoid blocking the main loop while doing I/O or waiting for other
> > events.
> >
> > For commands that are not declared safe to run in a coroutine, the
> > dispatcher drops out of coroutine context by calling the QMP command
> > handler from a bottom half.
> >
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>
> Uh, what about @cur_mon?
>
> @cur_mon points to the current monitor while a command executes.
> Initial value is null. It is set in three places (not counting unit
> tests), and all three save, set, do something that may use @cur_mon,
> restore:
>
> * monitor_qmp_dispatch(), for use within qmp_dispatch()
> * monitor_read(), for use within handle_hmp_command()
> * qmp_human_monitor_command(), also for use within handle_hmp_command()
>
> Therefore, @cur_mon is null unless we're running within qmp_dispatch()
> or handle_hmp_command().
Can we make it NULL for coroutine-enabled handlers?
> Example of use: error_report() & friends print "to current monitor if we
> have one, else to stderr." Makes sharing code between HMP and CLI
> easier. Uses @cur_mon under the hood.
error_report() eventually prints to stderr both for cur_mon == NULL and
for QMP monitors. Is there an important difference between both cases?
There is error_vprintf_unless_qmp(), which behaves differently for both
cases. However, it is only used in VNC code, so that code would have to
keep coroutines disabled.
Is cur_mon used much in other functions called by QMP handlers?
> @cur_mon is thread-local.
>
> I'm afraid we have to save, clear and restore @cur_mon around a yield.
That sounds painful enough that I'd rather avoid it.
Kevin
next prev parent reply other threads:[~2020-03-23 17:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 15:40 [PATCH v5 0/4] qmp: Optionally run handlers in coroutines Kevin Wolf
2020-02-18 15:40 ` [PATCH v5 1/4] qapi: Add a 'coroutine' flag for commands Kevin Wolf
2020-03-03 8:10 ` Markus Armbruster
2020-03-03 11:40 ` Kevin Wolf
2020-02-18 15:40 ` [PATCH v5 2/4] vl: Initialise main loop earlier Kevin Wolf
2020-02-19 14:07 ` Wolfgang Bumiller
2020-02-19 14:57 ` Kevin Wolf
2020-02-18 15:40 ` [PATCH v5 3/4] qmp: Move dispatcher to a coroutine Kevin Wolf
2020-03-03 8:49 ` Markus Armbruster
2020-03-03 11:35 ` Kevin Wolf
2020-03-18 15:36 ` Markus Armbruster
2020-03-23 17:41 ` Kevin Wolf [this message]
2020-03-23 18:03 ` Marc-André Lureau
2020-03-30 12:33 ` Markus Armbruster
2020-03-30 12:30 ` Markus Armbruster
2020-02-18 15:40 ` [PATCH v5 4/4] block: Mark 'block_resize' as coroutine Kevin Wolf
2020-03-03 15:33 ` [PATCH v5 0/4] qmp: Optionally run handlers in coroutines Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200323174108.GD8049@linux.fritz.box \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.