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

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