Akihiko Odaki 937874a83d hw/qdev: Check machine_hotplug_handler in hotplug_unplug_allowed_common
Commit 03fcbd9dc508 ("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
..
2023-12-29 11:17:30 +11:00
2024-12-20 17:44:56 +01:00
2024-12-13 15:26:58 +01:00
2024-12-21 11:07:00 -05:00
2025-01-09 18:16:24 +01:00
2024-12-21 11:07:00 -05:00
2024-12-20 17:44:56 +01:00
2024-12-20 17:44:56 +01:00
2019-08-16 13:31:53 +02:00
2025-01-09 18:16:24 +01:00
2024-12-20 17:44:56 +01:00
2025-01-09 18:16:24 +01:00