From patchwork Thu Jul 7 19:59:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 9219573 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6A62E607D9 for ; Thu, 7 Jul 2016 20:01:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DD5128500 for ; Thu, 7 Jul 2016 20:01:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5243828502; Thu, 7 Jul 2016 20:01:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0043328500 for ; Thu, 7 Jul 2016 20:01:15 +0000 (UTC) Received: from localhost ([::1]:42039 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLFU3-000642-3t for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Jul 2016 16:01:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLFSe-0004DF-E8 for qemu-devel@nongnu.org; Thu, 07 Jul 2016 15:59:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLFSa-0004HD-4h for qemu-devel@nongnu.org; Thu, 07 Jul 2016 15:59:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33385) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLFSZ-0004Gh-VF for qemu-devel@nongnu.org; Thu, 07 Jul 2016 15:59:44 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A8D265425; Thu, 7 Jul 2016 19:59:43 +0000 (UTC) Received: from localhost (vpn1-4-171.gru2.redhat.com [10.97.4.171]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u67Jxfno021946; Thu, 7 Jul 2016 15:59:42 -0400 From: Eduardo Habkost To: Peter Maydell Date: Thu, 7 Jul 2016 16:59:09 -0300 Message-Id: <1467921562-11796-4-git-send-email-ehabkost@redhat.com> In-Reply-To: <1467921562-11796-1-git-send-email-ehabkost@redhat.com> References: <1467921562-11796-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 07 Jul 2016 19:59:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/16] qdev: GlobalProperty.errp field X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , qemu-devel@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The new field will allow error handling to be configured by qdev_prop_register_global() callers: &error_fatal and &error_abort can be used to make QEMU exit or abort if any errors are reported when applying the properties. While doing it, change the error message from "global %s.%s=%s ignored" to "can't apply global %s.%s=%s". Suggested-by: Paolo Bonzini Reviewed-by: Igor Mammedov Reviewed-by: Markus Armbruster Signed-off-by: Eduardo Habkost --- hw/core/qdev-properties.c | 11 ++++++++--- include/hw/qdev-core.h | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index c10edee..3c20c8e 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1085,9 +1085,14 @@ static void qdev_prop_set_globals_for_type(DeviceState *dev, prop->used = true; object_property_parse(OBJECT(dev), prop->value, prop->property, &err); if (err != NULL) { - assert(prop->user_provided); - error_reportf_err(err, "Warning: global %s.%s=%s ignored: ", - prop->driver, prop->property, prop->value); + error_prepend(&err, "can't apply global %s.%s=%s: ", + prop->driver, prop->property, prop->value); + if (prop->errp) { + error_propagate(prop->errp, err); + } else { + assert(prop->user_provided); + error_reportf_err(err, "Warning: "); + } } } } diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 24aa0a7..1d1f861 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -259,6 +259,9 @@ struct PropertyInfo { * @user_provided: Set to true if property comes from user-provided config * (command-line or config file). * @used: Set to true if property was used when initializing a device. + * @errp: Error destination, used like first argument of error_setg() + * in case property setting fails later. If @errp is NULL, we + * print warnings instead of ignoring errors silently. */ typedef struct GlobalProperty { const char *driver; @@ -266,6 +269,7 @@ typedef struct GlobalProperty { const char *value; bool user_provided; bool used; + Error **errp; } GlobalProperty; /*** Board API. This should go away once we have a machine config file. ***/