Skip to content

Commit

Permalink
hw/s390x/css-bridge: Realize sysbus device before accessing it
Browse files Browse the repository at this point in the history
qbus_new() should not be called on unrealized device.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20231019071611.98885-10-philmd@linaro.org>
  • Loading branch information
philmd committed Oct 19, 2023
1 parent 675d717 commit 840b449
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions hw/s390x/css-bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,26 @@ static const TypeInfo virtual_css_bus_info = {

VirtualCssBus *virtual_css_bus_init(void)
{
VirtualCssBus *cbus;
BusState *bus;
DeviceState *dev;

/* Create bridge device */
dev = qdev_new(TYPE_VIRTUAL_CSS_BRIDGE);
object_property_add_child(qdev_get_machine(), TYPE_VIRTUAL_CSS_BRIDGE,
OBJECT(dev));
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);

/* Create bus on bridge device */
bus = qbus_new(TYPE_VIRTUAL_CSS_BUS, dev, "virtual-css");
cbus = VIRTUAL_CSS_BUS(bus);

/* Enable hotplugging */
qbus_set_hotplug_handler(bus, OBJECT(dev));

sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);

css_register_io_adapters(CSS_IO_ADAPTER_VIRTIO, true, false,
0, &error_abort);

return cbus;
return VIRTUAL_CSS_BUS(bus);
}

/***************** Virtual-css Bus Bridge Device ********************/
Expand Down

0 comments on commit 840b449

Please sign in to comment.