All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: jsnow@redhat.com, "Daniel P. Berrangé" <berrange@redhat.com>,
	qemu-devel@nongnu.org, armbru@redhat.com
Subject: Re: Command line QAPIfication and -readconfig
Date: Wed, 11 Nov 2020 16:29:23 +0100	[thread overview]
Message-ID: <20201111152923.GD3898@merkur.fritz.box> (raw)
In-Reply-To: <0471d35c-6fbc-c3e8-a2c3-b627a1ec2ece@redhat.com>

Am 11.11.2020 um 14:06 hat Paolo Bonzini geschrieben:
> On 11/11/20 13:53, Kevin Wolf wrote:
> > QDicts are one step closer to the final result, but would also have to
> > be processed separately as they need only half of the processing that
> > command line options need. Eventually, qobject_input_visitor_new_str()
> > is what we want to use to parse strings directly into QAPI objects, and
> > QDicts are only an internal intermediate result there.
> 
> To be clearer, the processing would look like this:
> 
> - both qemu_config_parse and qemu_read_config_file call a static function
> qemu_config_foreach
> 
> - qemu_config_foreach builds a QDict and passes it to a callback
> 
> qemu_read_config_file receives a callback argument from vl.c, while
> qemu_config_parse uses a default callback that does qemu_opts_create and
> qemu_opts_absorb_qdict.
> 
> The callback in vl.c does this:
> 
> 1) for a keyval-based non-mergeable option (e.g. -object) -> do
> qdict_crumple and store the QDict for later processing.
> 
> 2) for a keyval-based mergeable option (e.g. -M) -> do qdict_crumple and
> merge with previous command-line options using a new function keyval_merge

Ah, I wasn't even aware of this type of option, so thanks for mentioning
it here. (It makes sense to me.)

> 3) for non-keyval options -> forward to the default callback used by
> qemu_config_parse.
> 
> 
> Later on, keyval-based options are parsed into QAPI objects or QOM
> properties using qobject_input_visitor_new_keyval.

Yes, no question this is doable, it just requires some extra code for
each option instead of reusing something existing. But it's not too bad
as QDicts are at least slightly more natural for a QAPI based interface
than QemuOpts.

> > So while it's even uglier, maybe what we should do with -readconfig is
> > convert it back to strings and then run the result through the normal
> > command line processing? This would get rid of the special cases.
> 
> That would be more or less doable but there are two problems: 1) the
> -readconfig code is used for blkdebug too, so you would need some kind of
> callback anyway

Whether it's a callback or an iterator shouldn't make a big difference.
blkdebug can easily use either.

And whether the data is QemuOpts, QDict or a string shouldn't make much
of a difference either because it can just run a visitor on any of them
and get back the QAPI BlkdebugFoo types that it should be using anyway.

> 2) converting to strings is not entirely trivial due to e.g.
> different spelling between the "-boot" command line option and the
> "boot-opts" group.

Hm, where is the difference between both? The QEMU_OPTION_boot case
seems to just directly parse optarg into "boot-opts" with
qemu_opts_parse_noisily(), which should be the same as -readconfig does
with its input, no?

> > Both options are probably only hacks for the short term, so either way I
> > think I'd still prefer deprecating -readconfig now, in favour of command
> > line options as long as we don't have a QAPI based config file.
> 
> "Now" is a bit too late for 5.2.  I would like to deprecate "-set" for that
> matter too, but it's so obscure that I'm thinking of just dropping it in
> 6.0.

Even if we queue the -readconfig deprecation only for 6.0, that's still
fine. I just don't want to discuss one year from now how we should have
deprecated it long ago.

Kevin



  reply	other threads:[~2020-11-11 15:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11  9:24 Command line QAPIfication and -readconfig Kevin Wolf
2020-11-11 10:14 ` Daniel P. Berrangé
2020-11-11 10:35   ` Kevin Wolf
2020-11-11 11:07     ` Paolo Bonzini
2020-11-11 12:53       ` Kevin Wolf
2020-11-11 13:06         ` Paolo Bonzini
2020-11-11 15:29           ` Kevin Wolf [this message]
2020-11-11 16:39             ` Paolo Bonzini
2020-11-12 14:14     ` Andrea Bolognani

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=20201111152923.GD3898@merkur.fritz.box \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=pbonzini@redhat.com \
    --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.