summary refs log tree commit diff stats
path: root/hw/core/qdev-hotplug.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* hw/qdev: Check machine_hotplug_handler in hotplug_unplug_allowed_commonAkihiko Odaki2025-01-131-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* hw/qdev: Check qbus_is_hotpluggable in hotplug_unplug_allowed_commonAkihiko Odaki2025-01-131-0/+8
| | | | | | | | | | Check the same code once in the common helper. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> [PMD: Split from bigger patch, part 5/6] Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20250110091908.64454-6-philmd@linaro.org>
* hw/qdev: Check DevClass::hotpluggable in hotplug_unplug_allowed_commonAkihiko Odaki2025-01-131-0/+9
| | | | | | | | | | Check the same code once in the common helper. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> [PMD: Split from bigger patch, part 4/6] Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20250110091908.64454-5-philmd@linaro.org>
* hw/qdev: Introduce qdev_hotplug_unplug_allowed_common()Akihiko Odaki2025-01-131-1/+12
| | | | | | | | | | | Introduce qdev_hotplug_unplug_allowed_common() to hold common code between checking hot-plug/unplug is allowed. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> [PMD: Split from bigger patch, part 3/6] Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20250110091908.64454-4-philmd@linaro.org>
* hw/qdev: Factor qdev_hotunplug_allowed() outAkihiko Odaki2025-01-131-0/+5
| | | | | | | | | | | Factor qdev_hotunplug_allowed() out of qdev_unplug(). Start checking the device is not blocked. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> [PMD: Split from bigger patch, part 2/6] Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20250110091908.64454-3-philmd@linaro.org>
* hw/qdev: Pass bus argument to qdev_hotplug_allowed()Akihiko Odaki2025-01-131-1/+1
| | | | | | | | | | | In preparation of checking the parent bus is hot(un)pluggable in a few commits, pass a 'bus' argument to qdev_hotplug_allowed(). Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> [PMD: Split from bigger patch, part 1/6] Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20250110091908.64454-2-philmd@linaro.org>
* hw/core: Extract hotplug-related functions to qdev-hotplug.cPhilippe Mathieu-Daudé2021-11-011-0/+73
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Yanan Wang <wangyanan55@huawei.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20211028150521.1973821-4-philmd@redhat.com>