qdev: Use qdev_realize() in qdev_device_add()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-56-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2020-06-10 07:32:44 +02:00
parent 510ef98dca
commit 464a22c757

View File

@ -661,9 +661,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
goto err_del_dev; goto err_del_dev;
} }
if (bus) { if (!bus && qdev_hotplug && !qdev_get_machine_hotplug_handler(dev)) {
qdev_set_parent_bus(dev, bus);
} else if (qdev_hotplug && !qdev_get_machine_hotplug_handler(dev)) {
/* No bus, no machine hotplug handler --> device is not hotpluggable */ /* No bus, no machine hotplug handler --> device is not hotpluggable */
error_setg(&err, "Device '%s' can not be hotplugged on this machine", error_setg(&err, "Device '%s' can not be hotplugged on this machine",
driver); driver);
@ -678,7 +676,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
} }
dev->opts = opts; dev->opts = opts;
object_property_set_bool(OBJECT(dev), true, "realized", &err); qdev_realize(DEVICE(dev), bus, &err);
if (err != NULL) { if (err != NULL) {
dev->opts = NULL; dev->opts = NULL;
goto err_del_dev; goto err_del_dev;