0a122b
From 69d7d4071c52078ff3040d693e07063de2730925 Mon Sep 17 00:00:00 2001
0a122b
From: Markus Armbruster <armbru@redhat.com>
0a122b
Date: Fri, 17 Jan 2014 17:07:56 +0100
0a122b
Subject: [PATCH 06/11] qdev-monitor: Inline qdev_init() for device_add
0a122b
MIME-Version: 1.0
0a122b
Content-Type: text/plain; charset=UTF-8
0a122b
Content-Transfer-Encoding: 8bit
0a122b
0a122b
RH-Author: Markus Armbruster <armbru@redhat.com>
0a122b
Message-id: <1389978479-30595-7-git-send-email-armbru@redhat.com>
0a122b
Patchwork-id: 56793
0a122b
O-Subject: [PATCH 7.0 qemu-kvm 6/9] qdev-monitor: Inline qdev_init() for device_add
0a122b
Bugzilla: 669524
0a122b
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
0a122b
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
0a122b
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
0a122b
0a122b
From: Andreas Färber <afaerber@suse.de>
0a122b
0a122b
For historic reasons, qdev_init() unparents the device on failure.
0a122b
Inline this to make the error paths clearer and consistent.
0a122b
0a122b
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
0a122b
Signed-off-by: Andreas Färber <afaerber@suse.de>
0a122b
(cherry picked from commit 852e2c5008563692a8868260480e76b95bb9018c)
0a122b
Signed-off-by: Markus Armbruster <armbru@redhat.com>
0a122b
---
0a122b
 qdev-monitor.c | 7 ++++++-
0a122b
 1 file changed, 6 insertions(+), 1 deletion(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 qdev-monitor.c |    7 ++++++-
0a122b
 1 files changed, 6 insertions(+), 1 deletions(-)
0a122b
0a122b
diff --git a/qdev-monitor.c b/qdev-monitor.c
0a122b
index 464e7bd..eb05b4c 100644
0a122b
--- a/qdev-monitor.c
0a122b
+++ b/qdev-monitor.c
0a122b
@@ -459,6 +459,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
0a122b
     const char *driver, *path, *id;
0a122b
     DeviceState *dev;
0a122b
     BusState *bus = NULL;
0a122b
+    Error *err = NULL;
0a122b
 
0a122b
     driver = qemu_opt_get(opts, "driver");
0a122b
     if (!driver) {
0a122b
@@ -541,7 +542,11 @@ DeviceState *qdev_device_add(QemuOpts *opts)
0a122b
                                   OBJECT(dev), NULL);
0a122b
         g_free(name);
0a122b
     }
0a122b
-    if (qdev_init(dev) < 0) {
0a122b
+    object_property_set_bool(OBJECT(dev), true, "realized", &err;;
0a122b
+    if (err != NULL) {
0a122b
+        qerror_report_err(err);
0a122b
+        error_free(err);
0a122b
+        object_unparent(OBJECT(dev));
0a122b
         object_unref(OBJECT(dev));
0a122b
         qerror_report(QERR_DEVICE_INIT_FAILED, driver);
0a122b
         return NULL;
0a122b
-- 
0a122b
1.7.1
0a122b