From patchwork Wed Dec 16 13:22:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 41258 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 93859B6F0D for ; Thu, 17 Dec 2009 00:23:20 +1100 (EST) Received: from localhost ([127.0.0.1]:33075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKtqX-0007Vo-Ee for incoming@patchwork.ozlabs.org; Wed, 16 Dec 2009 08:23:17 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NKtpd-0007IV-6x for qemu-devel@nongnu.org; Wed, 16 Dec 2009 08:22:21 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NKtpY-0007Ec-8O for qemu-devel@nongnu.org; Wed, 16 Dec 2009 08:22:20 -0500 Received: from [199.232.76.173] (port=37248 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKtpX-0007EO-Rx for qemu-devel@nongnu.org; Wed, 16 Dec 2009 08:22:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:26411) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NKtpX-0001FL-Ek for qemu-devel@nongnu.org; Wed, 16 Dec 2009 08:22:15 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBGDMECq020333 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Dec 2009 08:22:14 -0500 Received: from zweiblum.home.kraxel.org (vpn2-9-244.ams2.redhat.com [10.36.9.244]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBGDMDrW017761; Wed, 16 Dec 2009 08:22:13 -0500 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 0CCF770FCA; Wed, 16 Dec 2009 14:22:11 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 16 Dec 2009 14:22:11 +0100 Message-Id: <1260969731-26271-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [FOR 0.12 PATCH] qdev: improve property error reporting. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add a error message in case we fail to parse a qdev property. Also make qemu not abort() in case setting a global property can't be set. This used to be a clear programming error. The introduction of the -global switch changed that though, so better exit instead (after printing the new error message). Signed-off-by: Gerd Hoffmann --- hw/qdev-properties.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index fb07279..217ddc0 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -500,7 +500,12 @@ int qdev_prop_parse(DeviceState *dev, const char *name, const char *value) dev->info->name, name); return -1; } - return prop->info->parse(dev, prop, value); + if (prop->info->parse(dev, prop, value) != 0) { + fprintf(stderr, "property \"%s.%s\": failed to parse \"%s\"\n", + dev->info->name, name, value); + return -1; + } + return 0; } void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type) @@ -619,7 +624,7 @@ void qdev_prop_set_globals(DeviceState *dev) continue; } if (qdev_prop_parse(dev, prop->property, prop->value) != 0) { - abort(); + exit(1); } } }