Skip to content
cpu/core: Fix "help" of CPU core device types

Thomas Huth recently reported an annoying crash:

$ ./qemu-system-ppc64 -device power8_v2.0-spapr-cpu-core,help
/home/thuth/devel/qemu/include/hw/boards.h:24:
 MACHINE: Object 0x5635bd53af10 is not an instance of type machine
Aborted (core dumped)

This is caused by an early use of qdev_get_machine(), before the
machine creation, which triggers a side-effect of creating a
dummy "container" object instead of the machine. This is needed
by user mode emulation, which doesn't really care about the
type of the parent of the CPU model. This is toxic for system
mode though because the system mode specific code usually assume
MACHINE(qdev_get_machine()).

This series brings separate implementations between user and
system mode. The breakage with "cpu-code,help" is fixed by using
current_machine.