This achieved by select the target by provided -machine $type option. Error when anything wrong.
Signed-off-by: Yonggang Luo <[email protected]> --- system/vl.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/system/vl.c b/system/vl.c index 5d6ba08b591..bad13393f24 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1278,6 +1278,18 @@ static MachineClass *machine_target_select(GSList *machines, GSList **targets, static int device_help_func(void *opaque, QemuOpts *opts, Error **errp) { + const char *driver = qemu_opt_get(opts, "driver"); + + if (target_combined_binary() && driver && + (is_help_option(driver) || qemu_opt_has_help_opt(opts))) { + const char *name = qdict_get_try_str(machine_opts_dict, "type"); + + g_autoptr(GSList) machines = object_class_get_list(TYPE_MACHINE, + false); + g_autoptr(GSList) targets = NULL; + + machine_target_select(machines, &targets, name, &error_fatal); + } return qdev_device_help(opts); } @@ -2761,9 +2773,24 @@ static void qemu_process_help_options(void) * 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'. + * to say '-cpu help -machine something' in single-target binaries. */ if (cpu_option && is_help_option(cpu_option)) { + if (target_combined_binary()) { + const char *name = qdict_get_try_str(machine_opts_dict, "type"); + + if (!name) { + error_report("-cpu help requires -machine " + "<arch>-<machine-name> or an unambiguous " + "<machine-name> in a combined binary"); + exit(EXIT_FAILURE); + } + g_autoptr(GSList) machines = + object_class_get_list(TYPE_MACHINE, false); + g_autoptr(GSList) targets = NULL; + + machine_target_select(machines, &targets, name, &error_fatal); + } list_cpus(); exit(0); } -- 2.55.0.windows.3
