From patchwork Tue Feb 5 20:39:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 218358 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 5AF4A2C02C1 for ; Wed, 6 Feb 2013 08:33:35 +1100 (EST) Received: from localhost ([::1]:38935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2pHr-0003T7-Dq for incoming@patchwork.ozlabs.org; Tue, 05 Feb 2013 15:38:39 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2pHD-0002cV-3S for qemu-devel@nongnu.org; Tue, 05 Feb 2013 15:38:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U2pH4-00016Q-Ct for qemu-devel@nongnu.org; Tue, 05 Feb 2013 15:37:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37862) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2pH4-000167-2H for qemu-devel@nongnu.org; Tue, 05 Feb 2013 15:37:50 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r15KbkU4003021 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 5 Feb 2013 15:37:46 -0500 Received: from lacos-laptop.usersys.redhat.com (vpn1-5-180.ams2.redhat.com [10.36.5.180]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r15KbRvd020516; Tue, 5 Feb 2013 15:37:44 -0500 From: Laszlo Ersek To: aliguori@us.ibm.com, pbonzini@redhat.com, afaerber@suse.de, lcapitulino@redhat.com, stefanha@linux.vnet.ibm.com, xiawenc@linux.vnet.ibm.com, kwolf@redhat.com, ehabkost@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Date: Tue, 5 Feb 2013 21:39:19 +0100 Message-Id: <1360096768-8863-7-git-send-email-lersek@redhat.com> In-Reply-To: <1360096768-8863-1-git-send-email-lersek@redhat.com> References: <1360096768-8863-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 06/15] set_property(): extend signature with Error 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 Signed-off-by: Laszlo Ersek --- hw/qdev-monitor.c | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index cf96046..545e66c 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -100,9 +100,14 @@ static void qdev_print_devinfo(ObjectClass *klass, void *opaque) error_printf("\n"); } +typedef struct { + DeviceState *dev; + Error **errp; +} PropertyContext; + static int set_property(const char *name, const char *value, void *opaque) { - DeviceState *dev = opaque; + PropertyContext *ctx = opaque; Error *err = NULL; if (strcmp(name, "driver") == 0) @@ -110,7 +115,7 @@ static int set_property(const char *name, const char *value, void *opaque) if (strcmp(name, "bus") == 0) return 0; - qdev_prop_parse(dev, name, value, &err); + qdev_prop_parse(ctx->dev, name, value, &err); if (error_is_set(&err)) { qerror_report_err(err); error_free(err); @@ -481,10 +486,16 @@ DeviceState *qdev_device_add(QemuOpts *opts) if (id) { qdev->id = id; } - if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) { - qdev_free(qdev); - return NULL; + + { + PropertyContext ctx = { .dev = qdev, .errp = NULL }; + + if (qemu_opt_foreach(opts, set_property, &ctx, 1) != 0) { + qdev_free(qdev); + return NULL; + } } + if (qdev->id) { object_property_add_child(qdev_get_peripheral(), qdev->id, OBJECT(qdev), NULL);