qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: afaerber@suse.de
Subject: [Qemu-devel] [PATCH 1/8] qdev: Improve qdev_init_nofail()'s error reporting
Date: Wed,  4 Feb 2015 18:33:01 +0100	[thread overview]
Message-ID: <1423071188-1085-2-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1423071188-1085-1-git-send-email-armbru@redhat.com>

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 <armbru@redhat.com>
---
 hw/core/qdev.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 2eacac0..416c7a4 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;
 
-    if (qdev_init(dev) < 0) {
-        error_report("Initialization of device %s failed", typename);
+    assert(!dev->realized);
+
+    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);
     }
 }
-- 
1.9.3

  reply	other threads:[~2015-02-04 17:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-04 17:33 [Qemu-devel] [PATCH 0/8] Cleanups around unchecked qdev_init() Markus Armbruster
2015-02-04 17:33 ` Markus Armbruster [this message]
2015-02-04 17:33 ` [Qemu-devel] [PATCH 2/8] ide/isa: Replace unchecked qdev_init() by qdev_init_nofail() Markus Armbruster
2015-02-04 17:33 ` [Qemu-devel] [PATCH 3/8] leon3: " Markus Armbruster
2015-02-12  9:30   ` Fabien Chouteau
2015-02-04 17:33 ` [Qemu-devel] [PATCH 4/8] etsec: Replace " Markus Armbruster
2015-02-04 17:33 ` [Qemu-devel] [PATCH 5/8] serial: Factor out common serial_hds_isa_init() Markus Armbruster
2015-02-04 17:33 ` [Qemu-devel] [PATCH 6/8] serial: serial_hds_isa_init() shouldn't fail Markus Armbruster
2015-02-04 17:33 ` [Qemu-devel] [PATCH 7/8] parallel: Factor out common parallel_hds_isa_init() Markus Armbruster
2015-02-04 17:33 ` [Qemu-devel] [PATCH 8/8] parallel: parallel_hds_isa_init() shouldn't fail Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423071188-1085-2-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=afaerber@suse.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).