From nobody Wed Nov 5 18:23:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536757171557331.7622345838165; Wed, 12 Sep 2018 05:59:31 -0700 (PDT) Received: from localhost ([::1]:36143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04ju-0001SA-1x for importer@patchew.org; Wed, 12 Sep 2018 08:59:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04gO-0007DW-Gm for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:55:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g04gN-0007gV-ME for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:55:48 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55000 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g04gN-0007g8-FN for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:55:47 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02D148011059; Wed, 12 Sep 2018 12:55:47 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 388152166BA3; Wed, 12 Sep 2018 12:55:41 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 12 Sep 2018 16:55:23 +0400 Message-Id: <20180912125531.32131-2-marcandre.lureau@redhat.com> In-Reply-To: <20180912125531.32131-1-marcandre.lureau@redhat.com> References: <20180912125531.32131-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 12 Sep 2018 12:55:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 12 Sep 2018 12:55:47 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 1/9] qom/user-creatable: add a few helper macros 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: Eduardo Habkost , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Igor Mammedov , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Improve a bit code readability. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qom/object_interfaces.h | 4 ++++ qom/object.c | 4 ++-- qom/object_interfaces.c | 9 +++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/qom/object_interfaces.h b/include/qom/object_interface= s.h index 4d513fb329..46b0861457 100644 --- a/include/qom/object_interfaces.h +++ b/include/qom/object_interfaces.h @@ -9,9 +9,13 @@ #define USER_CREATABLE_CLASS(klass) \ OBJECT_CLASS_CHECK(UserCreatableClass, (klass), \ TYPE_USER_CREATABLE) +#define IS_USER_CREATABLE_CLASS(klass) \ + object_class_dynamic_cast(OBJECT_CLASS(oc), TYPE_USER_CREATABLE) #define USER_CREATABLE_GET_CLASS(obj) \ OBJECT_GET_CLASS(UserCreatableClass, (obj), \ TYPE_USER_CREATABLE) +#define IS_USER_CREATABLE(obj) \ + object_dynamic_cast(OBJECT(obj), TYPE_USER_CREATABLE) #define USER_CREATABLE(obj) \ INTERFACE_CHECK(UserCreatable, (obj), \ TYPE_USER_CREATABLE) diff --git a/qom/object.c b/qom/object.c index 75d1d48944..0703e8e4ff 100644 --- a/qom/object.c +++ b/qom/object.c @@ -424,7 +424,7 @@ void object_initialize_childv(Object *parentobj, const = char *propname, goto out; } =20 - if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) { + if (IS_USER_CREATABLE(obj)) { user_creatable_complete(obj, &local_err); if (local_err) { object_unparent(obj); @@ -605,7 +605,7 @@ Object *object_new_with_propv(const char *typename, goto error; } =20 - if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) { + if (IS_USER_CREATABLE(obj)) { user_creatable_complete(obj, &local_err); if (local_err) { object_unparent(obj); diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 72b97a8bed..e3084bc04a 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -10,18 +10,15 @@ =20 void user_creatable_complete(Object *obj, Error **errp) { - UserCreatableClass *ucc; - UserCreatable *uc =3D - (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE); =20 - if (!uc) { + if (!IS_USER_CREATABLE(obj)) { return; } =20 - ucc =3D USER_CREATABLE_GET_CLASS(uc); + ucc =3D USER_CREATABLE_GET_CLASS(obj); if (ucc->complete) { - ucc->complete(uc, errp); + ucc->complete(USER_CREATABLE(obj), errp); } } =20 --=20 2.19.0.rc1 From nobody Wed Nov 5 18:23:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536757293283977.9252053968145; Wed, 12 Sep 2018 06:01:33 -0700 (PDT) Received: from localhost ([::1]:36176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04lv-0002st-Na for importer@patchew.org; Wed, 12 Sep 2018 09:01:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04gT-0007Hi-Df for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:55:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g04gS-0007lN-BM for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:55:53 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54484 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g04gS-0007kx-5q for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:55:52 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3E9A40241C0; Wed, 12 Sep 2018 12:55:51 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FBE22156889; Wed, 12 Sep 2018 12:55:50 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 12 Sep 2018 16:55:24 +0400 Message-Id: <20180912125531.32131-3-marcandre.lureau@redhat.com> In-Reply-To: <20180912125531.32131-1-marcandre.lureau@redhat.com> References: <20180912125531.32131-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 12 Sep 2018 12:55:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 12 Sep 2018 12:55:51 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 2/9] 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: Eduardo Habkost , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Igor Mammedov , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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=C3=A9 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 *de= v, Property *prop, const char *value); =20 -/** - * 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" =20 static const TypeInfo accel_type =3D { .name =3D TYPE_ACCEL, @@ -121,7 +122,13 @@ void configure_accelerator(MachineState *ms) void accel_register_compat_props(AccelState *accel) { AccelClass *class =3D ACCEL_GET_CLASS(accel); - register_compat_props_array(class->global_props); + GlobalProperty *prop =3D class->global_props; + + for (; prop && prop->driver; prop++) { + /* Any compat_props must never cause error */ + prop->errp =3D &error_abort; + qdev_prop_register_global(prop); + } } =20 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 =3D g_list_append(global_props, prop); } =20 -void register_compat_prop(const char *driver, - const char *property, - const char *value) -{ - GlobalProperty *p =3D g_new0(GlobalProperty, 1); - - /* Any compat_props must never cause error */ - p->errp =3D &error_abort; - p->driver =3D driver; - p->property =3D property; - p->value =3D 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; --=20 2.19.0.rc1 From nobody Wed Nov 5 18:23:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536757057417544.7049552382622; Wed, 12 Sep 2018 05:57:37 -0700 (PDT) Received: from localhost ([::1]:36133 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04i8-0008Jz-3X for importer@patchew.org; Wed, 12 Sep 2018 08:57:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04gf-0007Qw-15 for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g04gb-0007w1-Gn for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:04 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38806 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g04gb-0007vW-Av for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:01 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E02EA40216E5; Wed, 12 Sep 2018 12:56:00 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CF41112D168; Wed, 12 Sep 2018 12:55:55 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 12 Sep 2018 16:55:25 +0400 Message-Id: <20180912125531.32131-4-marcandre.lureau@redhat.com> In-Reply-To: <20180912125531.32131-1-marcandre.lureau@redhat.com> References: <20180912125531.32131-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 12 Sep 2018 12:56:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 12 Sep 2018 12:56:00 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 3/9] qdev: move qdev_prop_register_global_list() to tests 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: Eduardo Habkost , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Igor Mammedov , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The function is only used by a test, move it there. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/qdev-properties.h | 1 - hw/core/qdev-properties.c | 9 --------- tests/test-qdev-global-props.c | 18 ++++++++++++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index a95f4a73eb..3ab9cd2eb6 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -249,7 +249,6 @@ void qdev_prop_set_enum(DeviceState *dev, const char *n= ame, int value); void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value); =20 void qdev_prop_register_global(GlobalProperty *prop); -void qdev_prop_register_global_list(GlobalProperty *props); int qdev_prop_check_globals(void); void qdev_prop_set_globals(DeviceState *dev); void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *de= v, diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index ab61d502fd..bd84c4ea4c 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1180,15 +1180,6 @@ void qdev_prop_register_global(GlobalProperty *prop) global_props =3D g_list_append(global_props, prop); } =20 -void qdev_prop_register_global_list(GlobalProperty *props) -{ - int i; - - for (i =3D 0; props[i].driver !=3D NULL; i++) { - qdev_prop_register_global(props+i); - } -} - int qdev_prop_check_globals(void) { GList *l; diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c index d81b0862d5..d8596e6637 100644 --- a/tests/test-qdev-global-props.c +++ b/tests/test-qdev-global-props.c @@ -89,6 +89,16 @@ static void test_static_prop(void) g_test_trap_assert_stdout(""); } =20 +static void register_global_list(GlobalProperty *props) +{ + int i; + + for (i =3D 0; props[i].driver !=3D NULL; i++) { + qdev_prop_register_global(props + i); + } +} + + /* Test setting of static property using global properties */ static void test_static_globalprop_subprocess(void) { @@ -98,7 +108,7 @@ static void test_static_globalprop_subprocess(void) {} }; =20 - qdev_prop_register_global_list(props); + register_global_list(props); =20 mt =3D STATIC_TYPE(object_new(TYPE_STATIC_PROPS)); qdev_init_nofail(DEVICE(mt)); @@ -216,7 +226,7 @@ static void test_dynamic_globalprop_subprocess(void) }; int all_used; =20 - qdev_prop_register_global_list(props); + register_global_list(props); =20 mt =3D DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); qdev_init_nofail(DEVICE(mt)); @@ -261,7 +271,7 @@ static void test_dynamic_globalprop_nouser_subprocess(v= oid) }; int all_used; =20 - qdev_prop_register_global_list(props); + register_global_list(props); =20 mt =3D DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); qdev_init_nofail(DEVICE(mt)); @@ -299,7 +309,7 @@ static void test_subclass_global_props(void) {} }; =20 - qdev_prop_register_global_list(props); + register_global_list(props); =20 mt =3D STATIC_TYPE(object_new(TYPE_SUBCLASS)); qdev_init_nofail(DEVICE(mt)); --=20 2.19.0.rc1 From nobody Wed Nov 5 18:23:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536757140857265.7205180739462; Wed, 12 Sep 2018 05:59:00 -0700 (PDT) Received: from localhost ([::1]:36142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04jT-000147-C4 for importer@patchew.org; Wed, 12 Sep 2018 08:58:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04gk-0007Uz-4M for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g04gh-00080v-EH for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:09 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38824 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g04gh-000801-5M for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:07 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F02640216FE; Wed, 12 Sep 2018 12:56:06 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id D89B710CD6B9; Wed, 12 Sep 2018 12:56:04 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 12 Sep 2018 16:55:26 +0400 Message-Id: <20180912125531.32131-5-marcandre.lureau@redhat.com> In-Reply-To: <20180912125531.32131-1-marcandre.lureau@redhat.com> References: <20180912125531.32131-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 12 Sep 2018 12:56:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 12 Sep 2018 12:56:06 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 4/9] qom/globals: move qdev globals to qom 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: Eduardo Habkost , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Igor Mammedov , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the global properties handling to QOM. For now, this is just a simple moving & renaming and the globals are only applied to TYPE_DEVICE. The following patches will generalize the global handling to other object types. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/qdev-core.h | 20 --------- include/hw/qdev-properties.h | 4 +- include/qom/globals.h | 32 +++++++++++++++ accel/accel.c | 2 +- hw/core/machine.c | 2 +- hw/core/qdev-properties.c | 67 ------------------------------ hw/core/qdev.c | 2 +- qom/cpu.c | 2 +- qom/globals.c | 75 ++++++++++++++++++++++++++++++++++ target/i386/cpu.c | 2 +- target/sparc/cpu.c | 2 +- tests/test-qdev-global-props.c | 6 +-- vl.c | 8 ++-- qom/Makefile.objs | 2 +- 14 files changed, 122 insertions(+), 104 deletions(-) create mode 100644 include/qom/globals.h create mode 100644 qom/globals.c diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index f1fd0f8736..9e4695d03f 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -246,26 +246,6 @@ struct PropertyInfo { ObjectPropertyRelease *release; }; =20 -/** - * GlobalProperty: - * @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. For - * hotplugged devices, errp is always ignored and warnings are - * printed instead. - */ -typedef struct GlobalProperty { - const char *driver; - const char *property; - const char *value; - bool user_provided; - bool used; - Error **errp; -} GlobalProperty; - /*** Board API. This should go away once we have a machine config file. = ***/ =20 DeviceState *qdev_create(BusState *bus, const char *name); diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 3ab9cd2eb6..c8b727f081 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -4,6 +4,7 @@ #include "qapi/qapi-types-block.h" #include "qapi/qapi-types-misc.h" #include "hw/qdev-core.h" +#include "qom/globals.h" =20 /*** qdev-properties.c ***/ =20 @@ -248,9 +249,6 @@ void qdev_prop_set_enum(DeviceState *dev, const char *n= ame, int value); /* FIXME: Remove opaque pointer properties. */ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value); =20 -void qdev_prop_register_global(GlobalProperty *prop); -int qdev_prop_check_globals(void); -void qdev_prop_set_globals(DeviceState *dev); void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *de= v, Property *prop, const char *value); =20 diff --git a/include/qom/globals.h b/include/qom/globals.h new file mode 100644 index 0000000000..28a0390233 --- /dev/null +++ b/include/qom/globals.h @@ -0,0 +1,32 @@ +#ifndef QOM_GLOBALS +#define QOM_GLOBALS + +#include "qom/object.h" + +/** + * GlobalProperty: + * @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. For + * hotplugged devices, errp is always ignored and warnings are + * printed instead. + */ +typedef struct GlobalProperty { + const char *driver; + const char *property; + const char *value; + bool user_provided; + bool used; + Error **errp; +} GlobalProperty; + +void object_property_register_global(GlobalProperty *prop); + +void object_property_set_globals(Object *obj); + +int object_property_check_globals(void); + +#endif diff --git a/accel/accel.c b/accel/accel.c index 3da26eb90f..6916e0d63d 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -127,7 +127,7 @@ void accel_register_compat_props(AccelState *accel) for (; prop && prop->driver; prop++) { /* Any compat_props must never cause error */ prop->errp =3D &error_abort; - qdev_prop_register_global(prop); + object_property_register_global(prop); } } =20 diff --git a/hw/core/machine.c b/hw/core/machine.c index 6b68e1218f..5f532939e4 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -855,7 +855,7 @@ void machine_register_compat_props(MachineState *machin= e) p =3D g_array_index(mc->compat_props, GlobalProperty *, i); /* Machine compat_props must never cause errors: */ p->errp =3D &error_abort; - qdev_prop_register_global(p); + object_property_register_global(p); } } =20 diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index bd84c4ea4c..4605ca9b78 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1173,73 +1173,6 @@ void qdev_prop_set_ptr(DeviceState *dev, const char = *name, void *value) *ptr =3D value; } =20 -static GList *global_props; - -void qdev_prop_register_global(GlobalProperty *prop) -{ - global_props =3D g_list_append(global_props, prop); -} - -int qdev_prop_check_globals(void) -{ - GList *l; - int ret =3D 0; - - for (l =3D global_props; l; l =3D l->next) { - GlobalProperty *prop =3D l->data; - ObjectClass *oc; - DeviceClass *dc; - if (prop->used) { - continue; - } - if (!prop->user_provided) { - continue; - } - oc =3D object_class_by_name(prop->driver); - oc =3D object_class_dynamic_cast(oc, TYPE_DEVICE); - if (!oc) { - warn_report("global %s.%s has invalid class name", - prop->driver, prop->property); - ret =3D 1; - continue; - } - dc =3D DEVICE_CLASS(oc); - if (!dc->hotpluggable && !prop->used) { - warn_report("global %s.%s=3D%s not used", - prop->driver, prop->property, prop->value); - ret =3D 1; - continue; - } - } - return ret; -} - -void qdev_prop_set_globals(DeviceState *dev) -{ - GList *l; - - for (l =3D global_props; l; l =3D l->next) { - GlobalProperty *prop =3D l->data; - Error *err =3D NULL; - - if (object_dynamic_cast(OBJECT(dev), prop->driver) =3D=3D NULL) { - continue; - } - prop->used =3D true; - object_property_parse(OBJECT(dev), prop->value, prop->property, &e= rr); - if (err !=3D NULL) { - error_prepend(&err, "can't apply global %s.%s=3D%s: ", - prop->driver, prop->property, prop->value); - if (!dev->hotplugged && prop->errp) { - error_propagate(prop->errp, err); - } else { - assert(prop->user_provided); - warn_report_err(err); - } - } - } -} - /* --- 64bit unsigned int 'size' type --- */ =20 static void get_size(Object *obj, Visitor *v, const char *name, void *opaq= ue, diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 529b82de18..473060b551 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -976,7 +976,7 @@ static void device_initfn(Object *obj) =20 static void device_post_init(Object *obj) { - qdev_prop_set_globals(DEVICE(obj)); + object_property_set_globals(obj); } =20 /* Unlink device from bus and free the structure. */ diff --git a/qom/cpu.c b/qom/cpu.c index 92599f3541..aaabe67648 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -314,7 +314,7 @@ static void cpu_common_parse_features(const char *typen= ame, char *features, prop->property =3D g_strdup(featurestr); prop->value =3D g_strdup(val); prop->errp =3D &error_fatal; - qdev_prop_register_global(prop); + object_property_register_global(prop); } else { error_setg(errp, "Expected key=3Dvalue format, found %s.", featurestr); diff --git a/qom/globals.c b/qom/globals.c new file mode 100644 index 0000000000..587f4a1b5c --- /dev/null +++ b/qom/globals.c @@ -0,0 +1,75 @@ +#include "qemu/osdep.h" + +#include "hw/qdev.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qom/globals.h" +#include "qom/object_interfaces.h" + +static GList *global_props; + +void object_property_register_global(GlobalProperty *prop) +{ + global_props =3D g_list_append(global_props, prop); +} + +void object_property_set_globals(Object *obj) +{ + DeviceState *dev =3D DEVICE(obj); + GList *l; + + for (l =3D global_props; l; l =3D l->next) { + GlobalProperty *prop =3D l->data; + Error *err =3D NULL; + + if (object_dynamic_cast(OBJECT(dev), prop->driver) =3D=3D NULL) { + continue; + } + prop->used =3D true; + object_property_parse(OBJECT(dev), prop->value, prop->property, &e= rr); + if (err !=3D NULL) { + error_prepend(&err, "can't apply global %s.%s=3D%s: ", + prop->driver, prop->property, prop->value); + if (!dev->hotplugged && prop->errp) { + error_propagate(prop->errp, err); + } else { + assert(prop->user_provided); + warn_report_err(err); + } + } + } +} + +int object_property_check_globals(void) +{ + GList *l; + int ret =3D 0; + + for (l =3D global_props; l; l =3D l->next) { + GlobalProperty *prop =3D l->data; + ObjectClass *oc; + DeviceClass *dc; + if (prop->used) { + continue; + } + if (!prop->user_provided) { + continue; + } + oc =3D object_class_by_name(prop->driver); + oc =3D object_class_dynamic_cast(oc, TYPE_DEVICE); + if (!oc) { + warn_report("global %s.%s has invalid class name", + prop->driver, prop->property); + ret =3D 1; + continue; + } + dc =3D DEVICE_CLASS(oc); + if (!dc->hotpluggable && !prop->used) { + warn_report("global %s.%s=3D%s not used", + prop->driver, prop->property, prop->value); + ret =3D 1; + continue; + } + } + return ret; +} diff --git a/target/i386/cpu.c b/target/i386/cpu.c index f24295e6e4..ead1f67805 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3414,7 +3414,7 @@ static void x86_cpu_parse_featurestr(const char *type= name, char *features, prop->property =3D g_strdup(name); prop->value =3D g_strdup(val); prop->errp =3D &error_fatal; - qdev_prop_register_global(prop); + object_property_register_global(prop); } =20 if (ambiguous) { diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 0f090ece54..3fde246d0d 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -112,7 +112,7 @@ cpu_add_feat_as_prop(const char *typename, const char *= name, const char *val) prop->property =3D g_strdup(name); prop->value =3D g_strdup(val); prop->errp =3D &error_fatal; - qdev_prop_register_global(prop); + object_property_register_global(prop); } =20 /* Parse "+feature,-feature,feature=3Dfoo" CPU feature string */ diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c index d8596e6637..9dffdf336d 100644 --- a/tests/test-qdev-global-props.c +++ b/tests/test-qdev-global-props.c @@ -94,7 +94,7 @@ static void register_global_list(GlobalProperty *props) int i; =20 for (i =3D 0; props[i].driver !=3D NULL; i++) { - qdev_prop_register_global(props + i); + object_property_register_global(props + i); } } =20 @@ -233,7 +233,7 @@ static void test_dynamic_globalprop_subprocess(void) =20 g_assert_cmpuint(mt->prop1, =3D=3D, 101); g_assert_cmpuint(mt->prop2, =3D=3D, 102); - all_used =3D qdev_prop_check_globals(); + all_used =3D object_property_check_globals(); g_assert_cmpuint(all_used, =3D=3D, 1); g_assert(props[0].used); g_assert(props[1].used); @@ -278,7 +278,7 @@ static void test_dynamic_globalprop_nouser_subprocess(v= oid) =20 g_assert_cmpuint(mt->prop1, =3D=3D, 101); g_assert_cmpuint(mt->prop2, =3D=3D, 102); - all_used =3D qdev_prop_check_globals(); + all_used =3D object_property_check_globals(); g_assert_cmpuint(all_used, =3D=3D, 0); g_assert(props[0].used); g_assert(props[1].used); diff --git a/vl.c b/vl.c index 5ba06adf78..03b8bda0ac 100644 --- a/vl.c +++ b/vl.c @@ -903,7 +903,7 @@ static void configure_rtc(QemuOpts *opts) .value =3D "slew", }; =20 - qdev_prop_register_global(&slew_lost_ticks); + object_property_register_global(&slew_lost_ticks); } else if (!strcmp(value, "none")) { /* discard is default */ } else { @@ -2872,7 +2872,7 @@ static int global_init_func(void *opaque, QemuOpts *o= pts, Error **errp) g->value =3D qemu_opt_get(opts, "value"); g->user_provided =3D true; g->errp =3D &error_fatal; - qdev_prop_register_global(g); + object_property_register_global(g); return 0; } =20 @@ -3564,7 +3564,7 @@ int main(int argc, char **argv, char **envp) .value =3D "slew", }; =20 - qdev_prop_register_global(&slew_lost_ticks); + object_property_register_global(&slew_lost_ticks); warn_report("This option is deprecated, " "use '-rtc driftfix=3Dslew' instead."); break; @@ -4623,7 +4623,7 @@ int main(int argc, char **argv, char **envp) } } =20 - qdev_prop_check_globals(); + object_property_check_globals(); if (vmstate_dump_file) { /* dump and exit */ dump_vmstate_json_to_file(vmstate_dump_file); diff --git a/qom/Makefile.objs b/qom/Makefile.objs index 516349eec3..723851ff28 100644 --- a/qom/Makefile.objs +++ b/qom/Makefile.objs @@ -1,4 +1,4 @@ qom-obj-y =3D object.o container.o qom-qobject.o -qom-obj-y +=3D object_interfaces.o +qom-obj-y +=3D object_interfaces.o globals.o =20 common-obj-y =3D cpu.o --=20 2.19.0.rc1 From nobody Wed Nov 5 18:23:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536757427876817.7438767548248; Wed, 12 Sep 2018 06:03:47 -0700 (PDT) Received: from localhost ([::1]:36184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04o1-0004D1-2F for importer@patchew.org; Wed, 12 Sep 2018 09:03:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04gp-0007Zk-WB for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g04gp-00088C-0b for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:15 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55040 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g04go-00087E-Pr for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:14 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6232E8011059; Wed, 12 Sep 2018 12:56:14 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA832FA996; Wed, 12 Sep 2018 12:56:09 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 12 Sep 2018 16:55:27 +0400 Message-Id: <20180912125531.32131-6-marcandre.lureau@redhat.com> In-Reply-To: <20180912125531.32131-1-marcandre.lureau@redhat.com> References: <20180912125531.32131-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 12 Sep 2018 12:56:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 12 Sep 2018 12:56:14 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 5/9] qom/globals: generalize object_property_set_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: Eduardo Habkost , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Igor Mammedov , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Handle calls of object_property_set_globals() with any object type, but only apply globals to TYPE_DEVICE & TYPE_USER_CREATABLE. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qom/globals.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/qom/globals.c b/qom/globals.c index 587f4a1b5c..8664baebe0 100644 --- a/qom/globals.c +++ b/qom/globals.c @@ -15,22 +15,28 @@ void object_property_register_global(GlobalProperty *pr= op) =20 void object_property_set_globals(Object *obj) { - DeviceState *dev =3D DEVICE(obj); GList *l; + DeviceState *dev =3D (DeviceState *)object_dynamic_cast(obj, TYPE_DEVI= CE); + + if (!dev && !IS_USER_CREATABLE(obj)) { + /* only TYPE_DEVICE and TYPE_USER_CREATABLE support globals */ + return; + } =20 for (l =3D global_props; l; l =3D l->next) { GlobalProperty *prop =3D l->data; Error *err =3D NULL; =20 - if (object_dynamic_cast(OBJECT(dev), prop->driver) =3D=3D NULL) { + if (object_dynamic_cast(obj, prop->driver) =3D=3D NULL) { continue; } prop->used =3D true; - object_property_parse(OBJECT(dev), prop->value, prop->property, &e= rr); + object_property_parse(obj, prop->value, prop->property, &err); if (err !=3D NULL) { error_prepend(&err, "can't apply global %s.%s=3D%s: ", prop->driver, prop->property, prop->value); - if (!dev->hotplugged && prop->errp) { + + if (dev && !dev->hotplugged && prop->errp) { error_propagate(prop->errp, err); } else { assert(prop->user_provided); @@ -56,15 +62,15 @@ int object_property_check_globals(void) continue; } oc =3D object_class_by_name(prop->driver); - oc =3D object_class_dynamic_cast(oc, TYPE_DEVICE); - if (!oc) { + dc =3D (DeviceClass *)object_class_dynamic_cast(oc, TYPE_DEVICE); + if (!IS_USER_CREATABLE_CLASS(oc) && !dc) { warn_report("global %s.%s has invalid class name", prop->driver, prop->property); ret =3D 1; continue; } - dc =3D DEVICE_CLASS(oc); - if (!dc->hotpluggable && !prop->used) { + + if (dc && !dc->hotpluggable) { warn_report("global %s.%s=3D%s not used", prop->driver, prop->property, prop->value); ret =3D 1; --=20 2.19.0.rc1 From nobody Wed Nov 5 18:23:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536757186412596.6576605525391; Wed, 12 Sep 2018 05:59:46 -0700 (PDT) Received: from localhost ([::1]:36144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04kD-0001ju-A9 for importer@patchew.org; Wed, 12 Sep 2018 08:59:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04h0-0007i8-C9 for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g04gx-0008Fe-6C for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:26 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49722 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g04gx-0008E2-0K for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:23 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9623E4023840; Wed, 12 Sep 2018 12:56:22 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFD732027EA4; Wed, 12 Sep 2018 12:56:17 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 12 Sep 2018 16:55:28 +0400 Message-Id: <20180912125531.32131-7-marcandre.lureau@redhat.com> In-Reply-To: <20180912125531.32131-1-marcandre.lureau@redhat.com> References: <20180912125531.32131-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 12 Sep 2018 12:56:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 12 Sep 2018 12:56:22 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 6/9] qom/object: set globals when initializing object 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: Eduardo Habkost , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Igor Mammedov , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Set globals for all objects, although only TYPE_DEVICE & TYPE_USER_CREATABLE can have globals for now. Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/core/qdev.c | 6 ------ qom/object.c | 2 ++ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 473060b551..28c6c8d7c9 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -974,11 +974,6 @@ static void device_initfn(Object *obj) QLIST_INIT(&dev->gpios); } =20 -static void device_post_init(Object *obj) -{ - object_property_set_globals(obj); -} - /* Unlink device from bus and free the structure. */ static void device_finalize(Object *obj) { @@ -1103,7 +1098,6 @@ static const TypeInfo device_type_info =3D { .parent =3D TYPE_OBJECT, .instance_size =3D sizeof(DeviceState), .instance_init =3D device_initfn, - .instance_post_init =3D device_post_init, .instance_finalize =3D device_finalize, .class_base_init =3D device_class_base_init, .class_init =3D device_class_init, diff --git a/qom/object.c b/qom/object.c index 0703e8e4ff..025ad0e191 100644 --- a/qom/object.c +++ b/qom/object.c @@ -12,6 +12,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qom/globals.h" #include "qom/object.h" #include "qom/object_interfaces.h" #include "qemu/cutils.h" @@ -382,6 +383,7 @@ static void object_initialize_with_type(void *data, siz= e_t size, TypeImpl *type) obj->properties =3D g_hash_table_new_full(g_str_hash, g_str_equal, NULL, object_property_free); object_init_with_type(obj, type); + object_property_set_globals(obj); object_post_init_with_type(obj, type); } =20 --=20 2.19.0.rc1 From nobody Wed Nov 5 18:23:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536757543127424.39019384760945; Wed, 12 Sep 2018 06:05:43 -0700 (PDT) Received: from localhost ([::1]:36195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04px-0005R6-KS for importer@patchew.org; Wed, 12 Sep 2018 09:05:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04h9-0007pd-LM for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g04h6-00004r-ER for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:35 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54516 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g04h5-0008W2-Vl for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:32 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B7C640241C0; Wed, 12 Sep 2018 12:56:31 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 643E2101042B; Wed, 12 Sep 2018 12:56:25 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 12 Sep 2018 16:55:29 +0400 Message-Id: <20180912125531.32131-8-marcandre.lureau@redhat.com> In-Reply-To: <20180912125531.32131-1-marcandre.lureau@redhat.com> References: <20180912125531.32131-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 12 Sep 2018 12:56:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 12 Sep 2018 12:56:31 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 7/9] tests: add user-creatable test to test-qdev-global-props 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: Eduardo Habkost , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Igor Mammedov , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a TYPE_USER_CREATABLE object global property check. Rename the test, since it is no longer QDev-specific. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ...dev-global-props.c =3D> test-global-props.c} | 128 ++++++++++++++++-- tests/Makefile.include | 4 +- 2 files changed, 117 insertions(+), 15 deletions(-) rename tests/{test-qdev-global-props.c =3D> test-global-props.c} (74%) diff --git a/tests/test-qdev-global-props.c b/tests/test-global-props.c similarity index 74% rename from tests/test-qdev-global-props.c rename to tests/test-global-props.c index 9dffdf336d..1c725245bc 100644 --- a/tests/test-qdev-global-props.c +++ b/tests/test-global-props.c @@ -27,7 +27,100 @@ #include "hw/qdev.h" #include "qom/object.h" #include "qapi/visitor.h" +#include "qom/object_interfaces.h" =20 +#define TYPE_DUMMY "qemu-dummy" + +typedef struct DummyObject DummyObject; +typedef struct DummyObjectClass DummyObjectClass; + +#define DUMMY_OBJECT(obj) \ + OBJECT_CHECK(DummyObject, (obj), TYPE_DUMMY) + +struct DummyObject { + Object parent_obj; + + char *sv; +}; + +struct DummyObjectClass { + ObjectClass parent_class; +}; + +static void dummy_set_sv(Object *obj, + const char *value, + Error **errp) +{ + DummyObject *dobj =3D DUMMY_OBJECT(obj); + + g_free(dobj->sv); + dobj->sv =3D g_strdup(value); +} + +static char *dummy_get_sv(Object *obj, + Error **errp) +{ + DummyObject *dobj =3D DUMMY_OBJECT(obj); + + return g_strdup(dobj->sv); +} + + + +static void dummy_class_init(ObjectClass *cls, void *data) +{ + object_class_property_add_str(cls, "sv", + dummy_get_sv, + dummy_set_sv, + NULL); +} + + +static void dummy_finalize(Object *obj) +{ + DummyObject *dobj =3D DUMMY_OBJECT(obj); + + g_free(dobj->sv); +} + + +static const TypeInfo dummy_info =3D { + .name =3D TYPE_DUMMY, + .parent =3D TYPE_OBJECT, + .instance_size =3D sizeof(DummyObject), + .instance_finalize =3D dummy_finalize, + .class_size =3D sizeof(DummyObjectClass), + .class_init =3D dummy_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_USER_CREATABLE }, + { } + } +}; + +static void test_global_props_uc_subprocess(void) +{ + DummyObject *d; + static GlobalProperty gp =3D { + TYPE_DUMMY, "sv", "foobar", + }; + + d =3D DUMMY_OBJECT(object_new(TYPE_DUMMY)); + g_assert_null(d->sv); + object_unref(OBJECT(d)); + + object_property_register_global(&gp); + d =3D DUMMY_OBJECT(object_new(TYPE_DUMMY)); + g_assert_cmpstr(d->sv, =3D=3D, "foobar"); + object_unref(OBJECT(d)); +} + +static void test_global_props_uc(void) +{ + g_test_trap_subprocess("/global-props/usercreatable/subprocess", 0, 0); + g_test_trap_assert_passed(); + g_test_trap_assert_stderr(""); + g_test_trap_assert_stdout(""); +} =20 #define TYPE_STATIC_PROPS "static_prop_type" #define STATIC_TYPE(obj) \ @@ -83,7 +176,8 @@ static void test_static_prop_subprocess(void) =20 static void test_static_prop(void) { - g_test_trap_subprocess("/qdev/properties/static/default/subprocess", 0= , 0); + g_test_trap_subprocess("/global-props/qdev/static/default/subprocess", + 0, 0); g_test_trap_assert_passed(); g_test_trap_assert_stderr(""); g_test_trap_assert_stdout(""); @@ -119,7 +213,7 @@ static void test_static_globalprop_subprocess(void) =20 static void test_static_globalprop(void) { - g_test_trap_subprocess("/qdev/properties/static/global/subprocess", 0,= 0); + g_test_trap_subprocess("/global-props/qdev/static/global/subprocess", = 0, 0); g_test_trap_assert_passed(); g_test_trap_assert_stderr(""); g_test_trap_assert_stdout(""); @@ -245,7 +339,8 @@ static void test_dynamic_globalprop_subprocess(void) =20 static void test_dynamic_globalprop(void) { - g_test_trap_subprocess("/qdev/properties/dynamic/global/subprocess", 0= , 0); + g_test_trap_subprocess("/global-props/qdev/dynamic/global/subprocess", + 0, 0); g_test_trap_assert_passed(); g_test_trap_assert_stderr_unmatched("*prop1*"); g_test_trap_assert_stderr_unmatched("*prop2*"); @@ -290,7 +385,8 @@ static void test_dynamic_globalprop_nouser_subprocess(v= oid) =20 static void test_dynamic_globalprop_nouser(void) { - g_test_trap_subprocess("/qdev/properties/dynamic/global/nouser/subproc= ess", 0, 0); + g_test_trap_subprocess("/global-props/qdev" + "/dynamic/global/nouser/subprocess", 0, 0); g_test_trap_assert_passed(); g_test_trap_assert_stderr(""); g_test_trap_assert_stdout(""); @@ -323,6 +419,7 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); =20 module_call_init(MODULE_INIT_QOM); + type_register_static(&dummy_info); type_register_static(&static_prop_type); type_register_static(&subclass_type); type_register_static(&dynamic_prop_type); @@ -330,27 +427,32 @@ int main(int argc, char **argv) type_register_static(&nohotplug_type); type_register_static(&nondevice_type); =20 - g_test_add_func("/qdev/properties/static/default/subprocess", + g_test_add_func("/global-props/usercreatable/subprocess", + test_global_props_uc_subprocess); + g_test_add_func("/global-props/usercreatable", + test_global_props_uc); + + g_test_add_func("/global-props/qdev/static/default/subprocess", test_static_prop_subprocess); - g_test_add_func("/qdev/properties/static/default", + g_test_add_func("/global-props/qdev/static/default", test_static_prop); =20 - g_test_add_func("/qdev/properties/static/global/subprocess", + g_test_add_func("/global-props/qdev/static/global/subprocess", test_static_globalprop_subprocess); - g_test_add_func("/qdev/properties/static/global", + g_test_add_func("/global-props/qdev/static/global", test_static_globalprop); =20 - g_test_add_func("/qdev/properties/dynamic/global/subprocess", + g_test_add_func("/global-props/qdev/dynamic/global/subprocess", test_dynamic_globalprop_subprocess); - g_test_add_func("/qdev/properties/dynamic/global", + g_test_add_func("/global-props/qdev/dynamic/global", test_dynamic_globalprop); =20 - g_test_add_func("/qdev/properties/dynamic/global/nouser/subprocess", + g_test_add_func("/global-props/qdev/dynamic/global/nouser/subprocess", test_dynamic_globalprop_nouser_subprocess); - g_test_add_func("/qdev/properties/dynamic/global/nouser", + g_test_add_func("/global-props/qdev/dynamic/global/nouser", test_dynamic_globalprop_nouser); =20 - g_test_add_func("/qdev/properties/global/subclass", + g_test_add_func("/global-props/qdev/global/subclass", test_subclass_global_props); =20 g_test_run(); diff --git a/tests/Makefile.include b/tests/Makefile.include index 87c81d1dcc..080b218fd3 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -128,7 +128,7 @@ check-unit-y +=3D tests/test-qht-par$(EXESUF) gcov-files-test-qht-par-y =3D util/qht.c check-unit-y +=3D tests/test-bitops$(EXESUF) check-unit-y +=3D tests/test-bitcnt$(EXESUF) -check-unit-y +=3D tests/test-qdev-global-props$(EXESUF) +check-unit-y +=3D tests/test-global-props$(EXESUF) check-unit-y +=3D tests/check-qom-interface$(EXESUF) gcov-files-check-qom-interface-y =3D qom/object.c check-unit-y +=3D tests/check-qom-proplist$(EXESUF) @@ -657,7 +657,7 @@ tests/qht-bench$(EXESUF): tests/qht-bench.o $(test-util= -obj-y) tests/test-bufferiszero$(EXESUF): tests/test-bufferiszero.o $(test-util-ob= j-y) tests/atomic_add-bench$(EXESUF): tests/atomic_add-bench.o $(test-util-obj-= y) =20 -tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ +tests/test-global-props$(EXESUF): tests/test-global-props.o \ hw/core/qdev.o hw/core/qdev-properties.o hw/core/hotplug.o\ hw/core/bus.o \ hw/core/irq.o \ --=20 2.19.0.rc1 From nobody Wed Nov 5 18:23:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153675731394322.235535305217013; Wed, 12 Sep 2018 06:01:53 -0700 (PDT) Received: from localhost ([::1]:36179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04mF-00036X-To for importer@patchew.org; Wed, 12 Sep 2018 09:01:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04hB-0007r3-9J for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g04hA-000085-C8 for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:37 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38838 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g04hA-00007W-2F for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:36 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F64840216EB; Wed, 12 Sep 2018 12:56:35 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69293202706C; Wed, 12 Sep 2018 12:56:34 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 12 Sep 2018 16:55:30 +0400 Message-Id: <20180912125531.32131-9-marcandre.lureau@redhat.com> In-Reply-To: <20180912125531.32131-1-marcandre.lureau@redhat.com> References: <20180912125531.32131-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 12 Sep 2018 12:56:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 12 Sep 2018 12:56:35 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 8/9] hw/i386: add pc-i440fx-3.1 & pc-q35-3.1 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: Eduardo Habkost , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Igor Mammedov , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The following patch is going to add compatiblity parameters. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michael S. Tsirkin --- include/hw/i386/pc.h | 5 ++++- hw/i386/pc_piix.c | 15 ++++++++++++--- hw/i386/pc_q35.c | 13 +++++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 6894f37df1..09b0365a8e 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -294,7 +294,10 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t); int e820_get_num_entries(void); bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); =20 -#define PC_COMPAT_2_12 \ +#define PC_COMPAT_3_0 \ + HW_COMPAT_3_0 + +#define PC_COMPAT_2_12 \ HW_COMPAT_2_12 \ {\ .driver =3D TYPE_X86_CPU,\ diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index dc09466b3e..7092d6d13f 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -428,21 +428,30 @@ static void pc_i440fx_machine_options(MachineClass *m) machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE); } =20 -static void pc_i440fx_3_0_machine_options(MachineClass *m) +static void pc_i440fx_3_1_machine_options(MachineClass *m) { pc_i440fx_machine_options(m); m->alias =3D "pc"; m->is_default =3D 1; } =20 +DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL, + pc_i440fx_3_1_machine_options); + +static void pc_i440fx_3_0_machine_options(MachineClass *m) +{ + pc_i440fx_3_1_machine_options(m); + m->is_default =3D 0; + m->alias =3D NULL; + SET_MACHINE_COMPAT(m, PC_COMPAT_3_0); +} + DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL, pc_i440fx_3_0_machine_options); =20 static void pc_i440fx_2_12_machine_options(MachineClass *m) { pc_i440fx_3_0_machine_options(m); - m->is_default =3D 0; - m->alias =3D NULL; SET_MACHINE_COMPAT(m, PC_COMPAT_2_12); } =20 diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 532241e3f8..4702bb13c4 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -311,19 +311,28 @@ static void pc_q35_machine_options(MachineClass *m) m->max_cpus =3D 288; } =20 -static void pc_q35_3_0_machine_options(MachineClass *m) +static void pc_q35_3_1_machine_options(MachineClass *m) { pc_q35_machine_options(m); m->alias =3D "q35"; } =20 +DEFINE_Q35_MACHINE(v3_1, "pc-q35-3.1", NULL, + pc_q35_3_1_machine_options); + +static void pc_q35_3_0_machine_options(MachineClass *m) +{ + pc_q35_3_1_machine_options(m); + m->alias =3D NULL; + SET_MACHINE_COMPAT(m, PC_COMPAT_3_0); +} + DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL, pc_q35_3_0_machine_options); =20 static void pc_q35_2_12_machine_options(MachineClass *m) { pc_q35_3_0_machine_options(m); - m->alias =3D NULL; SET_MACHINE_COMPAT(m, PC_COMPAT_2_12); } =20 --=20 2.19.0.rc1 From nobody Wed Nov 5 18:23:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536757441806759.8952060222522; Wed, 12 Sep 2018 06:04:01 -0700 (PDT) Received: from localhost ([::1]:36185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04oK-0004OG-EM for importer@patchew.org; Wed, 12 Sep 2018 09:04:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04hL-00081R-Gz for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g04hI-0000Gm-BI for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:47 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49734 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g04hI-0000Fy-4U for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:56:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B62644023840; Wed, 12 Sep 2018 12:56:43 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E8C263F38; Wed, 12 Sep 2018 12:56:38 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 12 Sep 2018 16:55:31 +0400 Message-Id: <20180912125531.32131-10-marcandre.lureau@redhat.com> In-Reply-To: <20180912125531.32131-1-marcandre.lureau@redhat.com> References: <20180912125531.32131-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 12 Sep 2018 12:56:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 12 Sep 2018 12:56:43 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 9/9] hostmem-ram: use whole path for memory region name with >= 3.1 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: Eduardo Habkost , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Igor Mammedov , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" hostmem-file and hostmem-memfd use the whole object path for the memory region name, but hostname-ram uses only the path component (the basename): qemu -m 1024 -object memory-backend-ram,id=3Dmem,size=3D1G -numa node,memde= v=3Dmem -monitor stdio (qemu) info ramblock Block Name PSize Offset Used = Total mem 4 KiB 0x0000000000000000 0x0000000040000000 0x= 0000000040000000 qemu -m 1024 -object memory-backend-file,id=3Dmem,size=3D1G,mem-path=3D/tmp= /foo -numa node,memdev=3Dmem -monitor stdio (qemu) info ramblock Block Name PSize Offset Used = Total /objects/mem 4 KiB 0x0000000000000000 0x0000000040000000 0x= 0000000040000000 qemu -m 1024 -object memory-backend-memfd,id=3Dmem,size=3D1G -numa node,mem= dev=3Dmem -monitor stdio (qemu) info ramblock Block Name PSize Offset Used = Total /objects/mem 4 KiB 0x0000000000000000 0x0000000040000000 0x= 0000000040000000 Use the whole path name with >=3D 3.1. Having a consistent naming allow to migrate to different hostmem backends. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Dr. David Alan Gilbert --- include/hw/compat.h | 6 +++++- backends/hostmem-ram.c | 47 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/include/hw/compat.h b/include/hw/compat.h index 6f4d5fc647..8ce7a7057b 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -2,7 +2,11 @@ #define HW_COMPAT_H =20 #define HW_COMPAT_3_0 \ - /* empty */ + {\ + .driver =3D "memory-backend-ram",\ + .property =3D "x-component-name",\ + .value =3D "true",\ + }, =20 #define HW_COMPAT_2_12 \ {\ diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c index 7ddd08d370..a9eb99cf1b 100644 --- a/backends/hostmem-ram.c +++ b/backends/hostmem-ram.c @@ -16,21 +16,56 @@ =20 #define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram" =20 +typedef struct RamMemoryBackend { + HostMemoryBackend parent; + + bool component_name; +} RamMemoryBackend; + +#define RAM_BACKEND(obj) \ + OBJECT_CHECK(RamMemoryBackend, (obj), TYPE_MEMORY_BACKEND_RAM) + +static char * +ram_backend_get_name(RamMemoryBackend *self) +{ + /* < 3.1 use the component as memory region name */ + if (self->component_name) { + return object_get_canonical_path_component(OBJECT(self)); + } + + return object_get_canonical_path(OBJECT(self)); +} =20 static void ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { - char *path; + char *name; =20 if (!backend->size) { error_setg(errp, "can't create backend with size 0"); return; } =20 - path =3D object_get_canonical_path_component(OBJECT(backend)); - memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend),= path, + name =3D ram_backend_get_name(RAM_BACKEND(backend)); + memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend),= name, backend->size, backend->share, errp); - g_free(path); + g_free(name); +} + +static bool +ram_backend_get_component_name(Object *obj, Error **errp) +{ + RamMemoryBackend *self =3D RAM_BACKEND(obj); + + return self->component_name; +} + +static void +ram_backend_set_component_name(Object *obj, bool value, Error **errp) +{ + RamMemoryBackend *self =3D RAM_BACKEND(obj); + + self->component_name =3D value; } =20 static void @@ -39,11 +74,15 @@ ram_backend_class_init(ObjectClass *oc, void *data) HostMemoryBackendClass *bc =3D MEMORY_BACKEND_CLASS(oc); =20 bc->alloc =3D ram_backend_memory_alloc; + object_class_property_add_bool(oc, "x-component-name", + ram_backend_get_component_name, + ram_backend_set_component_name, &error_abort); } =20 static const TypeInfo ram_backend_info =3D { .name =3D TYPE_MEMORY_BACKEND_RAM, .parent =3D TYPE_MEMORY_BACKEND, + .instance_size =3D sizeof(RamMemoryBackend), .class_init =3D ram_backend_class_init, }; =20 --=20 2.19.0.rc1