From 852e2c5008563692a8868260480e76b95bb9018c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 7 Oct 2013 16:42:34 +0200 Subject: qdev-monitor: Inline qdev_init() for device_add MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For historic reasons, qdev_init() unparents the device on failure. Inline this to make the error paths clearer and consistent. Reviewed-by: Igor Mammedov Signed-off-by: Andreas Färber --- qdev-monitor.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'qdev-monitor.c') diff --git a/qdev-monitor.c b/qdev-monitor.c index a46da32e99..dc37a43dd9 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -458,6 +458,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) const char *driver, *path, *id; DeviceState *dev; BusState *bus = NULL; + Error *err = NULL; driver = qemu_opt_get(opts, "driver"); if (!driver) { @@ -540,7 +541,11 @@ DeviceState *qdev_device_add(QemuOpts *opts) OBJECT(dev), NULL); g_free(name); } - if (qdev_init(dev) < 0) { + object_property_set_bool(OBJECT(dev), true, "realized", &err); + if (err != NULL) { + qerror_report_err(err); + error_free(err); + object_unparent(OBJECT(dev)); object_unref(OBJECT(dev)); qerror_report(QERR_DEVICE_INIT_FAILED, driver); return NULL; -- cgit v1.2.3