soundhw: move help handling to vl.c

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>
This commit is contained in:
Paolo Bonzini 2022-04-27 13:15:23 +02:00
parent bf521c5655
commit 67aaa96ae4
2 changed files with 13 additions and 15 deletions

View File

@ -89,23 +89,17 @@ void select_soundhw(const char *optarg)
error_setg(&error_fatal, "only one -soundhw option is allowed"); error_setg(&error_fatal, "only one -soundhw option is allowed");
} }
if (is_help_option(optarg)) { for (c = soundhw; c->name; ++c) {
show_valid_soundhw(); if (g_str_equal(c->name, optarg)) {
exit(0); selected = c;
break;
}
} }
else {
for (c = soundhw; c->name; ++c) {
if (g_str_equal(c->name, optarg)) {
selected = c;
break;
}
}
if (!c->name) { if (!c->name) {
error_report("Unknown sound card name `%s'", optarg); error_report("Unknown sound card name `%s'", optarg);
show_valid_soundhw(); show_valid_soundhw();
exit(1); exit(1);
}
} }
} }

View File

@ -2931,6 +2931,10 @@ void qemu_init(int argc, char **argv, char **envp)
audio_parse_option(optarg); audio_parse_option(optarg);
break; break;
case QEMU_OPTION_soundhw: case QEMU_OPTION_soundhw:
if (is_help_option(optarg)) {
show_valid_soundhw();
exit(0);
}
select_soundhw (optarg); select_soundhw (optarg);
break; break;
case QEMU_OPTION_h: case QEMU_OPTION_h: