From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: balaton@eik.bme.hu, berrange@redhat.com
Subject: [PATCH 4/7] audio: extend -audio to allow creating a default backend
Date: Thu, 5 Oct 2023 14:58:12 +0200 [thread overview]
Message-ID: <20231005125815.66082-5-pbonzini@redhat.com> (raw)
In-Reply-To: <20231005125815.66082-1-pbonzini@redhat.com>
If "-audio BACKEND" is used without a model, the resulting backend
will be used whenever the audiodev property is not specified.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
qemu-options.hx | 29 +++++++++++++++++++++--------
system/vl.c | 27 +++++++++++++++------------
2 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index 9ce8a5b9578..5f4c240a1e2 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -728,20 +728,22 @@ ERST
DEF("audio", HAS_ARG, QEMU_OPTION_audio,
+ "-audio [driver=]driver[,prop[=value][,...]]\n"
+ " specifies default audio backend when `audiodev` is not\n"
+ " used to create a machine or sound device;"
+ " options are the same as for -audiodev\n"
"-audio [driver=]driver,model=value[,prop[=value][,...]]\n"
" specifies the audio backend and device to use;\n"
" apart from 'model', options are the same as for -audiodev.\n"
" use '-audio model=help' to show possible devices.\n",
QEMU_ARCH_ALL)
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 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.
+``-audio [driver=]driver[,model=value][,prop[=value][,...]]``
+ If the ``model`` option is specified, ``-audio`` is a shortcut
+ for configuring both the guest audio hardware and the host audio
+ backend in one go. The guest hardware model can be set with
+ ``model=modelname``. Use ``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:
@@ -750,6 +752,17 @@ SRST
|qemu_system| -audiodev pa,id=pa -device sb16,audiodev=pa
|qemu_system| -audio pa,model=sb16
+
+ If the ``model`` option is not specified, ``-audio`` is used to
+ configure a default audio backend that will be used whenever the
+ ``audiodev`` property is not set on a device or machine. In
+ particular, ``-audio none`` ensures that no audio is produced even
+ for machines that have embedded sound hardware.
+
+ In both cases, the driver option is the same as with the corresponding
+ ``-audiodev`` option below. Use ``driver=help`` to list the available
+ drivers.
+
ERST
DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev,
diff --git a/system/vl.c b/system/vl.c
index 7ca92d4490d..72be5a49764 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2935,7 +2935,7 @@ void qemu_init(int argc, char **argv)
break;
case QEMU_OPTION_audio: {
bool help;
- char *model;
+ char *model = NULL;
Audiodev *dev = NULL;
Visitor *v;
QDict *dict = keyval_parse(optarg, "driver", &help, &error_fatal);
@@ -2948,22 +2948,25 @@ void qemu_init(int argc, char **argv)
if (!qdict_haskey(dict, "id")) {
qdict_put_str(dict, "id", "audiodev0");
}
- if (!qdict_haskey(dict, "model")) {
- error_setg(&error_fatal, "Parameter 'model' is missing");
- }
- model = g_strdup(qdict_get_str(dict, "model"));
- qdict_del(dict, "model");
- if (is_help_option(model)) {
- show_valid_soundhw();
- exit(0);
+ if (qdict_haskey(dict, "model")) {
+ model = g_strdup(qdict_get_str(dict, "model"));
+ qdict_del(dict, "model");
+ if (is_help_option(model)) {
+ show_valid_soundhw();
+ exit(0);
+ }
}
v = qobject_input_visitor_new_keyval(QOBJECT(dict));
qobject_unref(dict);
visit_type_Audiodev(v, NULL, &dev, &error_fatal);
visit_free(v);
- audio_define(dev);
- select_soundhw(model, dev->id);
- g_free(model);
+ if (model) {
+ audio_define(dev);
+ select_soundhw(model, dev->id);
+ g_free(model);
+ } else {
+ audio_define_default(dev, &error_fatal);
+ }
break;
}
case QEMU_OPTION_h:
--
2.41.0
next prev parent reply other threads:[~2023-10-05 13:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 12:58 [PATCH 0/7] audio: redo default audio backend creation Paolo Bonzini
2023-10-05 12:58 ` [PATCH 1/7] audio: error hints need a trailing \n Paolo Bonzini
2023-10-05 12:58 ` [PATCH 2/7] audio: disable default backends if -audio/-audiodev is used Paolo Bonzini
2023-10-05 12:58 ` [PATCH 3/7] audio: extract audio_define_default Paolo Bonzini
2023-10-05 12:58 ` Paolo Bonzini [this message]
2023-10-05 12:58 ` [PATCH 5/7] audio: do not use first -audiodev as default audio device Paolo Bonzini
2023-10-05 13:33 ` BALATON Zoltan
2023-10-05 13:38 ` BALATON Zoltan
2023-10-05 15:09 ` Paolo Bonzini
2023-10-05 15:40 ` BALATON Zoltan
2023-10-05 16:41 ` Paolo Bonzini
2023-10-05 18:20 ` BALATON Zoltan
2023-10-05 12:58 ` [PATCH 6/7] audio: reintroduce default audio backend for VNC Paolo Bonzini
2023-10-05 12:58 ` [PATCH 7/7] audio, qtest: get rid of QEMU_AUDIO_DRV Paolo Bonzini
2023-10-09 10:46 ` [PATCH 0/7] audio: redo default audio backend creation Marc-André Lureau
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=20231005125815.66082-5-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=balaton@eik.bme.hu \
--cc=berrange@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).