qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Amos Kong <akong@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: libvirt-list@redhat.com, qemu-devel@nongnu.org, jyang@redhat.com,
	pbonzini@redhat.com, lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH v4 2/2] query-command-line-options: query all the options in qemu-options.hx
Date: Thu, 27 Mar 2014 13:09:32 +0800	[thread overview]
Message-ID: <20140327050932.GA29264@amosk.info> (raw)
In-Reply-To: <20140320141243.GC2693@amosk.info>

On Thu, Mar 20, 2014 at 10:12:43PM +0800, Amos Kong wrote:
> On Tue, Mar 11, 2014 at 10:04:56AM +0100, Markus Armbruster wrote:
> > Eric Blake <eblake@redhat.com> writes:
> > 
> > > On 03/07/2014 02:54 AM, Markus Armbruster wrote:
> > >> Eric Blake <eblake@redhat.com> writes:
> > >> 
> > >>> On 03/05/2014 07:36 PM, Amos Kong wrote:
> > >>>> vm_config_groups[] only contains part of the options which have
> > >>>> argument, and all options which have no argument aren't added
> > >>>> to vm_config_groups[]. Current query-command-line-options only
> > >>>> checks options from vm_config_groups[], so some options will
> > >>>> be lost.
> > >>>>
> > >
> > >>    Example: -device takes unspecified parameters.  -cdrom doesn't take
> > >>    parameters, it takes a file name.  Yet, the command reports the same
> > >>    for both: "parameters": [], "argument": true.
> > >> 
> > >>    Looks like we need a tri-state: option takes no argument, QemuOpts
> > >>    argument, or other argument.
> > >
> > > I don't buy that.  '-cdrom filename' could easily be re-written [in a
> > > future qemu version] to use QemuOpts with an implied parameter name
> > > (we've done that elsewhere, such as for '-machine').  In other words, I
> > > think we could make it become shorthand for '-cdrom file=filename', at
> > > which point the QemuOpts spelling is available and would now show up as
> > > "parameters":[{"name":"file"...}].  Thus, in converting -cdrom to
> > > QemuOpts, we can still maintain command-line back-compat, while making
> > > the query-command-line-options output more featureful.  In other words,
> > > _for now_ it takes unspecified parameters, and the fact that it is only
> > > a single parameter in the form 'filename' rather than a more typical
> > > parameter 'file=filename' is not a show-stopper.
> > 
> > Incompatible change for funny filenames: -cdrom you,break=me.
> > 
> > Besides breaking funny filenames, we'd also buy ourselves some stupid
> > -readconfig / -writeconfig trouble.  Let me explain.
> > 
> > -cdrom F is effectively sugar for "-drive media=cdrom,index=2,file=FF",
> > where FF is F with comma doubled.
> > 
> > -writeconfig writes out desugared QemuOpts.  Therefore, "-cdrom r7.iso"
> > gets written as
> > 
> >     [drive]
> >       media = "cdrom"
> >       index = "2"
> >       file = "r7.iso"
> > 
> > which -readconfig can read.
> > 
> > If we convert -cdrom to QemuOpts, it gets written out like this:
> > 
> >     [cdrom]
> >        file = "r7.iso"
> > 
> > If we continue to desugar it, it'll *also* get written out as before.
> > Either we *delete* the sugared QemuOpts to avoid duplication, or we
> > *stop* desugaring.  The latter breaks -readconfig of existing
> > configuration files, and complicates the code reading configuration from
> > QemuOpts.
> > 
> > I don't think any of the old non-QemuOpts options that have become sugar
> > for newer, more flexible QemuOpts options should be converted to
> > QemuOpts.
> > 
> > > So your idea of a tri-state (QemuOpts, no argument, or other argument)
> > > doesn't add anything - any option that takes "other argument" could be
> > > converted to take QemuOpts, and from the command line, we can't tell the
> > > difference from whether something was implemented by QemuOpts, only by
> > > whether we have introspection on what the argument consists of.
> > 
> > I doubt we can convert all existing options to QemuOpts without breaking
> > backward compatibility and complicating the code.
> > 
> > > Meanwhile, it DOES point out that our use of implicit argument in
> > > QemuOpts ought to be exposed to the introspection mechanism, for
> > > introspection to be fully descriptive.  That is, maybe we should modify
> > > our introspection to add a new 'implied-name':
> > >
> > > ##
> > > # @CommandLineParameterInfo:
> > > #
> > > ...
> > > # @implied-name: #optional, if present and true, the parameter can be
> > > #                specified as '-option value' instead of the preferred
> > > #                spelling of '-option name=value' (since 2.0)
> > > # Since 1.5
> > > { 'type': 'CommandLineParameterInfo',
> > >   'data': { 'name': 'str',
> > >             'type': 'CommandLineParameterType',
> > >             '*help': 'str', '*implied-name': 'bool' } }
  
reply-myself

> How can we get this information? it's not good to rely on the help message.
> 
> And the parameters [] only have content when the option have a non-NULL desc
> table, so we always just return a NULL parameters list, the 'implied-name'
> information will be lost.

I'm wrong, 'implied-name' is attribute of parameter, it's stored in
QemuOptsList.implied_opt_name.

I will add this filed in V6.
 
> I thinks Markus's suggestion is fine, we can use tri-state (no-arg,
> unsuecified-para-arg, no-para-arg).

Thanks, Amos
 
> > The only use for implied-name I can think of is interpreting a user's
> > command line.  Is that a real use case?
> 
>  
> > >> 
> > >>    parameters is [] unless it's a QemuOpts argument.  Then it lists the
> > >>    recognized parameters.
> > >
> > > This part is still true.  When parameters[] is non-empty, it is a
> > > QemuOpts and we know all recognized parameters (well, more precisely,
> > > the subset of QemuOpts that were explicitly called out - given your
> > > point 2 about the mess of -drive); when it is empty, then all we know is
> > > whether the argument is a boolean or takes unspecified arguments (where
> > > the conversion of those unknown arguments to QemuOpts will be what
> > > finally lets us introspect the format of those unknown arguments).
> > 
> > QemuOpts argument with only unspecified parameters is not the same as
> > non-QemuOpts argument.  I don't think conflating the two is useful.

  reply	other threads:[~2014-03-27  5:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-06  2:36 [Qemu-devel] [PATCH v4 0/2] fix query-command-line-options Amos Kong
2014-03-06  2:36 ` [Qemu-devel] [PATCH v4 1/2] qmp: rename query_option_descs() to get_param_infolist() Amos Kong
2014-03-06  2:36 ` [Qemu-devel] [PATCH v4 2/2] query-command-line-options: query all the options in qemu-options.hx Amos Kong
2014-03-06 10:50   ` Markus Armbruster
2014-03-06 21:23   ` Eric Blake
2014-03-07  6:09     ` Amos Kong
2014-03-07  9:54     ` Markus Armbruster
2014-03-10 17:41       ` Eric Blake
2014-03-11  9:04         ` Markus Armbruster
2014-03-11 14:46           ` Eric Blake
2014-03-20 14:12           ` Amos Kong
2014-03-27  5:09             ` Amos Kong [this message]
2014-03-20 14:03       ` Amos Kong
2014-03-20 14:51         ` Amos Kong
2014-03-26 13:15         ` Markus Armbruster
2014-03-27  5:04           ` Amos Kong
2014-03-27  9:46             ` Markus Armbruster
2014-03-07  9:56   ` 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=20140327050932.GA29264@amosk.info \
    --to=akong@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jyang@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=libvirt-list@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 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).