From: Kevin Wolf <kwolf@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-block@nongnu.org, marcandre.lureau@gmail.com,
qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [PATCH v3 1/4] qapi: Add a 'coroutine' flag for commands
Date: Thu, 16 Jan 2020 16:02:14 +0100 [thread overview]
Message-ID: <20200116150214.GH9470@linux.fritz.box> (raw)
In-Reply-To: <871rrzy2sg.fsf@dusky.pond.sub.org>
Am 16.01.2020 um 14:00 hat Markus Armbruster geschrieben:
> Kevin Wolf <kwolf@redhat.com> writes:
> > I have no idea if we will eventually get a case where the command wants
> > to behave different between the two modes and actually has use for a
> > coroutine. I hope not.
> >
> > But using two bools rather than a single enum keeps the code simple and
> > leaves us all options open if it turns out that we do have a use case.
>
> I can buy the argument "the two are conceptually orthogonal, although we
> don't haven't found a use for one of the four cases".
>
> Let's review the four combinations of the two flags once more:
>
> * allow-oob: false, coroutine: false
>
> Handler runs in main loop, outside coroutine context. Okay.
>
> * allow-oob: false, coroutine: true
>
> Handler runs in main loop, in coroutine context. Okay.
>
> * allow-oob: true, coroutine: false
>
> Handler may run in main loop or in iothread, outside coroutine
> context. Okay.
>
> * allow-oob: true, coroutine: true
>
> Handler may run (in main loop, in coroutine context) or (in iothread,
> outside coroutine context). This "in coroutine context only with
> execute, not with exec-oob" behavior is a bit surprising.
>
> We could document it, noting that it may change to always run in
> coroutine context. Or we simply reject this case as "not
> implemented". Since we have no uses, I'm leaning towards reject. One
> fewer case to test then.
What would be the right mode of rejecting it?
I assume we should catch it somewhere in the QAPI generator (where?) and
then just assert in the C code that both flags aren't set at the same
time?
> >> > @@ -194,8 +195,9 @@ out:
> >> > return ret
> >> >
> >> >
> >> > -def gen_register_command(name, success_response, allow_oob, allow_preconfig):
> >> > - options = []
> >> > +def gen_register_command(name: str, success_response: bool, allow_oob: bool,
> >> > + allow_preconfig: bool, coroutine: bool) -> str:
> >> > + options = [] # type: List[str]
>
> One more: this is a PEP 484 type hint. With Python 3, we can use PEP
> 526 instead:
>
> options: List[str] = []
>
> I think we should.
This requires Python 3.6, unfortunately. The minimum requirement for
building QEMU is 3.5.
> >> Some extra churn due to type hints here. Distracting. Suggest not to
> >> mix adding type hints to existing code with feature work.
> >
> > If you would be open for a compromise, I could leave options
> > unannotated, but keep the typed parameter list.
>
> Keeping just the function annotation is much less distracting. I can't
> reject that with a "separate patches for separate things" argument.
>
> I'd still prefer not to, because:
>
> * If we do add systematic type hints in the near future, then delaying
> this one until then shouldn't hurt your productivity.
>
> * If we don't, this lone one won't help your productivity much, but
> it'll look out of place.
>
> I really don't want us to add type hints as we go, because such
> open-ended "while we touch it anyway" conversions take forever and a
> day. Maximizes the confusion integral over time.
I think it's a first time that I'm asked not to document things, but
I'll remove them.
Kevin
next prev parent reply other threads:[~2020-01-16 15:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-15 12:23 [PATCH v3 0/4] qmp: Optionally run handlers in coroutines Kevin Wolf
2020-01-15 12:23 ` [PATCH v3 1/4] qapi: Add a 'coroutine' flag for commands Kevin Wolf
2020-01-15 14:59 ` Markus Armbruster
2020-01-15 15:58 ` Kevin Wolf
2020-01-16 13:00 ` Markus Armbruster
2020-01-16 15:02 ` Kevin Wolf [this message]
2020-01-17 7:57 ` Markus Armbruster
2020-01-17 9:40 ` Kevin Wolf
2020-01-17 10:43 ` Markus Armbruster
2020-01-17 11:08 ` Kevin Wolf
2020-01-17 7:50 ` Markus Armbruster
2020-01-15 12:23 ` [PATCH v3 2/4] vl: Initialise main loop earlier Kevin Wolf
2020-01-15 16:26 ` Markus Armbruster
2020-01-15 12:23 ` [PATCH v3 3/4] qmp: Move dispatcher to a coroutine Kevin Wolf
2020-01-17 12:20 ` Markus Armbruster
2020-01-17 14:03 ` Kevin Wolf
2020-01-15 12:23 ` [PATCH v3 4/4] block: Mark 'block_resize' as coroutine Kevin Wolf
2020-01-16 9:45 ` Markus Armbruster
2020-01-16 10:13 ` Kevin Wolf
2020-01-16 15:13 ` Markus Armbruster
2020-01-16 15:23 ` Kevin Wolf
2020-01-17 5:44 ` Markus Armbruster
2020-01-17 9:24 ` Kevin Wolf
2020-01-17 10:46 ` Markus Armbruster
2020-01-17 8:13 ` Markus Armbruster
2020-01-17 9:13 ` Kevin Wolf
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=20200116150214.GH9470@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 \
--cc=stefanha@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).