Skip to content

Commit

Permalink
system/vl.c: Print machine name, not "(null)", for unknown machine types
Browse files Browse the repository at this point in the history
In commit 412d294 we tried to improve the error message printed when
the machine type is unknown, but we used the wrong variable, resulting in:

$ ./build/x86/qemu-system-aarch64 -M bang
qemu-system-aarch64: unsupported machine type: "(null)"
Use -machine help to list supported machines

Use the right variable, so we produce more helpful output:

$ ./build/x86/qemu-system-aarch64 -M bang
qemu-system-aarch64: unsupported machine type: "bang"
Use -machine help to list supported machines

Note that we must move the qdict_del() to below the error_setg(),
because machine_type points into the value of that qdict entry,
and deleting it will make the pointer invalid.

Cc: [email protected]
Fixes: 412d294 ("vl.c: select_machine(): add selected machine type to error message")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
  • Loading branch information
pm215 authored and Michael Tokarev committed Aug 23, 2024
1 parent 80e3541 commit d53bb90
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions system/vl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1679,10 +1679,10 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)

if (machine_type) {
machine_class = find_machine(machine_type, machines);
qdict_del(qdict, "type");
if (!machine_class) {
error_setg(errp, "unsupported machine type: \"%s\"", optarg);
error_setg(errp, "unsupported machine type: \"%s\"", machine_type);
}
qdict_del(qdict, "type");
} else {
machine_class = find_default_machine(machines);
if (!machine_class) {
Expand Down

0 comments on commit d53bb90

Please sign in to comment.