qemu/system
Akihiko Odaki 937874a83d hw/qdev: Check machine_hotplug_handler in hotplug_unplug_allowed_common
Commit 03fcbd9dc5 ("qdev: Check for the availability of a hotplug
controller before adding a device") says:

 > The qdev_unplug() function contains a g_assert(hotplug_ctrl)
 > statement, so QEMU crashes when the user tries to device_add +
 > device_del a device that does not have a corresponding hotplug
 > controller.

 > The code in qdev_device_add() already checks whether the bus has a
 > proper hotplug controller, but for devices that do not have a
 > corresponding bus, here is no appropriate check available yet. In that
 > case we should check whether the machine itself provides a suitable
 > hotplug controller and refuse to plug the device if none is available.

However, it forgot to add the corresponding check to qdev_unplug().

Check the machine hotplug handler once in the common
qdev_hotplug_unplug_allowed_common() helper so both hotplug
and hot-unplug path are covered.

Fixes: 7716b8ca74 ("qdev: HotplugHandler: Add support for unplugging BUS-less devices")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
[PMD: Split from bigger patch, part 6/6]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20250110091908.64454-7-philmd@linaro.org>
2025-01-13 17:16:03 +01:00
..
arch_init.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
async-teardown.c qemu/osdep: Add excluded fd parameter to qemu_close_all_open_fd() 2024-08-05 08:21:59 +10:00
balloon.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
bootdevice.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
cpu-timers.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
cpus.c Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
datadir.c system: Rename softmmu/ directory as system/ 2023-10-08 21:08:08 +02:00
device_tree-stub.c kconfig: allow compiling out QEMU device tree code per target 2024-05-10 15:45:15 +02:00
device_tree.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
dirtylimit.c system/dirtylimit: Don't use migration_is_active() 2024-12-26 07:23:38 +01:00
dma-helpers.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
globals.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
ioport.c qdev: Use machine_get_container() 2025-01-09 18:16:24 +01:00
main.c ui & main loop: Redesign of system-specific main thread event handling 2024-12-31 21:21:34 +01:00
memory.c qdev: Use machine_get_container() 2025-01-09 18:16:24 +01:00
memory_ldst.c.inc system: Move memory_ldst.c.inc to system 2024-02-13 10:59:25 +03:00
memory_mapping.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
meson.build migration: Move cpu-throttle.c from system to migration 2024-10-31 15:48:18 -04:00
physmem.c accel/tcg: Include missing 'exec/translation-block.h' header 2024-12-20 17:44:57 +01:00
qdev-monitor.c hw/qdev: Check machine_hotplug_handler in hotplug_unplug_allowed_common 2025-01-13 17:16:03 +01:00
qemu-seccomp.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
qtest.c system/qtest: properly feedback results of clock_[step|set] 2025-01-10 11:18:32 +00:00
rtc.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
runstate-action.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
runstate-hmp-cmds.c system: Rename softmmu/ directory as system/ 2023-10-08 21:08:08 +02:00
runstate.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
tpm-hmp-cmds.c system: Rename softmmu/ directory as system/ 2023-10-08 21:08:08 +02:00
tpm.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
trace-events system/dma-helpers.c: Move trace events to system/trace-events 2024-11-19 14:14:13 +00:00
trace.h system: Rename softmmu/ directory as system/ 2023-10-08 21:08:08 +02:00
vl.c system: Inline machine_containers[] in qemu_create_machine_containers() 2025-01-09 18:16:27 +01:00
watchpoint.c system/watchpoint: Move TCG specific code to accel/tcg/ 2024-01-19 12:28:59 +01:00