From patchwork Tue Nov 27 09:27:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1003711 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 433zJk24Sdz9s3C for ; Tue, 27 Nov 2018 20:39:34 +1100 (AEDT) Received: from localhost ([::1]:40903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRZq7-0002rF-OG for incoming@patchwork.ozlabs.org; Tue, 27 Nov 2018 04:39:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRZgc-0003RB-3I for qemu-devel@nongnu.org; Tue, 27 Nov 2018 04:29:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRZgb-0004vS-7t for qemu-devel@nongnu.org; Tue, 27 Nov 2018 04:29:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39798) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRZgb-0004ut-0n for qemu-devel@nongnu.org; Tue, 27 Nov 2018 04:29:41 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6548137E87 for ; Tue, 27 Nov 2018 09:29:40 +0000 (UTC) Received: from localhost (ovpn-112-28.ams2.redhat.com [10.36.112.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30060608C1; Tue, 27 Nov 2018 09:29:35 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 13:27:45 +0400 Message-Id: <20181127092801.21777-13-marcandre.lureau@redhat.com> In-Reply-To: <20181127092801.21777-1-marcandre.lureau@redhat.com> References: <20181127092801.21777-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 27 Nov 2018 09:29:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v4 12/28] accel: register global_props like machine globals 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: imammedo@redhat.com, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" global_props is only used for Xen xen_compat_props. It's a static array of GlobalProperty, like machine globals in SET_MACHINE_COMPAT(). Let's register the globals the same way, without extra copy allocation. Signed-off-by: Marc-André Lureau Reviewed-by: Igor Mammedov --- include/hw/qdev-properties.h | 29 ----------------------------- accel/accel.c | 9 ++++++++- hw/core/qdev-properties.c | 21 --------------------- 3 files changed, 8 insertions(+), 51 deletions(-) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 4f60cc88f3..a95f4a73eb 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -255,35 +255,6 @@ void qdev_prop_set_globals(DeviceState *dev); void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, Property *prop, const char *value); -/** - * register_compat_prop: - * - * Register internal (not user-provided) global property, changing the - * default value of a given property in a device type. This can be used - * for enabling machine-type compatibility or for enabling - * accelerator-specific defaults in devices. - * - * The property values set using this function must be always valid and - * never report setter errors, as the property will have - * GlobalProperty::errp set to &error_abort. - * - * User-provided global properties should override internal global - * properties, so callers of this function should ensure that it is - * called before user-provided global properties are registered. - * - * @driver: Device type to be affected - * @property: Property whose default value is going to be changed - * @value: New default value for the property - */ -void register_compat_prop(const char *driver, const char *property, - const char *value); -/* - * register_compat_props_array(): using register_compat_prop(), which - * only registers internal global properties (which has lower priority - * than user-provided global properties) - */ -void register_compat_props_array(GlobalProperty *prop); - /** * qdev_property_add_static: * @dev: Device to add the property to. diff --git a/accel/accel.c b/accel/accel.c index 966b2d8f53..3da26eb90f 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -34,6 +34,7 @@ #include "qom/object.h" #include "qemu/error-report.h" #include "qemu/option.h" +#include "qapi/error.h" static const TypeInfo accel_type = { .name = TYPE_ACCEL, @@ -121,7 +122,13 @@ void configure_accelerator(MachineState *ms) void accel_register_compat_props(AccelState *accel) { AccelClass *class = ACCEL_GET_CLASS(accel); - register_compat_props_array(class->global_props); + GlobalProperty *prop = class->global_props; + + for (; prop && prop->driver; prop++) { + /* Any compat_props must never cause error */ + prop->errp = &error_abort; + qdev_prop_register_global(prop); + } } void accel_setup_post(MachineState *ms) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 35072dec1e..ab61d502fd 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1180,27 +1180,6 @@ void qdev_prop_register_global(GlobalProperty *prop) global_props = g_list_append(global_props, prop); } -void register_compat_prop(const char *driver, - const char *property, - const char *value) -{ - GlobalProperty *p = g_new0(GlobalProperty, 1); - - /* Any compat_props must never cause error */ - p->errp = &error_abort; - p->driver = driver; - p->property = property; - p->value = value; - qdev_prop_register_global(p); -} - -void register_compat_props_array(GlobalProperty *prop) -{ - for (; prop && prop->driver; prop++) { - register_compat_prop(prop->driver, prop->property, prop->value); - } -} - void qdev_prop_register_global_list(GlobalProperty *props) { int i;