提交 0210afe6 编写于 作者: M Markus Armbruster 提交者: Andreas Färber

qdev: Deprecated qdev_init() is finally unused, drop

qdev_init() is a wrapper around setting property "realized" to true,
plus error handling that passes errors to qerror_report_err().
qerror_report_err() is a transitional interface to help with
converting existing monitor commands to QMP.  It should not be used
elsewhere.

All code has been modernized to avoid qdev_init() and its
inappropriate error handling.  We can finally drop it.
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NAndreas Färber <afaerber@suse.de>
上级 a3590dac
...@@ -126,9 +126,9 @@ void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp) ...@@ -126,9 +126,9 @@ void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp)
qbus_set_hotplug_handler_internal(bus, OBJECT(bus), errp); qbus_set_hotplug_handler_internal(bus, OBJECT(bus), errp);
} }
/* Create a new device. This only initializes the device state structure /* Create a new device. This only initializes the device state
and allows properties to be set. qdev_init should be called to structure and allows properties to be set. The device still needs
initialize the actual device emulation. */ to be realized. See qdev-core.h. */
DeviceState *qdev_create(BusState *bus, const char *name) DeviceState *qdev_create(BusState *bus, const char *name)
{ {
DeviceState *dev; DeviceState *dev;
...@@ -168,27 +168,6 @@ DeviceState *qdev_try_create(BusState *bus, const char *type) ...@@ -168,27 +168,6 @@ DeviceState *qdev_try_create(BusState *bus, const char *type)
return dev; return dev;
} }
/* Initialize a device. Device properties should be set before calling
this function. IRQs and MMIO regions should be connected/mapped after
calling this function.
On failure, destroy the device and return negative value.
Return 0 on success. */
int qdev_init(DeviceState *dev)
{
Error *local_err = NULL;
assert(!dev->realized);
object_property_set_bool(OBJECT(dev), true, "realized", &local_err);
if (local_err != NULL) {
qerror_report_err(local_err);
error_free(local_err);
object_unparent(OBJECT(dev));
return -1;
}
return 0;
}
static QTAILQ_HEAD(device_listeners, DeviceListener) device_listeners static QTAILQ_HEAD(device_listeners, DeviceListener) device_listeners
= QTAILQ_HEAD_INITIALIZER(device_listeners); = QTAILQ_HEAD_INITIALIZER(device_listeners);
...@@ -364,13 +343,19 @@ void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev, ...@@ -364,13 +343,19 @@ void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
object_unparent(OBJECT(dev)); object_unparent(OBJECT(dev));
} }
/* Like qdev_init(), but terminate program via error_report() instead of /*
returning an error value. This is okay during machine creation. * Realize @dev.
Don't use for hotplug, because there callers need to recover from * Device properties should be set before calling this function. IRQs
failure. Exception: if you know the device's init() callback can't * and MMIO regions should be connected/mapped after calling this
fail, then qdev_init_nofail() can't fail either, and is therefore * function.
usable even then. But relying on the device implementation that * On failure, report an error with error_report() and terminate the
way is somewhat unclean, and best avoided. */ * program. This is okay during machine creation. Don't use for
* hotplug, because there callers need to recover from failure.
* Exception: if you know the device's init() callback can't fail,
* then qdev_init_nofail() can't fail either, and is therefore usable
* even then. But relying on the device implementation that way is
* somewhat unclean, and best avoided.
*/
void qdev_init_nofail(DeviceState *dev) void qdev_init_nofail(DeviceState *dev)
{ {
Error *err = NULL; Error *err = NULL;
......
...@@ -66,7 +66,7 @@ struct VMStateDescription; ...@@ -66,7 +66,7 @@ struct VMStateDescription;
* After successful realization, setting static properties will fail. * After successful realization, setting static properties will fail.
* *
* As an interim step, the #DeviceState:realized property is set by deprecated * As an interim step, the #DeviceState:realized property is set by deprecated
* functions qdev_init() and qdev_init_nofail(). * function qdev_init_nofail().
* In the future, devices will propagate this state change to their children * In the future, devices will propagate this state change to their children
* and along busses they expose. * and along busses they expose.
* The point in time will be deferred to machine creation, so that values * The point in time will be deferred to machine creation, so that values
...@@ -262,7 +262,6 @@ typedef struct GlobalProperty { ...@@ -262,7 +262,6 @@ typedef struct GlobalProperty {
DeviceState *qdev_create(BusState *bus, const char *name); DeviceState *qdev_create(BusState *bus, const char *name);
DeviceState *qdev_try_create(BusState *bus, const char *name); DeviceState *qdev_try_create(BusState *bus, const char *name);
int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
void qdev_init_nofail(DeviceState *dev); void qdev_init_nofail(DeviceState *dev);
void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id, void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
int required_for_version); int required_for_version);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册