[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] audio: add help option (?) for -audiodev
From: |
Claudio Fontana |
Subject: |
Re: [PATCH] audio: add help option (?) for -audiodev |
Date: |
Wed, 7 Sep 2022 17:56:41 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 |
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);
>