From nobody Tue Feb 10 03:40:10 2026 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 1543311841279673.0968523788647; Tue, 27 Nov 2018 01:44:01 -0800 (PST) Received: from localhost ([::1]:40928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRZuR-0008Sf-T6 for importer@patchew.org; Tue, 27 Nov 2018 04:43:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRZik-0005Ac-T9 for qemu-devel@nongnu.org; Tue, 27 Nov 2018 04:31:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRZij-0006Xp-Qi for qemu-devel@nongnu.org; Tue, 27 Nov 2018 04:31:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35008) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRZij-0006XJ-HU for qemu-devel@nongnu.org; Tue, 27 Nov 2018 04:31:53 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B9099C0C8B9C; Tue, 27 Nov 2018 09:31:52 +0000 (UTC) Received: from localhost (ovpn-112-28.ams2.redhat.com [10.36.112.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A0AB5C3FA; Tue, 27 Nov 2018 09:31:50 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 13:27:58 +0400 Message-Id: <20181127092801.21777-26-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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 27 Nov 2018 09:31:52 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 25/28] machine: add compat-props interface 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, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's make compatiblity properties an interface, so that objects other than QDev can benefit from having machine compatiblity properties. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/boards.h | 2 ++ hw/core/compat-props.c | 55 ++++++++++++++++++++++++++++++++++++++++++ hw/core/qdev.c | 24 +++--------------- MAINTAINERS | 1 + hw/core/Makefile.objs | 1 + tests/Makefile.include | 1 + 6 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 hw/core/compat-props.c diff --git a/include/hw/boards.h b/include/hw/boards.h index f743d9d4a4..77d1fc1bef 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -9,6 +9,8 @@ #include "qom/object.h" #include "qom/cpu.h" =20 +#define TYPE_COMPAT_PROPS "compat-props" + /** * memory_region_allocate_system_memory - Allocate a board's main memory * @mr: the #MemoryRegion to be initialized diff --git a/hw/core/compat-props.c b/hw/core/compat-props.c new file mode 100644 index 0000000000..538378e71f --- /dev/null +++ b/hw/core/compat-props.c @@ -0,0 +1,55 @@ +/* + * QEMU Machine compat properties + * + * Copyright (C) 2018 Red Hat Inc + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/boards.h" +#include "qapi/error.h" + +typedef struct CompatProps CompatProps; + +typedef struct CompatPropsClass { + InterfaceClass parent_class; +} CompatPropsClass; + +static const GPtrArray *ac_compat_props; +static const GPtrArray *mc_compat_props; + +void accel_register_compat_props(const GPtrArray *props) +{ + ac_compat_props =3D props; +} + +void machine_register_compat_props(const GPtrArray *props) +{ + mc_compat_props =3D props; +} + +static void compat_props_post_init(Object *obj) +{ + if (ac_compat_props) { + object_apply_global_props(obj, ac_compat_props, &error_abort); + } + if (mc_compat_props) { + object_apply_global_props(obj, mc_compat_props, &error_abort); + } +} + +static void compat_props_register_types(void) +{ + static const TypeInfo cp_interface_info =3D { + .name =3D TYPE_COMPAT_PROPS, + .parent =3D TYPE_INTERFACE, + .class_size =3D sizeof(CompatPropsClass), + .instance_post_init =3D compat_props_post_init, + }; + + type_register_static(&cp_interface_info); +} + +type_init(compat_props_register_types) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 3b31b2c025..b0ee05f837 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -970,28 +970,8 @@ static void device_initfn(Object *obj) QLIST_INIT(&dev->gpios); } =20 -static const GPtrArray *ac_compat_props; -static const GPtrArray *mc_compat_props; - -void accel_register_compat_props(const GPtrArray *props) -{ - ac_compat_props =3D props; -} - -void machine_register_compat_props(const GPtrArray *props) -{ - mc_compat_props =3D props; -} - static void device_post_init(Object *obj) { - if (ac_compat_props) { - object_apply_global_props(obj, ac_compat_props, &error_abort); - } - if (mc_compat_props) { - object_apply_global_props(obj, mc_compat_props, &error_abort); - } - qdev_prop_set_globals(DEVICE(obj)); } =20 @@ -1124,6 +1104,10 @@ static const TypeInfo device_type_info =3D { .class_init =3D device_class_init, .abstract =3D true, .class_size =3D sizeof(DeviceClass), + .interfaces =3D (InterfaceInfo[]) { + { TYPE_COMPAT_PROPS }, + { } + } }; =20 static void qdev_register_types(void) diff --git a/MAINTAINERS b/MAINTAINERS index 9410bbb7cf..adff09627f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1145,6 +1145,7 @@ Machine core M: Eduardo Habkost M: Marcel Apfelbaum S: Supported +F: hw/core/compat-props.c F: hw/core/machine.c F: hw/core/null-machine.c F: include/hw/boards.h diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs index a799c83815..f15b3c970a 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -1,5 +1,6 @@ # core qdev-related obj files, also used by *-user: common-obj-y +=3D qdev.o qdev-properties.o +common-obj-y +=3D compat-props.o common-obj-y +=3D bus.o reset.o common-obj-$(CONFIG_SOFTMMU) +=3D qdev-fw.o common-obj-$(CONFIG_SOFTMMU) +=3D fw-path-provider.o diff --git a/tests/Makefile.include b/tests/Makefile.include index fb0b449c02..fc74358c0a 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -567,6 +567,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-= global-props.o \ hw/core/irq.o \ hw/core/fw-path-provider.o \ hw/core/reset.o \ + hw/core/compat-props.o \ $(test-qapi-obj-y) tests/test-vmstate$(EXESUF): tests/test-vmstate.o \ migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \ --=20 2.20.0.rc1