[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 09/55] hw/qdev: Check DevClass::hotpluggable in hotplug_unplug_
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL v2 09/55] hw/qdev: Check DevClass::hotpluggable in hotplug_unplug_allowed_common |
Date: |
Mon, 13 Jan 2025 18:36:01 +0100 |
From: Akihiko Odaki <akihiko.odaki@daynix.com>
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/core/qdev-hotplug.c | 9 +++++++++
system/qdev-monitor.c | 10 +---------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c
index 168d7964740..1d77fffb5e0 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;
}
diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
index 511d1aa83c2..81f747b38fa 100644
--- a/system/qdev-monitor.c
+++ b/system/qdev-monitor.c
@@ -263,8 +263,7 @@ static DeviceClass *qdev_get_device_class(const char
**driver, Error **errp)
}
dc = DEVICE_CLASS(oc);
- if (!dc->user_creatable ||
- (phase_check(PHASE_MACHINE_READY) && !dc->hotpluggable)) {
+ if (!dc->user_creatable) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
"a pluggable device type");
return NULL;
@@ -904,7 +903,6 @@ static DeviceState *find_device_state(const char *id, bool
use_generic_error,
void qdev_unplug(DeviceState *dev, Error **errp)
{
- DeviceClass *dc = DEVICE_GET_CLASS(dev);
HotplugHandler *hotplug_ctrl;
HotplugHandlerClass *hdc;
Error *local_err = NULL;
@@ -919,12 +917,6 @@ void qdev_unplug(DeviceState *dev, Error **errp)
return;
}
- if (!dc->hotpluggable) {
- error_setg(errp, "Device '%s' does not support hotplugging",
- object_get_typename(OBJECT(dev)));
- return;
- }
-
if (migration_is_running() && !dev->allow_unplug_during_migration) {
error_setg(errp, "device_del not allowed while migrating");
return;
--
2.47.1
- [PULL v2 00/55] Misc HW patches for 2025-01-12, Philippe Mathieu-Daudé, 2025/01/13
- [PULL v2 10/55] hw/qdev: Check qbus_is_hotpluggable in hotplug_unplug_allowed_common, Philippe Mathieu-Daudé, 2025/01/13
- [PULL v2 55/55] Add a b4 configuration file, Philippe Mathieu-Daudé, 2025/01/13
- [PULL v2 06/55] hw/qdev: Pass bus argument to qdev_hotplug_allowed(), Philippe Mathieu-Daudé, 2025/01/13
- [PULL v2 09/55] hw/qdev: Check DevClass::hotpluggable in hotplug_unplug_allowed_common,
Philippe Mathieu-Daudé <=
- [PULL v2 08/55] hw/qdev: Introduce qdev_hotplug_unplug_allowed_common(), Philippe Mathieu-Daudé, 2025/01/13
- [PULL v2 07/55] hw/qdev: Factor qdev_hotunplug_allowed() out, Philippe Mathieu-Daudé, 2025/01/13
- [PULL v2 11/55] hw/qdev: Check machine_hotplug_handler in hotplug_unplug_allowed_common, Philippe Mathieu-Daudé, 2025/01/13
- Re: [PULL v2 00/55] Misc HW patches for 2025-01-12, Stefan Hajnoczi, 2025/01/14