qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/9] vl: support -audio BACKEND without model


From: Paolo Bonzini
Subject: [PATCH 3/9] vl: support -audio BACKEND without model
Date: Fri, 22 Sep 2023 11:44:53 +0200

For machines with an embedded audio device, "-audio BACKEND" will
set the audiodev property of the machine itself.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 5a1413da2aa..70c9eb34dcf 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2933,11 +2933,12 @@ 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");
+                if (qdict_haskey(dict, "model")) {
+                    model = g_strdup(qdict_get_str(dict, "model"));
+                    qdict_del(dict, "model");
+                } else {
+                    model = g_strdup("default");
                 }
-                model = g_strdup(qdict_get_str(dict, "model"));
-                qdict_del(dict, "model");
                 if (is_help_option(model)) {
                     show_valid_soundhw();
                     exit(0);
@@ -2947,7 +2948,11 @@ void qemu_init(int argc, char **argv)
                 visit_type_Audiodev(v, NULL, &dev, &error_fatal);
                 visit_free(v);
                 audio_define(dev);
-                select_soundhw(model, dev->id);
+                if (g_str_equal(model, "default")) {
+                    qdict_put_str(machine_opts_dict, "audiodev", dev->id);
+                } else {
+                    select_soundhw(model, dev->id);
+                }
                 g_free(model);
                 break;
             }
-- 
2.41.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]