[PATCH 0/2] cpu/core: Fix "help" of CPU core device types

Greg Kurz posted 2 patches 3 years ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210409160339.500167-1-groug@kaod.org
Maintainers: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>
hw/core/machine.c        | 14 ++++++++++++++
hw/core/qdev.c           |  2 +-
hw/cpu/core.c            | 10 ++++++++--
include/hw/qdev-core.h   |  1 +
stubs/meson.build        |  1 +
stubs/qdev-get-machine.c | 11 +++++++++++
6 files changed, 36 insertions(+), 3 deletions(-)
create mode 100644 stubs/qdev-get-machine.c
[PATCH 0/2] cpu/core: Fix "help" of CPU core device types
Posted by Greg Kurz 3 years ago
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.

Greg Kurz (2):
  qdev: Separate implementations of qdev_get_machine() for user and
    system
  cpu/core: Fix "help" of CPU core device types

 hw/core/machine.c        | 14 ++++++++++++++
 hw/core/qdev.c           |  2 +-
 hw/cpu/core.c            | 10 ++++++++--
 include/hw/qdev-core.h   |  1 +
 stubs/meson.build        |  1 +
 stubs/qdev-get-machine.c | 11 +++++++++++
 6 files changed, 36 insertions(+), 3 deletions(-)
 create mode 100644 stubs/qdev-get-machine.c

-- 
2.26.3