soundhw: move help handling to vl.c
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 27 Apr 2022 11:15:23 +0000 (13:15 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 14 May 2022 10:33:44 +0000 (12:33 +0200)
This will allow processing "-audio model=help" even if the backend
part of the option is missing.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/audio/soundhw.c
softmmu/vl.c

index a1558dab3a2cca6a94d2e91ae9f8c47f5bfca8ed..ebbd0958bacf6f1254b3584cb4363983c4f1091f 100644 (file)
@@ -89,23 +89,17 @@ void select_soundhw(const char *optarg)
         error_setg(&error_fatal, "only one -soundhw option is allowed");
     }
 
-    if (is_help_option(optarg)) {
-        show_valid_soundhw();
-        exit(0);
-    }
-    else {
-        for (c = soundhw; c->name; ++c) {
-            if (g_str_equal(c->name, optarg)) {
-                selected = c;
-                break;
-            }
+    for (c = soundhw; c->name; ++c) {
+        if (g_str_equal(c->name, optarg)) {
+            selected = c;
+            break;
         }
+    }
 
-        if (!c->name) {
-            error_report("Unknown sound card name `%s'", optarg);
-            show_valid_soundhw();
-            exit(1);
-        }
+    if (!c->name) {
+        error_report("Unknown sound card name `%s'", optarg);
+        show_valid_soundhw();
+        exit(1);
     }
 }
 
index 817d515783068b8e9d46ae533878679772c2df9a..0363cbd9b4f6812626b02c51be64ce77fdeb3e2a 100644 (file)
@@ -2931,6 +2931,10 @@ void qemu_init(int argc, char **argv, char **envp)
                 audio_parse_option(optarg);
                 break;
             case QEMU_OPTION_soundhw:
+                if (is_help_option(optarg)) {
+                    show_valid_soundhw();
+                    exit(0);
+                }
                 select_soundhw (optarg);
                 break;
             case QEMU_OPTION_h: