You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qemu/hw/cpu
Greg Kurz 0b47ec4b95 cpu/core: Fix "help" of CPU core device types
Calling qdev_get_machine() from a QOM instance_init function is
fragile because we can't be sure the machine object actually
exists. And this happens to break when passing ",help" on the
command line to get the list of properties for a CPU core
device types :

$ ./qemu-system-ppc64 -device power8_v2.0-spapr-cpu-core,help
qemu-system-ppc64: ../../hw/core/machine.c:1290:
 qdev_get_machine: Assertion `machine != NULL' failed.
Aborted (core dumped)

This used to work before QEMU 5.0, but commit 3df261b667
unwillingly introduced a subtle regression : the above command
line needs to create an instance but the instance_init function
of the base class calls qdev_get_machine() before
qemu_create_machine() has been called, which is a programming bug.

Use current_machine instead. It is okay to skip the setting of
nr_thread in this case since only its type is displayed.

Fixes: 3df261b667 ("softmmu/vl.c: Handle '-cpu help' and '-device help' before 'no default machine'")
Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Cc: peter.maydell@linaro.org
Message-Id: <20210409160339.500167-3-groug@kaod.org>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
4 years ago
..
Kconfig kconfig: introduce kconfig files 6 years ago
a9mpcore.c qom: simplify object_find_property / object_class_find_property 4 years ago
a15mpcore.c qom: simplify object_find_property / object_class_find_property 4 years ago
arm11mpcore.c error: Eliminate error_propagate() with Coccinelle, part 1 4 years ago
cluster.c qdev: set properties with device_class_set_props() 5 years ago
core.c cpu/core: Fix "help" of CPU core device types 4 years ago
meson.build meson: convert hw/cpu 4 years ago
realview_mpcore.c Use OBJECT_DECLARE_SIMPLE_TYPE when possible 4 years ago