All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] audio: add help option (?) for -audiodev
@ 2022-09-07 14:23 Claudio Fontana
  2022-09-07 15:06 ` Markus Armbruster
  0 siblings, 1 reply; 6+ messages in thread
From: Claudio Fontana @ 2022-09-07 14:23 UTC (permalink / raw)
  To: Gerd Hoffmann, Philippe Mathieu-Daudé,
	Christian Schoenebeck, Akihiko Odaki
  Cc: Claudio Fontana, qemu-devel, Richard Henderson

add a simple help option for -audiodev, so users can do

qemu -audiodev ?

to get the list of drivers available.

Signed-off-by: Claudio Fontana <cfontana@suse.de>
---
 audio/audio.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/audio/audio.c b/audio/audio.c
index 4f4bb10cce..bd8c18c3cd 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -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);
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] audio: add help option (?) for -audiodev
  2022-09-07 14:23 [PATCH] audio: add help option (?) for -audiodev Claudio Fontana
@ 2022-09-07 15:06 ` Markus Armbruster
  2022-09-07 15:22   ` Daniel P. Berrangé
  2022-09-07 15:56   ` Claudio Fontana
  0 siblings, 2 replies; 6+ messages in thread
From: Markus Armbruster @ 2022-09-07 15:06 UTC (permalink / raw)
  To: Claudio Fontana
  Cc: Gerd Hoffmann, Philippe Mathieu-Daudé,
	Christian Schoenebeck, Akihiko Odaki, qemu-devel,
	Richard Henderson

Claudio Fontana <cfontana@suse.de> writes:

> 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.

>
> to get the list of drivers available.
>
> Signed-off-by: Claudio Fontana <cfontana@suse.de>
> ---
>  audio/audio.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>
> diff --git a/audio/audio.c b/audio/audio.c
> index 4f4bb10cce..bd8c18c3cd 100644
> --- a/audio/audio.c
> +++ b/audio/audio.c
> @@ -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);



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] audio: add help option (?) for -audiodev
  2022-09-07 15:06 ` Markus Armbruster
@ 2022-09-07 15:22   ` Daniel P. Berrangé
  2022-09-07 16:07     ` BALATON Zoltan
  2022-09-08  5:20     ` Markus Armbruster
  2022-09-07 15:56   ` Claudio Fontana
  1 sibling, 2 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2022-09-07 15:22 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Claudio Fontana, Gerd Hoffmann, Philippe Mathieu-Daudé,
	Christian Schoenebeck, Akihiko Odaki, qemu-devel,
	Richard Henderson

On Wed, Sep 07, 2022 at 05:06:36PM +0200, Markus Armbruster wrote:
> Claudio Fontana <cfontana@suse.de> writes:
> 
> > 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)

> >
> > to get the list of drivers available.
> >
> > Signed-off-by: Claudio Fontana <cfontana@suse.de>
> > ---
> >  audio/audio.c | 20 ++++++++++++++++++++
> >  1 file changed, 20 insertions(+)

Update qemu-options.hx ?


With regards,
Daniel
-- 
|: 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 :|



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] audio: add help option (?) for -audiodev
  2022-09-07 15:06 ` Markus Armbruster
  2022-09-07 15:22   ` Daniel P. Berrangé
@ 2022-09-07 15:56   ` Claudio Fontana
  1 sibling, 0 replies; 6+ messages in thread
From: Claudio Fontana @ 2022-09-07 15:56 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Gerd Hoffmann, Philippe Mathieu-Daudé,
	Christian Schoenebeck, Akihiko Odaki, qemu-devel,
	Richard Henderson

On 9/7/22 17:06, Markus Armbruster wrote:
> Claudio Fontana <cfontana@suse.de> writes:
> 
>> 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

> 
>>
>> to get the list of drivers available.
>>
>> Signed-off-by: Claudio Fontana <cfontana@suse.de>
>> ---
>>  audio/audio.c | 20 ++++++++++++++++++++
>>  1 file changed, 20 insertions(+)
>>
>> diff --git a/audio/audio.c b/audio/audio.c
>> index 4f4bb10cce..bd8c18c3cd 100644
>> --- a/audio/audio.c
>> +++ b/audio/audio.c
>> @@ -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);
> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] audio: add help option (?) for -audiodev
  2022-09-07 15:22   ` Daniel P. Berrangé
@ 2022-09-07 16:07     ` BALATON Zoltan
  2022-09-08  5:20     ` Markus Armbruster
  1 sibling, 0 replies; 6+ messages in thread
From: BALATON Zoltan @ 2022-09-07 16:07 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: Markus Armbruster, Claudio Fontana, Gerd Hoffmann,
	Philippe Mathieu-Daudé,
	Christian Schoenebeck, Akihiko Odaki, qemu-devel,
	Richard Henderson

[-- Attachment #1: Type: text/plain, Size: 1350 bytes --]

On Wed, 7 Sep 2022, Daniel P. Berrangé wrote:
> On Wed, Sep 07, 2022 at 05:06:36PM +0200, Markus Armbruster wrote:
>> Claudio Fontana <cfontana@suse.de> writes:
>>
>>> 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.

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

> (tangential to this patch, NOT a request to fix something in v2)
>
>>>
>>> to get the list of drivers available.
>>>
>>> Signed-off-by: Claudio Fontana <cfontana@suse.de>
>>> ---
>>>  audio/audio.c | 20 ++++++++++++++++++++
>>>  1 file changed, 20 insertions(+)
>
> Update qemu-options.hx ?
>
>
> With regards,
> Daniel
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] audio: add help option (?) for -audiodev
  2022-09-07 15:22   ` Daniel P. Berrangé
  2022-09-07 16:07     ` BALATON Zoltan
@ 2022-09-08  5:20     ` Markus Armbruster
  1 sibling, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2022-09-08  5:20 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: Claudio Fontana, Gerd Hoffmann, Philippe Mathieu-Daudé,
	Christian Schoenebeck, Akihiko Odaki, qemu-devel,
	Richard Henderson

Daniel P. Berrangé <berrange@redhat.com> writes:

> On Wed, Sep 07, 2022 at 05:06:36PM +0200, Markus Armbruster wrote:
>> Claudio Fontana <cfontana@suse.de> writes:
>> 
>> > 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 '?'.

is_help_option()'s function comment says "'?' is deprecated".  Goes back
to

commit c8057f951d64de93bfd01569c0a725baa9f94372
Author: Peter Maydell <peter.maydell@linaro.org>
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.
    
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

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.

>                                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.

[...]



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-08  5:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-07 14:23 [PATCH] audio: add help option (?) for -audiodev Claudio Fontana
2022-09-07 15:06 ` Markus Armbruster
2022-09-07 15:22   ` Daniel P. Berrangé
2022-09-07 16:07     ` BALATON Zoltan
2022-09-08  5:20     ` Markus Armbruster
2022-09-07 15:56   ` Claudio Fontana

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.