All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>
Subject: Re: [PATCH v2 03/11] qemu-option: Remove short form options support
Date: Wed, 07 Oct 2026 09:43:03 -0300	[thread overview]
Message-ID: <87y0c97kbs.fsf@suse.de> (raw)
In-Reply-To: <87h5iyasxn.fsf@pond.sub.org>

Markus Armbruster <armbru@redhat.com> writes:

> Fabiano Rosas <farosas@suse.de> writes:
>
>> Option parameters without a value (i.e. key vs. key=val) are
>> deprecated. The missing value is currently implied to be either "on"
>> or "off" depending on whether the parameter name starts with "no".
>
> Commit ccd3b3b811 (qemu-option: warn for short-form boolean options,
> 2020-11-09).  Six years of warnings should suffice.
>
>> Remove the implied behavior and start rejecting option parameters
>> without values by emitting the error message:
>>
>>  "Parameter 'foo' without a value."
>>
>> Two special cases remain:
>>
>> 1) The 'help' parameter is special and still supported. Keep a
>>    positive value attached to it ("on").
>>
>>    Note that currently there is no validation for the value (if any)
>>    attached to the help parameter. help, help=on, help=off, help=foo
>>    all result in the help text being emitted. This is not changed by
>>    this patch.
>
> Really?
>
>     $ qemu-system-x86_64 -chardev help=foo
>     qemu-system-x86_64: -chardev help=foo: Invalid parameter 'help'
>

Ah, ok, it depends on whether the option accepts any parameter
(i.e. opts_accepts_any()). Here's -object failing to reject the bogus
value:

$ qemu-system-x86_64 -object memory-backend-ram,id=m1,help=foo
memory-backend-ram options:
  dump=<bool>            - Set to 'off' to exclude from core dump
  host-nodes=<[uint16]>  - Binds memory to the list of NUMA host nodes
  merge=<bool>           - Mark memory as mergeable
  policy=<HostMemPolicy> - Set the NUMA policy
  prealloc-context=<link<thread-context>> - Context to use for creating CPU threads for preallocation
  prealloc-threads=<int> - Number of CPU threads to use for prealloc
  prealloc=<bool>        - Preallocate memory
  reserve=<bool>         - Reserve swap space (or huge pages) if applicable
  share=<bool>           - Mark the memory as private to QEMU or shared
  size=<size>            - Size of the memory region (ex: 500M)
  x-use-canonical-path-for-ramblock-id=<bool>

>> 2) The empty value is allowed if the key is also empty. This can be
>>    achieved in the command line by adding commas.
>>    E.g.: share=on,, is parsed as:
>>      key:"share" value:"on" and
>>      key:"" value:"on"
>
> I don't think so:
>
>     $ qemu-system-x86_64 -object memory-backend-ram,id=mem0,share=on,,
>     qemu-system-x86_64: -object memory-backend-ram,id=mem0,share=on,,: Parameter 'share' expects 'on' or 'off'
>

Bah, I wrote the example for the commit message but haven't tried
it. I'm trying to refer to the single leading comma scenario, we have a
test for it:

    /* Except when it isn't */
    opts = qemu_opts_parse(&opts_list_03, ",", false, &error_abort);
    g_assert_cmpuint(opts_count(opts), ==, 1);
    g_assert_cmpstr(qemu_opt_get(opts, ""), ==, "on");

The following are parsed as valid and only reject the empty key further
down the line:

$ qemu-system-x86_64 -drive ,
qemu-system-x86_64: -drive ,: warning: short-form boolean option '' deprecated
Please use =on instead
qemu-system-x86_64: -drive ,: Must specify either driver or file

$ qemu-system-x86_64 -drive ,file=dummy
qemu-system-x86_64: -drive ,file=dummy: warning: short-form boolean option '' deprecated
Please use =on instead
WARNING: Image format was not specified for 'dummy' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
qemu-system-x86_64: -drive ,file=dummy: Block format 'raw' does not support the option ''


> Set a breakpoint on qapi_bool_parse() to see the actual value.  It's
> "on,".  In QemuOpts syntax, double comma is an escape, so you can put
> comma in values.
>
>> One effect of this change that might not be obvious is that parameter
>> combinations of the form:
>>
>>  id=mem0,share,help
>>
>> no longer produce the help output. The lack of value for the 'share'
>> parameter is reported with precedence. Users will need to either use a
>> valid value or omit the parameter entirely:
>>
>>  id=mem0,share=on,help
>>  id=mem0,help
>
> That's unfortunate.
>
> [...]


  reply	other threads:[~2026-10-07 12:43 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 22:10 [PATCH v2 00/11] qemu-options: Spring cleanup Fabiano Rosas
2026-09-30 22:10 ` [PATCH v2 01/11] qemu-option: Use g_autofree when calling get_opt_name_value() Fabiano Rosas
2026-10-01  9:42   ` marcandre.lureau
2026-09-30 22:10 ` [PATCH v2 02/11] tests/unit/test-qemu-opts: Validate help=foo options Fabiano Rosas
2026-10-01  9:42   ` marcandre.lureau
2026-09-30 22:10 ` [PATCH v2 03/11] qemu-option: Remove short form options support Fabiano Rosas
2026-10-01  9:42   ` marcandre.lureau
2026-10-07  7:08   ` Markus Armbruster
2026-10-07 12:43     ` Fabiano Rosas [this message]
2026-10-08  4:42       ` Markus Armbruster
2026-10-10  0:04         ` Fabiano Rosas
2026-10-07  8:16   ` Markus Armbruster
2026-09-30 22:10 ` [PATCH v2 04/11] qemu-option: Fix 'help' parameter parsing Fabiano Rosas
2026-10-01  9:42   ` marcandre.lureau
2026-10-01 15:43     ` Fabiano Rosas
2026-09-30 22:10 ` [PATCH v2 05/11] qemu-option: Add qemu_opts_parse_list Fabiano Rosas
2026-10-01  9:42   ` marcandre.lureau
2026-09-30 22:11 ` [PATCH v2 06/11] qemu-option: Change qemu_parse_opts() to take the group name Fabiano Rosas
2026-10-01  9:42   ` marcandre.lureau
2026-09-30 22:11 ` [PATCH v2 07/11] qemu-option: Add qemu_opts_parse_list_noisily Fabiano Rosas
2026-10-01  9:42   ` marcandre.lureau
2026-10-07 12:54   ` Eric Blake
2026-09-30 22:11 ` [PATCH v2 08/11] qemu-option: Use qemu_opts_parse_list_noisily where appropriate Fabiano Rosas
2026-10-01  9:42   ` marcandre.lureau
2026-09-30 22:11 ` [PATCH v2 09/11] qemu-option: Change qemu_opts_parse_noisily() to take the group Fabiano Rosas
2026-10-01  9:42   ` marcandre.lureau
2026-10-07 12:54   ` Eric Blake
2026-09-30 22:11 ` [PATCH v2 10/11] qemu-option: Check for NULL list at qemu_opts_parse() Fabiano Rosas
2026-10-01  9:42   ` marcandre.lureau
2026-09-30 22:11 ` [PATCH v2 11/11] qemu-option: Remove a few instances of noisily parsing Fabiano Rosas
2026-10-01  9:42   ` marcandre.lureau

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=87y0c97kbs.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pierrick.bouvier@oss.qualcomm.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.