]> Git Repo - qemu.git/commitdiff
sysbus: Fix latent bug with onboard devices
authorMarkus Armbruster <[email protected]>
Fri, 8 Mar 2019 13:14:37 +0000 (14:14 +0100)
committerMarkus Armbruster <[email protected]>
Mon, 11 Mar 2019 21:53:44 +0000 (22:53 +0100)
The first call of sysbus_get_default() creates the main system bus and
stores it in QOM as "/machine/unattached/sysbus".  This must not
happen before main() creates "/machine", or else container_get() would
"helpfully" create it as "container" object, and the real creation of
"/machine" would later abort with "attempt to add duplicate property
'machine' to object (type 'container')".  Has been that way ever since
we wired up busses in QOM (commit f968fc6892d, v1.2.0).

I believe the bug is latent.  I got it to bite by trying to
qdev_create() a sysbus device from a machine's .instance_init()
method.

The fix is obvious: store the main system bus in QOM right after
creating "/machine".

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <20190308131445[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
hw/core/sysbus.c
vl.c

index 9f9edbcab96f14f7552db524e4f4cbc718aa6bdd..307cf90a51966bcb803529e915c5a9a35cb2c0e4 100644 (file)
@@ -357,9 +357,6 @@ static void main_system_bus_create(void)
     qbus_create_inplace(main_system_bus, system_bus_info.instance_size,
                         TYPE_SYSTEM_BUS, NULL, "main-system-bus");
     OBJECT(main_system_bus)->free = g_free;
-    object_property_add_child(container_get(qdev_get_machine(),
-                                            "/unattached"),
-                              "sysbus", OBJECT(main_system_bus), NULL);
 }
 
 BusState *sysbus_get_default(void)
diff --git a/vl.c b/vl.c
index 4f84d6568fe2b301d51017a3b107522e31cbc471..22609af3a4a02e13a451358c0d07a14c37ea265c 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -3989,6 +3989,10 @@ int main(int argc, char **argv, char **envp)
     }
     object_property_add_child(object_get_root(), "machine",
                               OBJECT(current_machine), &error_abort);
+    object_property_add_child(container_get(OBJECT(current_machine),
+                                            "/unattached"),
+                              "sysbus", OBJECT(sysbus_get_default()),
+                              NULL);
 
     if (machine_class->minimum_page_bits) {
         if (!set_preferred_target_page_bits(machine_class->minimum_page_bits)) {
This page took 0.02683 seconds and 4 git commands to generate.