summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Armbruster2020-06-09 14:23:37 +0200
committerMarkus Armbruster2020-06-15 21:36:30 +0200
commit81cb05732efb36971901c515b007869cc1d3a532 (patch)
tree659e362b0ab5742b4afee19f4986f6439916f4ef
parentsparc/leon3: Fix to put grlib,* devices on sysbus (diff)
downloadqemu-81cb05732efb36971901c515b007869cc1d3a532.tar.gz
qemu-81cb05732efb36971901c515b007869cc1d3a532.tar.xz
qemu-81cb05732efb36971901c515b007869cc1d3a532.zip
qdev: Assert devices are plugged into a bus that can take them
This would have caught some of the bugs I just fixed. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Message-Id: <20200609122339.937862-23-armbru@redhat.com>
-rw-r--r--hw/core/qdev.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 9e5538aeae..b5b42b2616 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -97,6 +97,9 @@ static void bus_add_child(BusState *bus, DeviceState *child)
void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
{
BusState *old_parent_bus = dev->parent_bus;
+ DeviceClass *dc = DEVICE_GET_CLASS(dev);
+
+ assert(dc->bus_type && object_dynamic_cast(OBJECT(bus), dc->bus_type));
if (old_parent_bus) {
trace_qdev_update_parent_bus(dev, object_get_typename(OBJECT(dev)),