[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/21] audio: add help option for -audio and -audiodev
From: |
Paolo Bonzini |
Subject: |
[PULL 15/21] audio: add help option for -audio and -audiodev |
Date: |
Mon, 19 Sep 2022 19:34:43 +0200 |
From: Claudio Fontana <cfontana@suse.de>
add a simple help option for -audio and -audiodev
to show the list of available drivers, and document them.
Signed-off-by: Claudio Fontana <cfontana@suse.de>
Message-Id: <20220908081441.7111-1-cfontana@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
audio/audio.c | 19 +++++++++++++++++++
audio/audio.h | 1 +
qemu-options.hx | 10 ++++++----
softmmu/vl.c | 9 +++++++--
4 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/audio/audio.c b/audio/audio.c
index 76b8735b44..cfa4119c05 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"
@@ -2101,10 +2102,28 @@ static void audio_validate_opts(Audiodev *dev, Error
**errp)
}
}
+void audio_help(void)
+{
+ int i;
+
+ printf("Available audio drivers:\n");
+
+ for (i = 0; i < AUDIODEV_DRIVER__MAX; i++) {
+ audio_driver *driver = audio_driver_lookup(AudiodevDriver_str(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(EXIT_SUCCESS);
+ }
Visitor *v = qobject_input_visitor_new_str(opt, "driver", &error_fatal);
visit_type_Audiodev(v, NULL, &dev, &error_fatal);
visit_free(v);
diff --git a/audio/audio.h b/audio/audio.h
index 27e67079a0..01bdc567fb 100644
--- a/audio/audio.h
+++ b/audio/audio.h
@@ -171,6 +171,7 @@ void audio_sample_from_uint64(void *samples, int pos,
void audio_define(Audiodev *audio);
void audio_parse_option(const char *opt);
bool audio_init_audiodevs(void);
+void audio_help(void);
void audio_legacy_help(void);
AudioState *audio_state_by_name(const char *name);
diff --git a/qemu-options.hx b/qemu-options.hx
index 1bb02363ab..d8b5ce5b43 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -704,10 +704,11 @@ SRST
``-audio [driver=]driver,model=value[,prop[=value][,...]]``
This option is a shortcut for configuring both the guest audio
hardware and the host audio backend in one go.
- The host backend options are the same as with the corresponding
- ``-audiodev`` options below. The guest hardware model can be set with
- ``model=modelname``. Use ``model=help`` to list the available device
- types.
+ The driver option is the same as with the corresponding ``-audiodev``
option below.
+ The guest hardware model can be set with ``model=modelname``.
+
+ Use ``driver=help`` to list the available drivers,
+ and ``model=help`` to list the available device types.
The following two example do exactly the same, to show how ``-audio``
can be used to shorten the command line length:
@@ -721,6 +722,7 @@ ERST
DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev,
"-audiodev [driver=]driver,id=id[,prop[=value][,...]]\n"
" specifies the audio backend to use\n"
+ " Use ``-audiodev help`` to list the available drivers\n"
" id= identifier of the backend\n"
" timer-period= timer period in microseconds\n"
" in|out.mixing-engine= use mixing engine to mix streams
inside QEMU\n"
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 263f029a8e..e62b9cc35d 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2842,11 +2842,16 @@ void qemu_init(int argc, char **argv, char **envp)
audio_parse_option(optarg);
break;
case QEMU_OPTION_audio: {
- QDict *dict = keyval_parse(optarg, "driver", NULL,
&error_fatal);
+ bool help;
char *model;
Audiodev *dev = NULL;
Visitor *v;
-
+ QDict *dict = keyval_parse(optarg, "driver", &help,
&error_fatal);
+ if (help || (qdict_haskey(dict, "driver") &&
+ is_help_option(qdict_get_str(dict, "driver")))) {
+ audio_help();
+ exit(EXIT_SUCCESS);
+ }
if (!qdict_haskey(dict, "id")) {
qdict_put_str(dict, "id", "audiodev0");
}
--
2.37.2
- [PULL 01/21] KVM: use store-release to mark dirty pages as harvested, (continued)
- [PULL 01/21] KVM: use store-release to mark dirty pages as harvested, Paolo Bonzini, 2022/09/19
- [PULL 02/21] target/i386: Raise #GP on unaligned m128 accesses when required., Paolo Bonzini, 2022/09/19
- [PULL 03/21] kvm: fix memory leak on failure to read stats descriptors, Paolo Bonzini, 2022/09/19
- [PULL 04/21] spapr_pci: fix leak in spapr_phb_vfio_get_loc_code, Paolo Bonzini, 2022/09/19
- [PULL 06/21] coverity: put NUBus under m68k component, Paolo Bonzini, 2022/09/19
- [PULL 07/21] smbios: sanitize type from external type before checking have_fields_bitmap, Paolo Bonzini, 2022/09/19
- [PULL 08/21] tests: unit: simplify test-visitor-serialization list tests, Paolo Bonzini, 2022/09/19
- [PULL 10/21] tests: unit: add NULL-pointer check, Paolo Bonzini, 2022/09/19
- [PULL 09/21] tests: test-qga: close socket on failure to connect, Paolo Bonzini, 2022/09/19
- [PULL 05/21] coverity: add new RISC-V component, Paolo Bonzini, 2022/09/19
- [PULL 15/21] audio: add help option for -audio and -audiodev,
Paolo Bonzini <=
- [PULL 16/21] target/i386: correctly mask SSE4a bit indices in register operands, Paolo Bonzini, 2022/09/19
- [PULL 14/21] tests/tcg: remove old SSE tests, Paolo Bonzini, 2022/09/19
- [PULL 20/21] build: remove extra parentheses causing missing rebuilds, Paolo Bonzini, 2022/09/19
- [PULL 11/21] tests/tcg: i386: fix typos in 3DNow! instructions, Paolo Bonzini, 2022/09/19
- [PULL 12/21] tests/tcg: i386: add MMX and 3DNow! tests, Paolo Bonzini, 2022/09/19
- [PULL 19/21] target/i386: introduce insn_get_addr, Paolo Bonzini, 2022/09/19
- [PULL 21/21] qboot: update to latest submodule, Paolo Bonzini, 2022/09/19
- [PULL 13/21] tests/tcg: refine MMX support in SSE tests, Paolo Bonzini, 2022/09/19
- [PULL 17/21] target/i386: fix INSERTQ implementation, Paolo Bonzini, 2022/09/19
- [PULL 18/21] target/i386: REPZ and REPNZ are mutually exclusive, Paolo Bonzini, 2022/09/19