From c4bacafb717de55538311b80a185ce9166b8daa2 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 4 Feb 2015 18:33:01 +0100 Subject: qdev: Improve qdev_init_nofail()'s error reporting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We get two error messages: a specific one from qdev_init(), and a generic one from qdev_init_nofail(). The specific one gets suppressed in QMP context. qdev_init_nofail() failing there is a bug, though. Cut out the qdev_init() middle-man: realize the device, and on error exit with a single error message. Signed-off-by: Markus Armbruster Signed-off-by: Andreas Färber --- hw/core/qdev.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'hw/core/qdev.c') diff --git a/hw/core/qdev.c b/hw/core/qdev.c index ff81f675da..10bf086a0a 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -373,10 +373,15 @@ void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev, way is somewhat unclean, and best avoided. */ void qdev_init_nofail(DeviceState *dev) { - const char *typename = object_get_typename(OBJECT(dev)); + Error *err = NULL; + + assert(!dev->realized); - if (qdev_init(dev) < 0) { - error_report("Initialization of device %s failed", typename); + object_property_set_bool(OBJECT(dev), true, "realized", &err); + if (err) { + error_report("Initialization of device %s failed: %s", + object_get_typename(OBJECT(dev)), + error_get_pretty(err)); exit(1); } } -- cgit v1.2.3