All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [PULL 31/31] qemu-option: warn for short-form boolean options
Date: Tue, 16 Feb 2021 11:43:50 +0100	[thread overview]
Message-ID: <378df6af-8383-8a51-4286-54739dba99e4@redhat.com> (raw)
In-Reply-To: <CAFEAcA_6RiR+ud5U0Y9K3jNmEoQ-Ex8fZN3-o0MkLxpK8PROgw@mail.gmail.com>

On 16/02/21 10:58, Peter Maydell wrote:
>> Unfortunately there is no way to change the code to distinguish okay
>> uses from broken ones. The fundamental issue is that QemuOpts is
>> sometimes typed and sometimes not, so it lacks the information to say
>> that "-chardev socket,server" is fine but "-device virtio-blk-pci,noserial"
>> ("set serial number to the string 'no'") is not.
>
> That is definitely a nonsensical example. But it's not clear to me
> that it's an improvement to start forbidding previously sensible and
> working command lines in order to be able to diagnose nonsensical
> command lines which it seems unlikely that anybody was ever actually
> using.

The problem with QemuOpts is twofold, in general and specifically for 
short-form boolean options.

On one hand it's the parser itself that is too permissive, because it 
applies a concept that is valid for boolean (short-form options) to all 
types.  This is the above "noserial" case.

On the other hand, the typing of QemuOpts itself is not something that 
is used a lot, especially as more and more options become a sort of 
discriminated union and therefore cannot really have a schema that is 
described in QemuOptsList and this means that it's not really possible 
to fix the other problem within QemuOpts.

The question is whether it's fixable in general.

For this to work, one would need to have a typed string->QAPI parser, 
i.e. one that takes the schema as input rather than doing a generic 
parsing to QDict and then using the schema via the visitor.  That would 
IMHO be overengineered for the purpose of saving five keystrokes on 
"server,nowait".  But even if that were possible, there are two issues:

1) the short-form "-machine kernel-irqchip" is applied not to a boolean 
but rather to an on/off/split enum.  So we would have to either 
introduce extra complication in the schema visitor to distinguish 
"extended boolean" enums from the others (and then, once we have defined 
the concept of "extended boolean enums", would we also accept yes/no in 
addition to on/off?).

2) the lexing is ambiguous.  For example virtio devices define a 
"notify_on_empty" property.  Attempting to set this property with a 
short form would fail, as it would be interpreted as 
"tify_on_empty=off".  Even worse is hw/isa/lpc_ich9.c's "noreboot" 
property (though the device is not user-creatable) for which it is 
possible to write "nonoreboot" but not "noreboot" (interpreted as 
reboot=yes).

I understand that none of these problems make it *impossible* to keep 
the short-form boolean options or even to reimplement them.  However, 
they do make me question whether they are a good idea and not just a 
historical wart.

Again, I do not plan to remove the short forms from QemuOpts.  However, 
I would like not to lock QEMU into the QemuOpts parser and its many 
issues, which are preventing a cleaner evolution of the QEMU command 
line.  (In particular I would like many command line options such as 
-smp, -m or -icount to be syntactic sugar for record properties -machine 
smp.xxx, -machine mem.xxx or -accel tcg,icount.xxx).  Even though I have 
not yet posted patches for this due to the deprecation period of 
short-form boolean options, I _did_ propose the deprecation only after 
writing a bunch of other code around command-line parsing cleanups.

