audio: add help option (?) for -audiodev
PATCH 1/1 audio: add help option (?) for -audiodev
add a simple help option for -audiodev, so users can do
qemu -audiodev ?
to get the list of drivers available.
--- audio/audio.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
audio/audio.c +20 -0
@@ -32,6 +32,7 @@#include "qapi/qapi-visit-audio.h" #include "qemu/cutils.h" #include "qemu/module.h" +#include "qemu/help_option.h" #include "sysemu/sysemu.h" #include "sysemu/replay.h" #include "sysemu/runstate.h"
@@ -2105,10 +2106,29 @@ static void audio_validate_opts(Audiodev *dev, Error **errp) } } +static void audio_help (void ) +{ +int i; + +printf ("Available audiodev types:\n" ); +printf ("none\n" ); + +for (i =0 ; audio_prio_list[i]; i++) { +audio_driver *driver =audio_driver_lookup (audio_prio_list[i]); +if (driver) { +printf ("%s\n" , driver->name); + } + } +} +void audio_parse_option (const char *opt) {Audiodev *dev =NULL ; +if (is_help_option (opt)) { +audio_help (); +exit (0 ); + }Visitor *v =qobject_input_visitor_new_str (opt,"driver" , &error_fatal);visit_type_Audiodev (v,NULL , &dev, &error_fatal);visit_free (v);
Signature · 1 line
2.26.2
Quoted 3 lines · Claudio Fontana
add a simple help option for -audiodev, so users can do
qemu -audiodev ?
The preferred form is actually '-audiodev help'. The other one is deprecated. Recommend to stay away from it even in commit messages.
Quoted 50 lines
to get the list of drivers available.
Signed-off-by Claudio Fontana <[email protected]>--- audio/audio.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)audio/audio.c +20
-0@@ -32,6 +32,7 @@#include "qapi/qapi-visit-audio.h" #include "qemu/cutils.h" #include "qemu/module.h" +#include "qemu/help_option.h" #include "sysemu/sysemu.h" #include "sysemu/replay.h" #include "sysemu/runstate.h" @@ -2105,10 +2106,29 @@ static void audio_validate_opts(Audiodev *dev, Error **errp) } } +static void audio_help (void ) +{ +int i; + +printf ("Available audiodev types:\n" ); +printf ("none\n" ); + +for (i =0 ; audio_prio_list[i]; i++) { +audio_driver *driver =audio_driver_lookup (audio_prio_list[i]); +if (driver) { +printf ("%s\n" , driver->name); + } + } +} +void audio_parse_option (const char *opt) {Audiodev *dev =NULL ; +if (is_help_option (opt)) { +audio_help (); +exit (0 ); + }Visitor *v =qobject_input_visitor_new_str (opt,"driver" , &error_fatal);visit_type_Audiodev (v,NULL , &dev, &error_fatal);visit_free (v);
Quoted 8 lines · Markus Armbruster
Quoted 3 lines · Claudio Fontana
add a simple help option for -audiodev, so users can do
qemu -audiodev ?
The preferred form is actually '-audiodev help'. The other one is deprecated. Recommend to stay away from it even in commit messages.
We introduced 'help' many many years ago, but don't thing we ever formally deprecated '?'. Should we do so and aim to remove it, or are we happy to keep '?' forever, despite it tripping up shell filename expansion with single char filenames.
(tangential to this patch, NOT a request to fix something in v2)
Quoted 7 lines
Quoted 7 lines
to get the list of drivers available.
Signed-off-by Claudio Fontana <[email protected]>--- audio/audio.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
Update qemu-options.hx ?
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 7 lines · Daniel P. Berrangé
Quoted 6 lines · Markus Armbruster
Quoted 3 lines · Claudio Fontana
add a simple help option for -audiodev, so users can do
qemu -audiodev ?
Quoted 7 lines
Quoted 2 lines
The preferred form is actually '-audiodev help'. The other one is deprecated. Recommend to stay away from it even in commit messages.
We introduced 'help' many many years ago, but don't thing we ever formally deprecated '?'. Should we do so and aim to remove it, or are we happy to keep '?' forever, despite it tripping up shell filename expansion with single char filenames.
Had this conversation before and I think we agreed to keep ? as a convenient shorthand even if help is preferred so it should not be deprecated but you can keep it from appearing in docs to advertise help as the preferred option. (\? is still shorter to type than help if you're worried about shell expansion which is rarely a problem in practice)
Regards,
BALATON Zoltan
Quoted 16 lines
(tangential to this patch, NOT a request to fix something in v2)
Quoted 7 lines
Quoted 7 lines
to get the list of drivers available.
Signed-off-by Claudio Fontana <[email protected]>--- audio/audio.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)Update qemu-options.hx ?
With regards,
Daniel
Quoted 5 lines · Daniel P. Berrangé
Quoted 4 lines · Markus Armbruster
Quoted 2 lines · Claudio Fontana
add a simple help option for -audiodev, so users can do
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
qemu -audiodev ?
The preferred form is actually '-audiodev help'. The other one is deprecated. Recommend to stay away from it even in commit messages.
We introduced 'help' many many years ago, but don't thing we ever formally deprecated '?'.
is_help_option()'s function comment says "'?' is deprecated". Goes back to
commit c8057f951d64de93bfd01569c0a725baa9f94372
Author: Peter Maydell <[email protected]> Date: Thu Aug 2 13:45:54 2012 +0100
Support 'help' as a synonym for '?' in command line options
For command line options which permit '?' meaning 'please list the permitted values', add support for 'help' as a synonym, by abstracting the check out into a helper function.
This change means that in some cases where we were being lazy in our string parsing, "?junk" will now be rejected as an invalid option rather than being (undocumentedly) treated the same way as "?".
Update the documentation to use 'help' rather than '?', since '?' is a shell metacharacter and thus prone to fail confusingly if there is a single character filename in the current working directory and the '?' has not been escaped. It's therefore better to steer users towards 'help', though '?' is retained for backwards compatibility.
We do not, however, update the output of the system emulator's -help (or any documentation autogenerated from the qemu-options.hx which is the source of the -help text) because libvirt parses our -help output and will break. At a later date when QEMU provides a better interface so libvirt can avoid having to do this, we can update the -help text too.
The more formal deprecation process we use today didn't exist in 2012. Looks like we simply de-documented '?'.
Note that output of -help has been updated since.
Quoted 3 lines
Should we do so and aim to
remove it, or are we happy to keep '?' forever, despite it tripping up shell filename expansion with single char filenames.
I'm not sure a belated formal notice of deprecation would be useful.
Emitting a warning might be. Would have to be done at roughly 20 call sites, I guess.
I'm cool with removing a feature that has been undocumented for a decade. However, experience tells us that every feature on the chopping block will find a champion, and I believe this one is still around simply because it's not worth a fight.
[...]
Quoted 8 lines · Markus Armbruster
Quoted 3 lines · Claudio Fontana
add a simple help option for -audiodev, so users can do
qemu -audiodev ?
The preferred form is actually '-audiodev help'. The other one is deprecated. Recommend to stay away from it even in commit messages.
I have no problem mentioning "help" instead of "?" in the commit message (or both).
The function used (is_help_option) checks for both, which seems the best way to me.
Ciao
C
Quoted 52 lines
Quoted 51 lines
to get the list of drivers available.
Signed-off-by Claudio Fontana <[email protected]>--- audio/audio.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)audio/audio.c +20
-0@@ -32,6 +32,7 @@#include "qapi/qapi-visit-audio.h" #include "qemu/cutils.h" #include "qemu/module.h" +#include "qemu/help_option.h" #include "sysemu/sysemu.h" #include "sysemu/replay.h" #include "sysemu/runstate.h" @@ -2105,10 +2106,29 @@ static void audio_validate_opts(Audiodev *dev, Error **errp) } } +static void audio_help (void ) +{ +int i; + +printf ("Available audiodev types:\n" ); +printf ("none\n" ); + +for (i =0 ; audio_prio_list[i]; i++) { +audio_driver *driver =audio_driver_lookup (audio_prio_list[i]); +if (driver) { +printf ("%s\n" , driver->name); + } + } +} +void audio_parse_option (const char *opt) {Audiodev *dev =NULL ; +if (is_help_option (opt)) { +audio_help (); +exit (0 ); + }Visitor *v =qobject_input_visitor_new_str (opt,"driver" , &error_fatal);visit_type_Audiodev (v,NULL , &dev, &error_fatal);visit_free (v);