qemu/hw
Thomas Huth 807830e809 hw/s390x: Fix crash that occurs when inspecting older versioned machines types
qemu-system-s390x currently crashes when trying to inspect older
machines types, for example:

 $ echo '{ "execute": "qmp_capabilities" }
         { "execute": "qom-list-properties","arguments":
           { "typename": "s390-ccw-virtio-3.0-machine"}}' \
   | ./qemu-system-s390x -qmp stdio -no-shutdown
 {"QMP": {"version": {"qemu": {"micro": 50, "minor": 2, "major": 9},
  "package": "v9.2.0-1071-g81e97df3e7"}, "capabilities": ["oob"]}}
 {"return": {}}
 **
 Bail out! ERROR:../target/s390x/cpu_models.c:832:s390_set_qemu_cpu_model:
  assertion failed: (QTAILQ_EMPTY_RCU(&cpus_queue))
 Aborted (core dumped)

The problem is that the versioned s390-ccw-virtio machine types
use instance_init() to set global state that should be initialized
before the CPUs get instantiated. But instance_init() is not called
only for the machine that is finally used, it is also called for
temporary instances of objects that are e.g. just created for
introspection. That means that those instance_init() functions can
also be called while a machine (and its CPUs) is already created,
which triggers the assertion in cpu_models.c.

So we must not use instance_init() for setting global state, but
use the machine->init() function instead, which is really only called
once when the machine comes to life.

Fixes: 3b00f702c2 ("s390x/cpumodel: add zpci, aen and ais facilities")
Message-ID: <20250120085059.239345-1-thuth@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2025-01-22 08:28:49 +01:00
..
9pfs Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
acpi hw/acpi: Add vmclock device 2025-01-15 17:43:24 -05:00
adc include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
alpha alpha: switch boards to "default y" 2024-05-03 15:47:47 +02:00
arm acpi/ghes: simplify the per-arch caller to build HEST table 2025-01-15 13:06:49 -05:00
audio Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
avr Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
block xen: do not use '%ms' scanf specifier 2025-01-15 17:06:49 +00:00
char hw/char/riscv_htif: Convert HTIF_DEBUG() to trace events 2025-01-19 09:44:35 +10:00
core * rust: miscellaneous changes 2025-01-17 10:12:52 -05:00
cpu Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
cxl Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
display virtio-gpu: Add definition for resource_uuid feature 2025-01-15 13:05:26 -05:00
dma Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
fsi hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
gpio hw/gpio/imx_gpio: Turn DPRINTF() into trace events 2025-01-13 17:16:04 +01:00
hppa hw/hppa: Reset vCPUs calling resettable_reset() 2025-01-13 17:16:04 +01:00
hyperv Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
i2c hw/i2c/imx_i2c: Convert DPRINTF() to trace events 2025-01-13 17:16:04 +01:00
i386 * rust: miscellaneous changes 2025-01-17 10:12:52 -05:00
ide Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
input Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
intc hw/intc/loongarch_ipi: Use alternative implemation for cpu_by_arch_id 2025-01-15 14:36:19 +08:00
ipack include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
ipmi Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
isa Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
loongarch hw/intc/loongarch_ipi: Remove property num-cpu 2025-01-15 14:31:19 +08:00
m68k next-cube: add my copyright to the top of the file 2024-12-29 07:13:47 +01:00
mem hw/cxl: Fix msix_notify: Assertion vector < dev->msix_entries_nr 2025-01-15 13:07:30 -05:00
microblaze hw/microblaze: Propagate CPU endianness to microblaze_load_kernel() 2024-12-31 21:21:34 +01:00
mips hw/pci-host/gpex: Allow more than 4 legacy IRQs 2024-12-30 20:04:50 +01:00
misc hw/misc/imx6_src: Convert DPRINTF() to trace events 2025-01-13 17:16:04 +01:00
net Xen regression fixes and cleanups 2025-01-16 09:03:43 -05:00
nubus include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
nvme Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
nvram fw_cfg: Don't set callback_opaque NULL in fw_cfg_modify_bytes_read() 2024-12-31 21:21:34 +01:00
openrisc hw/openrisc: Mark devices as big-endian 2024-12-31 21:21:34 +01:00
pci pci/msix: Fix msix pba read vector poll end calculation 2025-01-15 13:06:41 -05:00
pci-bridge Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
pci-host hw/pci-host/gpex: Allow more than 4 legacy IRQs 2024-12-30 20:04:50 +01:00
ppc Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
remote Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
riscv Second RISC-V PR for 10.0 2025-01-19 08:55:46 -05:00
rtc Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
rx Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
s390x hw/s390x: Fix crash that occurs when inspecting older versioned machines types 2025-01-22 08:28:49 +01:00
scsi Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
sd hw/sd/sdhci: Factor sdhci_sdma_transfer() out 2025-01-13 17:16:04 +01:00
sensor hw/sensor: Replace type_register() with type_register_static() 2024-12-10 18:49:25 +01:00
sh4 include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
smbios include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
sparc hw: Replace DEVICE(object_new) -> qdev_new() 2025-01-13 17:06:35 +01:00
sparc64 hw/sparc: Mark devices as big-endian 2024-12-31 21:21:34 +01:00
ssi Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
timer hw/timer/imx_gpt: Remove unused define 2025-01-13 17:16:04 +01:00
tpm Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
tricore hw/tricore/triboard: Remove unnecessary use of &first_cpu 2025-01-13 17:21:46 +01:00
ufs hw/ufs: Adjust value to match CPU's endian format 2025-01-13 17:16:04 +01:00
usb hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported 2025-01-13 17:21:46 +01:00
vfio hw/pci: Use -1 as the default value for rombar 2025-01-09 18:16:18 +01:00
virtio qmp: update vhost-user protocol feature maps 2024-12-28 14:42:53 +03:00
watchdog Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
xen hw/xen: Use xs_node_read() from xenstore_read_str() instead of open-coding it 2025-01-15 17:07:27 +00:00
xenpv include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
xtensa hw/pci-host/gpex: Allow more than 4 legacy IRQs 2024-12-30 20:04:50 +01:00
Kconfig hw: Remove PCMCIA subsystem 2024-10-15 15:16:17 +01:00
meson.build hw: Remove PCMCIA subsystem 2024-10-15 15:16:17 +01:00