From patchwork Tue Oct 8 17:44:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 281577 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 793F12C0090 for ; Wed, 9 Oct 2013 05:45:14 +1100 (EST) Received: from localhost ([::1]:38343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTbu4-0000Xq-E4 for incoming@patchwork.ozlabs.org; Tue, 08 Oct 2013 14:21:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTbeD-00054A-54 for qemu-devel@nongnu.org; Tue, 08 Oct 2013 14:05:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTbdu-0007aO-F4 for qemu-devel@nongnu.org; Tue, 08 Oct 2013 14:04:41 -0400 Received: from cantor2.suse.de ([195.135.220.15]:43046 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTbdu-0007YM-82 for qemu-devel@nongnu.org; Tue, 08 Oct 2013 14:04:22 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E728CA5752 for ; Tue, 8 Oct 2013 19:45:07 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Tue, 8 Oct 2013 19:44:48 +0200 Message-Id: <1381254296-3203-51-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1381254296-3203-1-git-send-email-afaerber@suse.de> References: <1381254296-3203-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PULL 50/58] qdev-monitor: Inline qdev_init() for device_add X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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(-) diff --git a/qdev-monitor.c b/qdev-monitor.c index f259e07..b7daab7 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -449,6 +449,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) { @@ -531,7 +532,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;