From patchwork Thu Apr 12 13:44:23 2012 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: 152085 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7CFE1B7098 for ; Fri, 13 Apr 2012 00:45:36 +1000 (EST) Received: from localhost ([::1]:49755 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SILHC-0000i3-9o for incoming@patchwork.ozlabs.org; Thu, 12 Apr 2012 10:45:34 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SILGN-0000Ng-Eb for qemu-devel@nongnu.org; Thu, 12 Apr 2012 10:45:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SILG7-00039Z-8y for qemu-devel@nongnu.org; Thu, 12 Apr 2012 10:44:43 -0400 Received: from cantor2.suse.de ([195.135.220.15]:37938 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SILG6-00035x-T7 for qemu-devel@nongnu.org; Thu, 12 Apr 2012 10:44:27 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 041D294056; Thu, 12 Apr 2012 16:44:25 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Thu, 12 Apr 2012 15:44:23 +0200 Message-Id: <1334238263-28572-1-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1334179793-5914-1-git-send-email-pbonzini@redhat.com> References: <1334179793-5914-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori , Peter Maydell Subject: [Qemu-devel] [PATCH v2] qom: Introduce object_realize_nofail() 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 Wrap setting of Object::realized property, error reporting and exit(1) into a helper function. It is the equivalent of qdev_init_nofail(). Signed-off-by: Andreas Färber Cc: Anthony Liguori Cc: Paolo Bonzini Cc: Peter Maydell --- Hi Paolo, please consider appending this patch to your push-push series. It then provides equivalent second-stage init functionality for non-qdev objects, as desired for ARMCPU and SH7750 SoC. include/qemu/object.h | 10 ++++++++++ qom/object.c | 11 +++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/include/qemu/object.h b/include/qemu/object.h index 360181d..524d3b0 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -504,6 +504,16 @@ void object_initialize_with_type(void *data, Type type); void object_initialize(void *obj, const char *typename); /** + * object_realize_nofail: + * @obj: The object to realize. + * + * This function will complete the initialization of an object based on + * properties set by setting the "realized" property to true. + * Like #qdev_init_nofail it will terminate the process in case of errors. + */ +void object_realize_nofail(Object *obj); + +/** * object_finalize: * @obj: The object to finalize. * diff --git a/qom/object.c b/qom/object.c index f4f29ab..1ef0b9b 100644 --- a/qom/object.c +++ b/qom/object.c @@ -381,6 +381,17 @@ void object_initialize(void *data, const char *typename) object_initialize_with_type(data, type); } +void object_realize_nofail(Object *obj) +{ + Error *err = NULL; + + object_property_set_bool(obj, true, "realized", &err); + if (error_is_set(&err)) { + qerror_report_err(err); + exit(1); + } +} + static void object_property_del_all(Object *obj) { while (!QTAILQ_EMPTY(&obj->properties)) {