From nobody Thu Nov 6 12:31:03 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 1540912820949908.337443488889; Tue, 30 Oct 2018 08:20:20 -0700 (PDT) Received: from localhost ([::1]:53843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVoZ-0000as-Tg for importer@patchew.org; Tue, 30 Oct 2018 11:20:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVcd-0005tr-HG for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:08:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHVcZ-0006Bs-B1 for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:07:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27880) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHVcX-00058I-Jy for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:07:54 -0400 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 C54FD3164691; Tue, 30 Oct 2018 15:07:33 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCAAE6767F; Tue, 30 Oct 2018 15:07:31 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 19:04:50 +0400 Message-Id: <20181030150453.9344-8-marcandre.lureau@redhat.com> In-Reply-To: <20181030150453.9344-1-marcandre.lureau@redhat.com> References: <20181030150453.9344-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.41]); Tue, 30 Oct 2018 15:07:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v2 07/10] qom/object: add set_globals flags 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 , Amit Shah , "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" Content-Type: text/plain; charset="utf-8" Guard against calling object_property_set_globals() for all objects, check that the class flag set_globals is set before. No need to guard in object_property_set_globals() anymore. Only QDev & user-creatable objects have set_globals set at this point. Suggested-by: Igor Mammedov Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qom/object.h | 1 + hw/core/qdev.c | 1 + qom/globals.c | 5 ----- qom/object.c | 5 ++++- qom/object_interfaces.c | 7 +++++++ 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index f0b0bf39cc..205099bc7e 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -400,6 +400,7 @@ struct ObjectClass ObjectUnparent *unparent; =20 GHashTable *properties; + bool set_globals; }; =20 /** diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 6a25fa027c..78ce9a3095 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1042,6 +1042,7 @@ static void device_class_init(ObjectClass *class, voi= d *data) */ dc->hotpluggable =3D true; dc->user_creatable =3D true; + class->set_globals =3D true; } =20 void device_class_set_parent_reset(DeviceClass *dc, diff --git a/qom/globals.c b/qom/globals.c index 8664baebe0..e94e6f2bf9 100644 --- a/qom/globals.c +++ b/qom/globals.c @@ -18,11 +18,6 @@ void object_property_set_globals(Object *obj) GList *l; DeviceState *dev =3D (DeviceState *)object_dynamic_cast(obj, TYPE_DEVI= CE); =20 - if (!dev && !IS_USER_CREATABLE(obj)) { - /* only TYPE_DEVICE and TYPE_USER_CREATABLE support globals */ - return; - } - for (l =3D global_props; l; l =3D l->next) { GlobalProperty *prop =3D l->data; Error *err =3D NULL; diff --git a/qom/object.c b/qom/object.c index 7300878125..c18e630159 100644 --- a/qom/object.c +++ b/qom/object.c @@ -259,6 +259,7 @@ static void type_initialize_interface(TypeImpl *ti, Typ= eImpl *interface_type, =20 ti->class->interfaces =3D g_slist_append(ti->class->interfaces, iface_impl->class); + ti->class->set_globals |=3D iface_impl->class->set_globals; } =20 static void object_property_free(gpointer data) @@ -391,7 +392,9 @@ static void object_initialize_with_type(void *data, siz= e_t size, TypeImpl *type) NULL, object_property_free); object_init_with_type(obj, type); object_post_init_with_type(obj, type); - object_property_set_globals(obj); + if (object_get_class(obj)->set_globals) { + object_property_set_globals(obj); + } } =20 void object_initialize(void *data, size_t size, const char *typename) diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index db85d1eb75..67886845e7 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -184,12 +184,19 @@ void user_creatable_cleanup(void) object_unparent(object_get_objects_root()); } =20 +static void user_creatable_class_init(ObjectClass *klass, void *data) +{ + klass->set_globals =3D true; +} + + static void register_types(void) { static const TypeInfo uc_interface_info =3D { .name =3D TYPE_USER_CREATABLE, .parent =3D TYPE_INTERFACE, .class_size =3D sizeof(UserCreatableClass), + .class_init =3D user_creatable_class_init, }; =20 type_register_static(&uc_interface_info); --=20 2.19.0.271.gfe8321ec05