softmmu/vl.c: Handle '-cpu help' and '-device help' before 'no default machine'

Currently if you try to ask for the list of CPUs for a target
architecture which does not specify a default machine type
you just get an error:

  $ qemu-system-arm -cpu help
  qemu-system-arm: No machine specified, and there is no default
  Use -machine help to list supported machines

Since the list of CPUs doesn't depend on the machine, this is
unnecessarily unhelpful. "-device help" has a similar problem.

Move the checks for "did the user ask for -cpu help or -device help"
up so they precede the select_machine() call which checks that the
user specified a valid machine type.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Peter Maydell 2020-03-13 17:24:47 +00:00 committed by Paolo Bonzini
parent 3b2c52c017
commit 3df261b667

View File

@ -3789,6 +3789,22 @@ void qemu_init(int argc, char **argv, char **envp)
*/ */
loc_set_none(); loc_set_none();
/*
* Check for -cpu help and -device help before we call select_machine(),
* which will return an error if the architecture has no default machine
* type and the user did not specify one, so that the user doesn't need
* to say '-cpu help -machine something'.
*/
if (cpu_option && is_help_option(cpu_option)) {
list_cpus(cpu_option);
exit(0);
}
if (qemu_opts_foreach(qemu_find_opts("device"),
device_help_func, NULL, NULL)) {
exit(0);
}
user_register_global_props(); user_register_global_props();
replay_configure(icount_opts); replay_configure(icount_opts);
@ -3877,11 +3893,6 @@ void qemu_init(int argc, char **argv, char **envp)
qemu_set_hw_version(machine_class->hw_version); qemu_set_hw_version(machine_class->hw_version);
} }
if (cpu_option && is_help_option(cpu_option)) {
list_cpus(cpu_option);
exit(0);
}
if (!trace_init_backends()) { if (!trace_init_backends()) {
exit(1); exit(1);
} }
@ -4112,11 +4123,6 @@ void qemu_init(int argc, char **argv, char **envp)
fsdev_init_func, NULL, &error_fatal); fsdev_init_func, NULL, &error_fatal);
#endif #endif
if (qemu_opts_foreach(qemu_find_opts("device"),
device_help_func, NULL, NULL)) {
exit(0);
}
/* /*
* Note: we need to create block backends before * Note: we need to create block backends before
* machine_set_property(), so machine properties can refer to * machine_set_property(), so machine properties can refer to