Blame SOURCES/kvm-sysbus-Fix-latent-bug-with-onboard-devices.patch

383d26
From 18b6e8931b3aebefbbccf545165ccc6fcdd09a1e Mon Sep 17 00:00:00 2001
383d26
From: Markus Armbruster <armbru@redhat.com>
383d26
Date: Fri, 17 May 2019 06:51:10 +0200
383d26
Subject: [PATCH 43/53] sysbus: Fix latent bug with onboard devices
383d26
MIME-Version: 1.0
383d26
Content-Type: text/plain; charset=UTF-8
383d26
Content-Transfer-Encoding: 8bit
383d26
383d26
RH-Author: Markus Armbruster <armbru@redhat.com>
383d26
Message-id: <20190517065120.12028-22-armbru@redhat.com>
383d26
Patchwork-id: 87995
383d26
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH v3 21/31] sysbus: Fix latent bug with onboard devices
383d26
Bugzilla: 1624009
383d26
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
383d26
RH-Acked-by: Thomas Huth <thuth@redhat.com>
383d26
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
383d26
The first call of sysbus_get_default() creates the main system bus and
383d26
stores it in QOM as "/machine/unattached/sysbus".  This must not
383d26
happen before main() creates "/machine", or else container_get() would
383d26
"helpfully" create it as "container" object, and the real creation of
383d26
"/machine" would later abort with "attempt to add duplicate property
383d26
'machine' to object (type 'container')".  Has been that way ever since
383d26
we wired up busses in QOM (commit f968fc6892d, v1.2.0).
383d26
383d26
I believe the bug is latent.  I got it to bite by trying to
383d26
qdev_create() a sysbus device from a machine's .instance_init()
383d26
method.
383d26
383d26
The fix is obvious: store the main system bus in QOM right after
383d26
creating "/machine".
383d26
383d26
Signed-off-by: Markus Armbruster <armbru@redhat.com>
383d26
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
383d26
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
383d26
Reviewed-by: Thomas Huth <thuth@redhat.com>
383d26
Message-Id: <20190308131445.17502-5-armbru@redhat.com>
383d26
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
383d26
(cherry picked from commit e2fb3fbbf9ce6b8eed00b53a91d3a316362f1b0d)
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 hw/core/sysbus.c | 3 ---
383d26
 vl.c             | 4 ++++
383d26
 2 files changed, 4 insertions(+), 3 deletions(-)
383d26
383d26
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
383d26
index 5d0887f..db95cb0 100644
383d26
--- a/hw/core/sysbus.c
383d26
+++ b/hw/core/sysbus.c
383d26
@@ -359,9 +359,6 @@ static void main_system_bus_create(void)
383d26
     qbus_create_inplace(main_system_bus, system_bus_info.instance_size,
383d26
                         TYPE_SYSTEM_BUS, NULL, "main-system-bus");
383d26
     OBJECT(main_system_bus)->free = g_free;
383d26
-    object_property_add_child(container_get(qdev_get_machine(),
383d26
-                                            "/unattached"),
383d26
-                              "sysbus", OBJECT(main_system_bus), NULL);
383d26
 }
383d26
 
383d26
 BusState *sysbus_get_default(void)
383d26
diff --git a/vl.c b/vl.c
383d26
index d46dff6..d89ac3a 100644
383d26
--- a/vl.c
383d26
+++ b/vl.c
383d26
@@ -4162,6 +4162,10 @@ int main(int argc, char **argv, char **envp)
383d26
     }
383d26
     object_property_add_child(object_get_root(), "machine",
383d26
                               OBJECT(current_machine), &error_abort);
383d26
+    object_property_add_child(container_get(OBJECT(current_machine),
383d26
+                                            "/unattached"),
383d26
+                              "sysbus", OBJECT(sysbus_get_default()),
383d26
+                              NULL);
383d26
 
383d26
     if (machine_class->minimum_page_bits) {
383d26
         if (!set_preferred_target_page_bits(machine_class->minimum_page_bits)) {
383d26
-- 
383d26
1.8.3.1
383d26