Paolo



  reply	other threads:[~2021-02-16 10:45 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-23 14:30 [PULL 00/31] Misc patches for 2020-01-21 Paolo Bonzini
2021-01-23 14:30 ` [PULL 01/31] runstate: cleanup reboot and panic actions Paolo Bonzini
2021-01-23 14:30 ` [PULL 02/31] configure: MinGW respect --bindir argument Paolo Bonzini
2021-01-23 14:31 ` [PULL 03/31] x86/cpu: Use max host physical address if -cpu max option is applied Paolo Bonzini
2021-01-23 14:31 ` [PULL 04/31] build-system: clean up TCG/TCI configury Paolo Bonzini
2021-02-06 18:01   ` Philippe Mathieu-Daudé
2021-02-06 19:08     ` Philippe Mathieu-Daudé
2021-01-23 14:31 ` [PULL 05/31] util/cacheflush: Fix error generated by clang Paolo Bonzini
2021-01-23 14:31 ` [PULL 06/31] softmmu/physmem: Silence GCC 10 maybe-uninitialized error Paolo Bonzini
2021-01-23 14:31 ` [PULL 07/31] ide: atapi: check logical block address and read size (CVE-2020-29443) Paolo Bonzini
2021-01-23 14:31 ` [PULL 08/31] build-sys: remove unused LIBS Paolo Bonzini
2021-01-23 14:31 ` [PULL 09/31] build-sys: set global arguments for cflags/ldflags Paolo Bonzini
2021-01-23 14:31 ` [PULL 10/31] build-sys: add libvhost-user missing dependencies Paolo Bonzini
2021-01-23 14:31 ` [PULL 11/31] slirp: update to git master Paolo Bonzini
2021-01-23 14:31 ` [PULL 12/31] meson: Declare have_virtfs_proxy_helper in main meson.build Paolo Bonzini
2021-01-23 14:31 ` [PULL 13/31] nsis: adjust for new MinGW paths Paolo Bonzini
2021-01-23 14:31 ` [PULL 14/31] meson: convert wixl detection to Meson Paolo Bonzini
2021-01-23 14:31 ` [PULL 15/31] meson: Summarize information related to directories first Paolo Bonzini
2021-01-23 14:31 ` [PULL 16/31] meson: Display host binaries information altogether Paolo Bonzini
2021-01-23 14:31 ` [PULL 17/31] meson: Summarize overall features altogether Paolo Bonzini
2021-01-23 14:31 ` [PULL 18/31] meson: Summarize compilation-related information altogether Paolo Bonzini
2021-01-23 14:31 ` [PULL 19/31] meson: Display accelerators and selected targets altogether Paolo Bonzini
2021-01-23 14:31 ` [PULL 20/31] meson: Display block layer information altogether Paolo Bonzini
2021-01-23 14:31 ` [PULL 21/31] meson: Display crypto-related " Paolo Bonzini
2021-01-23 14:31 ` [PULL 22/31] meson: Add a section header for library dependencies Paolo Bonzini
2021-01-23 14:31 ` [PULL 23/31] meson.build: Declare global edk2_targets / install_edk2_blobs variables Paolo Bonzini
2021-01-23 14:31 ` [PULL 24/31] meson.build: Detect bzip2 program Paolo Bonzini
2021-01-23 14:31 ` [PULL 25/31] acceptance: switch to QMP change-vnc-password command Paolo Bonzini
2021-01-23 14:31 ` [PULL 26/31] hmp: remove "change vnc TARGET" command Paolo Bonzini
2021-01-23 14:31 ` [PULL 27/31] qmp: remove deprecated "change" command Paolo Bonzini
2021-01-23 14:31 ` [PULL 28/31] vnc: support "-vnc help" Paolo Bonzini
2021-01-23 14:31 ` [PULL 29/31] qemu-option: clean up id vs. list->merge_lists Paolo Bonzini
2021-01-25  7:42   ` Markus Armbruster
2021-01-25  7:58     ` Paolo Bonzini
2021-01-23 14:31 ` [PULL 30/31] qemu-option: move help handling to get_opt_name_value Paolo Bonzini
2021-01-23 14:31 ` [PULL 31/31] qemu-option: warn for short-form boolean options Paolo Bonzini
2021-02-15 19:56   ` Peter Maydell
2021-02-15 23:14     ` Paolo Bonzini
2021-02-16  9:58       ` Peter Maydell
2021-02-16 10:43         ` Paolo Bonzini [this message]
2021-02-16 11:04           ` Peter Maydell
2021-02-16 11:23             ` Paolo Bonzini
2021-02-16 11:58               ` Peter Maydell
2021-02-16 13:30                 ` Paolo Bonzini
2021-02-16 13:36                   ` Peter Maydell
2021-02-16 13:43                     ` Paolo Bonzini
2021-02-16 14:11                       ` Peter Maydell
2021-02-16 14:45                         ` Paolo Bonzini
2021-02-16 14:51                           ` Peter Maydell
2021-02-16 14:58                             ` Paolo Bonzini
2021-02-16 13:53                     ` Daniel P. Berrangé
2021-01-23 14:57 ` [PULL 00/31] Misc patches for 2020-01-21 no-reply
2021-01-23 19:52 ` Peter Maydell

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=378df6af-8383-8a51-4286-54739dba99e4@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.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.