qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH-for-5.1] qdev: Allow to create hotplug device before plugging it


From: Philippe Mathieu-Daudé
Subject: [PATCH-for-5.1] qdev: Allow to create hotplug device before plugging it to a bus
Date: Sun, 19 Jul 2020 15:43:29 +0200

Commit 510ef98dca made qdev_realize() support bus-less devices,
asserting either the device is bus-less or the device is created
on a bus. Commit 464a22c757 used qdev_realize() instead of
object_property_set_bool(). Since qdev_realize() now checks for
a bus, it is not possible to create hotplug devices unattached
to any bus anymore.

Fix by only asserting if the device is not hotpluggable.

Fixes: 464a22c757 "qdev: Use qdev_realize() in qdev_device_add()"
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/core/qdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 01796823b4..6c5540ecdc 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -393,7 +393,9 @@ bool qdev_realize(DeviceState *dev, BusState *bus, Error 
**errp)
     if (bus) {
         qdev_set_parent_bus(dev, bus);
     } else {
-        assert(!DEVICE_GET_CLASS(dev)->bus_type);
+        DeviceClass *dc = DEVICE_GET_CLASS(dev);
+
+        assert(dc->hotpluggable || !dc->bus_type);
     }
 
     return object_property_set_bool(OBJECT(dev), "realized", true, errp);
-- 
2.21.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]