diff options
| author | Akihiko Odaki <akihiko.odaki@daynix.com> | 2024-02-18 15:57:11 +0900 |
|---|---|---|
| committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-01-13 17:16:03 +0100 |
| commit | 1bff035be76cc30ff0fc4e8f0b0fbda84db7d1dc (patch) | |
| tree | b9218e6bd032644d2b6409c13868a444753a8410 /hw/core | |
| parent | f2694f1b1a1a38c586ee6f00e88b729828012d3a (diff) | |
| download | focaccia-qemu-1bff035be76cc30ff0fc4e8f0b0fbda84db7d1dc.tar.gz focaccia-qemu-1bff035be76cc30ff0fc4e8f0b0fbda84db7d1dc.zip | |
hw/qdev: Check DevClass::hotpluggable in hotplug_unplug_allowed_common
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>
Diffstat (limited to 'hw/core')
| -rw-r--r-- | hw/core/qdev-hotplug.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c index 168d796474..1d77fffb5e 100644 --- a/hw/core/qdev-hotplug.c +++ b/hw/core/qdev-hotplug.c @@ -12,6 +12,7 @@ #include "qemu/osdep.h" #include "hw/qdev-core.h" #include "hw/boards.h" +#include "qapi/error.h" HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev) { @@ -33,6 +34,14 @@ HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev) static bool qdev_hotplug_unplug_allowed_common(DeviceState *dev, BusState *bus, Error **errp) { + DeviceClass *dc = DEVICE_GET_CLASS(dev); + + if (!dc->hotpluggable) { + error_setg(errp, "Device '%s' does not support hotplugging", + object_get_typename(OBJECT(dev))); + return false; + } + return true; } |