From patchwork Tue Oct 30 15:04:44 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: 990927 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 42kwHC4k8nz9s9h for ; Wed, 31 Oct 2018 02:24:07 +1100 (AEDT) Received: from localhost ([::1]:53870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVsD-0003LJ-5W for incoming@patchwork.ozlabs.org; Tue, 30 Oct 2018 11:24:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVao-0003te-DD for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHVaj-0000WT-Rw for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57302) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHVaj-0007rw-E1 for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:01 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C2E581108; Tue, 30 Oct 2018 15:05:38 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23AE92AAA8; Tue, 30 Oct 2018 15:05:01 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 19:04:44 +0400 Message-Id: <20181030150453.9344-2-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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 30 Oct 2018 15:05:38 +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] [PATCH v2 01/10] qom: make user_creatable_complete() specific to UserCreatable 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-?= =?utf-8?q?Andr=C3=A9_Lureau?= , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Andreas_F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Instead of accepting any Object*, change user_creatable_complete() to require a UserCreatable*. Modify the callers to pass the appropriate argument, removing redundant dynamic cast checks in object creation. Signed-off-by: Marc-André Lureau Reviewed-by: Igor Mammedov --- include/qom/object_interfaces.h | 4 ++-- hw/misc/ivshmem.c | 2 +- hw/virtio/virtio-rng.c | 2 +- qom/object.c | 12 ++++++++---- qom/object_interfaces.c | 14 +++----------- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h index 4d513fb329..7450cff908 100644 --- a/include/qom/object_interfaces.h +++ b/include/qom/object_interfaces.h @@ -55,14 +55,14 @@ typedef struct UserCreatableClass { /** * user_creatable_complete: - * @obj: the object whose complete() method is called if defined + * @uc: the user-creatable object whose complete() method is called if defined * @errp: if an error occurs, a pointer to an area to store the error * * Wrapper to call complete() method if one of types it's inherited * from implements USER_CREATABLE interface, otherwise the call does * nothing. */ -void user_creatable_complete(Object *obj, Error **errp); +void user_creatable_complete(UserCreatable *uc, Error **errp); /** * user_creatable_can_be_deleted: diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index f88910e55c..478f41044c 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -1279,7 +1279,7 @@ static void desugar_shm(IVShmemState *s) object_property_set_bool(obj, true, "share", &error_abort); object_property_add_child(OBJECT(s), "internal-shm-backend", obj, &error_abort); - user_creatable_complete(obj, &error_abort); + user_creatable_complete(USER_CREATABLE(obj), &error_abort); s->hostmem = MEMORY_BACKEND(obj); } diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index 855f1b41d1..30493a2586 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -191,7 +191,7 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp) if (vrng->conf.rng == NULL) { vrng->conf.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM)); - user_creatable_complete(OBJECT(vrng->conf.default_backend), + user_creatable_complete(USER_CREATABLE(vrng->conf.default_backend), &local_err); if (local_err) { error_propagate(errp, local_err); diff --git a/qom/object.c b/qom/object.c index 547dcf97c3..eb770dbf7f 100644 --- a/qom/object.c +++ b/qom/object.c @@ -417,6 +417,7 @@ void object_initialize_childv(Object *parentobj, const char *propname, { Error *local_err = NULL; Object *obj; + UserCreatable *uc; object_initialize(childobj, size, type); obj = OBJECT(childobj); @@ -431,8 +432,9 @@ void object_initialize_childv(Object *parentobj, const char *propname, goto out; } - if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) { - user_creatable_complete(obj, &local_err); + uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE); + if (uc) { + user_creatable_complete(uc, &local_err); if (local_err) { object_unparent(obj); goto out; @@ -590,6 +592,7 @@ Object *object_new_with_propv(const char *typename, Object *obj; ObjectClass *klass; Error *local_err = NULL; + UserCreatable *uc; klass = object_class_by_name(typename); if (!klass) { @@ -612,8 +615,9 @@ Object *object_new_with_propv(const char *typename, goto error; } - if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) { - user_creatable_complete(obj, &local_err); + uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE); + if (uc) { + user_creatable_complete(uc, &local_err); if (local_err) { object_unparent(obj); goto error; diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 97b79b48bb..db85d1eb75 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -8,18 +8,10 @@ #include "qapi/opts-visitor.h" #include "qemu/config-file.h" -void user_creatable_complete(Object *obj, Error **errp) +void user_creatable_complete(UserCreatable *uc, Error **errp) { + UserCreatableClass *ucc = USER_CREATABLE_GET_CLASS(uc); - UserCreatableClass *ucc; - UserCreatable *uc = - (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE); - - if (!uc) { - return; - } - - ucc = USER_CREATABLE_GET_CLASS(uc); if (ucc->complete) { ucc->complete(uc, errp); } @@ -89,7 +81,7 @@ Object *user_creatable_add_type(const char *type, const char *id, goto out; } - user_creatable_complete(obj, &local_err); + user_creatable_complete(USER_CREATABLE(obj), &local_err); if (local_err) { object_property_del(object_get_objects_root(), id, &error_abort); From patchwork Tue Oct 30 15:04: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: 990912 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 42kvy22y4jz9rxp for ; Wed, 31 Oct 2018 02:09:14 +1100 (AEDT) Received: from localhost ([::1]:53775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVdo-0006Yb-24 for incoming@patchwork.ozlabs.org; Tue, 30 Oct 2018 11:09:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVaq-0003wL-TE for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHVal-0000aq-0V for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37318) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHVak-00007d-IZ for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:02 -0400 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 154BA3C080; Tue, 30 Oct 2018 15:05:54 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 354C586FD7; Tue, 30 Oct 2018 15:05:41 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 19:04:45 +0400 Message-Id: <20181030150453.9344-3-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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 30 Oct 2018 15:05:54 +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] [PATCH v2 02/10] 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 , Amit Shah , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?utf-8?q?Marc-?= =?utf-8?q?Andr=C3=A9_Lureau?= , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Andreas_F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson 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; From patchwork Tue Oct 30 15:04:46 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: 990929 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 42kwKd4Qj9z9s2P for ; Wed, 31 Oct 2018 02:26:13 +1100 (AEDT) Received: from localhost ([::1]:53884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVuF-0005YB-3u for incoming@patchwork.ozlabs.org; Tue, 30 Oct 2018 11:26:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVap-0003vF-TK for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHVao-0000rN-Ne for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51862) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHVao-0000oX-DR for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9940C308A96E; Tue, 30 Oct 2018 15:06:05 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 137CF610C7; Tue, 30 Oct 2018 15:05:57 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 19:04:46 +0400 Message-Id: <20181030150453.9344-4-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.12 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:06:05 +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] [PATCH v2 03/10] 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 , Amit Shah , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?utf-8?q?Marc-?= =?utf-8?q?Andr=C3=A9_Lureau?= , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Andreas_F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The function is only used by a test, move it there. Signed-off-by: Marc-André Lureau Reviewed-by: Eduardo Habkost --- 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 *name, int value); void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value); 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 *dev, 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 = g_list_append(global_props, prop); } -void qdev_prop_register_global_list(GlobalProperty *props) -{ - int i; - - for (i = 0; props[i].driver != 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..f6bcc301c4 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(""); } +static void register_global_properties(GlobalProperty *props) +{ + int i; + + for (i = 0; props[i].driver != 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) {} }; - qdev_prop_register_global_list(props); + register_global_properties(props); mt = 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; - qdev_prop_register_global_list(props); + register_global_properties(props); mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); qdev_init_nofail(DEVICE(mt)); @@ -261,7 +271,7 @@ static void test_dynamic_globalprop_nouser_subprocess(void) }; int all_used; - qdev_prop_register_global_list(props); + register_global_properties(props); mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); qdev_init_nofail(DEVICE(mt)); @@ -299,7 +309,7 @@ static void test_subclass_global_props(void) {} }; - qdev_prop_register_global_list(props); + register_global_properties(props); mt = STATIC_TYPE(object_new(TYPE_SUBCLASS)); qdev_init_nofail(DEVICE(mt)); From patchwork Tue Oct 30 15:04:47 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: 990913 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 42kvzJ0Q3wz9rxp for ; Wed, 31 Oct 2018 02:10:19 +1100 (AEDT) Received: from localhost ([::1]:53778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVeq-0007ME-F0 for incoming@patchwork.ozlabs.org; Tue, 30 Oct 2018 11:10:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVbM-0004Hl-DP for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHVbJ-0002Pg-OH for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37694) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHVbJ-0001up-CA for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:37 -0400 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 A26773C087; Tue, 30 Oct 2018 15:06:26 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7913D61D0E; Tue, 30 Oct 2018 15:06:09 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 19:04:47 +0400 Message-Id: <20181030150453.9344-5-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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 30 Oct 2018 15:06:26 +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] [PATCH v2 04/10] 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 , Amit Shah , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?utf-8?q?Marc-?= =?utf-8?q?Andr=C3=A9_Lureau?= , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Andreas_F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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é 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 | 6 +-- qom/Makefile.objs | 2 +- 14 files changed, 121 insertions(+), 103 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 a24d0dd566..54ed5761ca 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -247,26 +247,6 @@ struct PropertyInfo { ObjectPropertyRelease *release; }; -/** - * 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. ***/ 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" /*** qdev-properties.c ***/ @@ -248,9 +249,6 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value); /* FIXME: Remove opaque pointer properties. */ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value); -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 *dev, Property *prop, const char *value); 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 = &error_abort; - qdev_prop_register_global(prop); + object_property_register_global(prop); } } diff --git a/hw/core/machine.c b/hw/core/machine.c index da50ad6de7..c067f4bfad 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -858,7 +858,7 @@ void machine_register_compat_props(MachineState *machine) p = g_array_index(mc->compat_props, GlobalProperty *, i); /* Machine compat_props must never cause errors: */ p->errp = &error_abort; - qdev_prop_register_global(p); + object_property_register_global(p); } } 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 = value; } -static GList *global_props; - -void qdev_prop_register_global(GlobalProperty *prop) -{ - global_props = g_list_append(global_props, prop); -} - -int qdev_prop_check_globals(void) -{ - GList *l; - int ret = 0; - - for (l = global_props; l; l = l->next) { - GlobalProperty *prop = l->data; - ObjectClass *oc; - DeviceClass *dc; - if (prop->used) { - continue; - } - if (!prop->user_provided) { - continue; - } - oc = object_class_by_name(prop->driver); - oc = object_class_dynamic_cast(oc, TYPE_DEVICE); - if (!oc) { - warn_report("global %s.%s has invalid class name", - prop->driver, prop->property); - ret = 1; - continue; - } - dc = DEVICE_CLASS(oc); - if (!dc->hotpluggable && !prop->used) { - warn_report("global %s.%s=%s not used", - prop->driver, prop->property, prop->value); - ret = 1; - continue; - } - } - return ret; -} - -void qdev_prop_set_globals(DeviceState *dev) -{ - GList *l; - - for (l = global_props; l; l = l->next) { - GlobalProperty *prop = l->data; - Error *err = NULL; - - if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) { - continue; - } - prop->used = true; - object_property_parse(OBJECT(dev), prop->value, prop->property, &err); - if (err != NULL) { - error_prepend(&err, "can't apply global %s.%s=%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 --- */ static void get_size(Object *obj, Visitor *v, const char *name, void *opaque, diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 6b3cc55b27..09a2c4df62 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -972,7 +972,7 @@ static void device_initfn(Object *obj) static void device_post_init(Object *obj) { - qdev_prop_set_globals(DEVICE(obj)); + object_property_set_globals(obj); } /* Unlink device from bus and free the structure. */ diff --git a/qom/cpu.c b/qom/cpu.c index 9ad1372d57..b0d9944039 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -313,7 +313,7 @@ static void cpu_common_parse_features(const char *typename, char *features, prop->property = g_strdup(featurestr); prop->value = g_strdup(val); prop->errp = &error_fatal; - qdev_prop_register_global(prop); + object_property_register_global(prop); } else { error_setg(errp, "Expected key=value 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 = g_list_append(global_props, prop); +} + +void object_property_set_globals(Object *obj) +{ + DeviceState *dev = DEVICE(obj); + GList *l; + + for (l = global_props; l; l = l->next) { + GlobalProperty *prop = l->data; + Error *err = NULL; + + if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) { + continue; + } + prop->used = true; + object_property_parse(OBJECT(dev), prop->value, prop->property, &err); + if (err != NULL) { + error_prepend(&err, "can't apply global %s.%s=%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 = 0; + + for (l = global_props; l; l = l->next) { + GlobalProperty *prop = l->data; + ObjectClass *oc; + DeviceClass *dc; + if (prop->used) { + continue; + } + if (!prop->user_provided) { + continue; + } + oc = object_class_by_name(prop->driver); + oc = object_class_dynamic_cast(oc, TYPE_DEVICE); + if (!oc) { + warn_report("global %s.%s has invalid class name", + prop->driver, prop->property); + ret = 1; + continue; + } + dc = DEVICE_CLASS(oc); + if (!dc->hotpluggable && !prop->used) { + warn_report("global %s.%s=%s not used", + prop->driver, prop->property, prop->value); + ret = 1; + continue; + } + } + return ret; +} diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 1469a1be01..f17a228459 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3414,7 +3414,7 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features, prop->property = g_strdup(name); prop->value = g_strdup(val); prop->errp = &error_fatal; - qdev_prop_register_global(prop); + object_property_register_global(prop); } 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 = g_strdup(name); prop->value = g_strdup(val); prop->errp = &error_fatal; - qdev_prop_register_global(prop); + object_property_register_global(prop); } /* Parse "+feature,-feature,feature=foo" CPU feature string */ diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c index f6bcc301c4..08e7f5c8e5 100644 --- a/tests/test-qdev-global-props.c +++ b/tests/test-qdev-global-props.c @@ -94,7 +94,7 @@ static void register_global_properties(GlobalProperty *props) int i; for (i = 0; props[i].driver != NULL; i++) { - qdev_prop_register_global(props + i); + object_property_register_global(props + i); } } @@ -233,7 +233,7 @@ static void test_dynamic_globalprop_subprocess(void) g_assert_cmpuint(mt->prop1, ==, 101); g_assert_cmpuint(mt->prop2, ==, 102); - all_used = qdev_prop_check_globals(); + all_used = object_property_check_globals(); g_assert_cmpuint(all_used, ==, 1); g_assert(props[0].used); g_assert(props[1].used); @@ -278,7 +278,7 @@ static void test_dynamic_globalprop_nouser_subprocess(void) g_assert_cmpuint(mt->prop1, ==, 101); g_assert_cmpuint(mt->prop2, ==, 102); - all_used = qdev_prop_check_globals(); + all_used = object_property_check_globals(); g_assert_cmpuint(all_used, ==, 0); g_assert(props[0].used); g_assert(props[1].used); diff --git a/vl.c b/vl.c index 1fcacc5caa..1e543a1baf 100644 --- a/vl.c +++ b/vl.c @@ -926,7 +926,7 @@ static void configure_rtc(QemuOpts *opts) .value = "slew", }; - qdev_prop_register_global(&slew_lost_ticks); + object_property_register_global(&slew_lost_ticks); } else if (!strcmp(value, "none")) { /* discard is default */ } else { @@ -2922,7 +2922,7 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) g->value = qemu_opt_get(opts, "value"); g->user_provided = true; g->errp = &error_fatal; - qdev_prop_register_global(g); + object_property_register_global(g); return 0; } @@ -4604,7 +4604,7 @@ int main(int argc, char **argv, char **envp) replay_vmstate_init(); } - 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 = object.o container.o qom-qobject.o -qom-obj-y += object_interfaces.o +qom-obj-y += object_interfaces.o globals.o common-obj-y = cpu.o From patchwork Tue Oct 30 15:04:48 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: 990916 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 42kw3d4Mq4z9s9G for ; Wed, 31 Oct 2018 02:14:05 +1100 (AEDT) Received: from localhost ([::1]:53811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHViU-00030V-Jl for incoming@patchwork.ozlabs.org; Tue, 30 Oct 2018 11:14:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVbX-0004Sh-Mg for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHVbS-0002pE-Bd for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57324) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHVbR-0002dc-Sh for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:06:46 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5053B3082B07; Tue, 30 Oct 2018 15:06:42 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 861811054FDF; Tue, 30 Oct 2018 15:06:30 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 19:04:48 +0400 Message-Id: <20181030150453.9344-6-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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 30 Oct 2018 15:06:42 +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] [PATCH v2 05/10] 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 , Amit Shah , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?utf-8?q?Marc-?= =?utf-8?q?Andr=C3=A9_Lureau?= , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Andreas_F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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é 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 *prop) void object_property_set_globals(Object *obj) { - DeviceState *dev = DEVICE(obj); GList *l; + DeviceState *dev = (DeviceState *)object_dynamic_cast(obj, TYPE_DEVICE); + + if (!dev && !IS_USER_CREATABLE(obj)) { + /* only TYPE_DEVICE and TYPE_USER_CREATABLE support globals */ + return; + } for (l = global_props; l; l = l->next) { GlobalProperty *prop = l->data; Error *err = NULL; - if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) { + if (object_dynamic_cast(obj, prop->driver) == NULL) { continue; } prop->used = true; - object_property_parse(OBJECT(dev), prop->value, prop->property, &err); + object_property_parse(obj, prop->value, prop->property, &err); if (err != NULL) { error_prepend(&err, "can't apply global %s.%s=%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 = object_class_by_name(prop->driver); - oc = object_class_dynamic_cast(oc, TYPE_DEVICE); - if (!oc) { + dc = (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 = 1; continue; } - dc = DEVICE_CLASS(oc); - if (!dc->hotpluggable && !prop->used) { + + if (dc && !dc->hotpluggable) { warn_report("global %s.%s=%s not used", prop->driver, prop->property, prop->value); ret = 1; From patchwork Tue Oct 30 15:04:49 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: 990919 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 42kw6V0BQlz9sB5 for ; Wed, 31 Oct 2018 02:16:33 +1100 (AEDT) Received: from localhost ([::1]:53827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVkt-0005EQ-3M for incoming@patchwork.ozlabs.org; Tue, 30 Oct 2018 11:16:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVcd-0005tx-HQ for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:08:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHVcZ-0006E0-OG for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:07:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59548) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHVcZ-0004vP-D7 for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:07:55 -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 3AF7EC068BD2; Tue, 30 Oct 2018 15:07:29 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AAD36091D; Tue, 30 Oct 2018 15:06:45 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 19:04:49 +0400 Message-Id: <20181030150453.9344-7-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.32]); Tue, 30 Oct 2018 15:07:29 +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] [PATCH v2 06/10] 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 , Amit Shah , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?utf-8?q?Marc-?= =?utf-8?q?Andr=C3=A9_Lureau?= , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Andreas_F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Set globals for all objects, although only TYPE_DEVICE & TYPE_USER_CREATABLE can have globals for now. Replaces the qdev post-init callback (which was the last called in the hierarchy order) by an explicit call during object creation after post-init, to maintain the call ordering. Signed-off-by: Marc-André 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 09a2c4df62..6a25fa027c 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -970,11 +970,6 @@ static void device_initfn(Object *obj) QLIST_INIT(&dev->gpios); } -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) { @@ -1098,7 +1093,6 @@ static const TypeInfo device_type_info = { .parent = TYPE_OBJECT, .instance_size = sizeof(DeviceState), .instance_init = device_initfn, - .instance_post_init = device_post_init, .instance_finalize = device_finalize, .class_base_init = device_class_base_init, .class_init = device_class_init, diff --git a/qom/object.c b/qom/object.c index eb770dbf7f..7300878125 100644 --- a/qom/object.c +++ b/qom/object.c @@ -12,6 +12,7 @@ #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" @@ -390,6 +391,7 @@ static void object_initialize_with_type(void *data, size_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); } void object_initialize(void *data, size_t size, const char *typename) From patchwork Tue Oct 30 15:04:50 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: 990920 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 42kw9j0wT4z9s9h for ; Wed, 31 Oct 2018 02:19:20 +1100 (AEDT) Received: from localhost ([::1]:53838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVna-0008Ig-5j for incoming@patchwork.ozlabs.org; Tue, 30 Oct 2018 11:19:18 -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_Lureau?= 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) 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-?= =?utf-8?q?Andr=C3=A9_Lureau?= , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Andreas_F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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é 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; GHashTable *properties; + bool set_globals; }; /** 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, void *data) */ dc->hotpluggable = true; dc->user_creatable = true; + class->set_globals = true; } 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 = (DeviceState *)object_dynamic_cast(obj, TYPE_DEVICE); - if (!dev && !IS_USER_CREATABLE(obj)) { - /* only TYPE_DEVICE and TYPE_USER_CREATABLE support globals */ - return; - } - for (l = global_props; l; l = l->next) { GlobalProperty *prop = l->data; Error *err = 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, TypeImpl *interface_type, ti->class->interfaces = g_slist_append(ti->class->interfaces, iface_impl->class); + ti->class->set_globals |= iface_impl->class->set_globals; } static void object_property_free(gpointer data) @@ -391,7 +392,9 @@ static void object_initialize_with_type(void *data, size_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); + } } 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()); } +static void user_creatable_class_init(ObjectClass *klass, void *data) +{ + klass->set_globals = true; +} + + static void register_types(void) { static const TypeInfo uc_interface_info = { .name = TYPE_USER_CREATABLE, .parent = TYPE_INTERFACE, .class_size = sizeof(UserCreatableClass), + .class_init = user_creatable_class_init, }; type_register_static(&uc_interface_info); From patchwork Tue Oct 30 15:04:51 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: 990923 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 42kwDM54fQz9s9G for ; Wed, 31 Oct 2018 02:21:39 +1100 (AEDT) Received: from localhost ([::1]:53857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVpp-0001Pw-BT for incoming@patchwork.ozlabs.org; Tue, 30 Oct 2018 11:21:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVcd-0005tw-HR for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:08:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHVca-0006HL-FQ for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:07:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32782) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHVca-0005MP-3O for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:07:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11F692D7E4; Tue, 30 Oct 2018 15:07:39 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F4A95D75C; Tue, 30 Oct 2018 15:07:37 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 19:04:51 +0400 Message-Id: <20181030150453.9344-9-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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 30 Oct 2018 15:07:39 +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] [PATCH v2 08/10] 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 , Amit Shah , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?utf-8?q?Marc-?= =?utf-8?q?Andr=C3=A9_Lureau?= , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Andreas_F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add a TYPE_USER_CREATABLE object global property check. Rename the test, since it is no longer QDev-specific. Signed-off-by: Marc-André Lureau --- ...dev-global-props.c => test-global-props.c} | 128 ++++++++++++++++-- tests/Makefile.include | 4 +- 2 files changed, 117 insertions(+), 15 deletions(-) rename tests/{test-qdev-global-props.c => 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 08e7f5c8e5..df047bfa1c 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" +#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 = DUMMY_OBJECT(obj); + + g_free(dobj->sv); + dobj->sv = g_strdup(value); +} + +static char *dummy_get_sv(Object *obj, + Error **errp) +{ + DummyObject *dobj = 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 = DUMMY_OBJECT(obj); + + g_free(dobj->sv); +} + + +static const TypeInfo dummy_info = { + .name = TYPE_DUMMY, + .parent = TYPE_OBJECT, + .instance_size = sizeof(DummyObject), + .instance_finalize = dummy_finalize, + .class_size = sizeof(DummyObjectClass), + .class_init = dummy_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_USER_CREATABLE }, + { } + } +}; + +static void test_global_props_uc_subprocess(void) +{ + DummyObject *d; + static GlobalProperty gp = { + TYPE_DUMMY, "sv", "foobar", + }; + + d = DUMMY_OBJECT(object_new(TYPE_DUMMY)); + g_assert_null(d->sv); + object_unref(OBJECT(d)); + + object_property_register_global(&gp); + d = DUMMY_OBJECT(object_new(TYPE_DUMMY)); + g_assert_cmpstr(d->sv, ==, "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(""); +} #define TYPE_STATIC_PROPS "static_prop_type" #define STATIC_TYPE(obj) \ @@ -83,7 +176,8 @@ static void test_static_prop_subprocess(void) 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) 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) 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(void) static void test_dynamic_globalprop_nouser(void) { - g_test_trap_subprocess("/qdev/properties/dynamic/global/nouser/subprocess", 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); 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); - 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); - 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); - 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); - 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); - g_test_add_func("/qdev/properties/global/subclass", + g_test_add_func("/global-props/qdev/global/subclass", test_subclass_global_props); g_test_run(); diff --git a/tests/Makefile.include b/tests/Makefile.include index f77a495109..446de4afda 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -88,7 +88,7 @@ check-unit-y += tests/test-qht$(EXESUF) check-unit-y += tests/test-qht-par$(EXESUF) check-unit-y += tests/test-bitops$(EXESUF) check-unit-y += tests/test-bitcnt$(EXESUF) -check-unit-y += tests/test-qdev-global-props$(EXESUF) +check-unit-y += tests/test-global-props$(EXESUF) check-unit-y += tests/check-qom-interface$(EXESUF) check-unit-y += tests/check-qom-proplist$(EXESUF) check-unit-y += tests/test-qemu-opts$(EXESUF) @@ -557,7 +557,7 @@ tests/atomic64-bench$(EXESUF): tests/atomic64-bench.o $(test-util-obj-y) tests/fp/%: $(MAKE) -C $(dir $@) $(notdir $@) -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 \ From patchwork Tue Oct 30 15:04:52 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: 990930 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 42kwMz3pDQz9s8F for ; Wed, 31 Oct 2018 02:28:14 +1100 (AEDT) Received: from localhost ([::1]:53905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVwB-00082A-JW for incoming@patchwork.ozlabs.org; Tue, 30 Oct 2018 11:28:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVcd-0005tt-HM for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:08:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHVca-0006HY-IG for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:07:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33002) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHVca-0005xP-6x for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:07:56 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6DAA32D7F5; Tue, 30 Oct 2018 15:07:52 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 119152A198; Tue, 30 Oct 2018 15:07:42 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 19:04:52 +0400 Message-Id: <20181030150453.9344-10-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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 30 Oct 2018 15:07:52 +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] [PATCH v2 09/10] 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 , Amit Shah , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?utf-8?q?Marc-?= =?utf-8?q?Andr=C3=A9_Lureau?= , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Andreas_F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The following patch is going to add compatiblity parameters. Signed-off-by: Marc-André Lureau Reviewed-by: Michael S. Tsirkin Reviewed-by: Eduardo Habkost Reviewed-by: Igor Mammedov --- include/hw/i386/pc.h | 2 +- hw/i386/pc_piix.c | 15 ++++++++++++--- hw/i386/pc_q35.c | 13 +++++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index dfe6746692..67ff516d61 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -300,7 +300,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .driver = TYPE_X86_CPU,\ .property = "x-hv-synic-kvm-only",\ .value = "on",\ - } + }, #define PC_COMPAT_2_12 \ HW_COMPAT_2_12 \ 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); } -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 = "pc"; m->is_default = 1; } +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 = 0; + m->alias = 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); static void pc_i440fx_2_12_machine_options(MachineClass *m) { pc_i440fx_3_0_machine_options(m); - m->is_default = 0; - m->alias = NULL; SET_MACHINE_COMPAT(m, PC_COMPAT_2_12); } 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 = 288; } -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 = "q35"; } +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 = 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); static void pc_q35_2_12_machine_options(MachineClass *m) { pc_q35_3_0_machine_options(m); - m->alias = NULL; SET_MACHINE_COMPAT(m, PC_COMPAT_2_12); } From patchwork Tue Oct 30 15:04:53 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: 990934 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 42kwPj5hFkz9s8F for ; Wed, 31 Oct 2018 02:29:45 +1100 (AEDT) Received: from localhost ([::1]:53916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVxe-0000np-RR for incoming@patchwork.ozlabs.org; Tue, 30 Oct 2018 11:29:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVcn-0006Hg-Aa for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:08:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHVcj-0006kJ-10 for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:08:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58866) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHVci-0006h9-IQ for qemu-devel@nongnu.org; Tue, 30 Oct 2018 11:08:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC6A6308421B; Tue, 30 Oct 2018 15:08:03 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A3E8620B8; Tue, 30 Oct 2018 15:07:56 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 19:04:53 +0400 Message-Id: <20181030150453.9344-11-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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 30 Oct 2018 15:08:03 +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] [PATCH v2 10/10] hostmem: use object id 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 , Amit Shah , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, =?utf-8?q?Marc-?= =?utf-8?q?Andr=C3=A9_Lureau?= , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Andreas_F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" hostmem-file and hostmem-memfd use the whole object path for the memory region name, and hostname-ram uses only the path component (the object id, or canonical path basename): qemu -m 1024 -object memory-backend-file,id=mem,size=1G,mem-path=/tmp/foo -numa node,memdev=mem -monitor stdio (qemu) info ramblock Block Name PSize Offset Used Total /objects/mem 4 KiB 0x0000000000000000 0x0000000040000000 0x0000000040000000 qemu -m 1024 -object memory-backend-memfd,id=mem,size=1G -numa node,memdev=mem -monitor stdio (qemu) info ramblock Block Name PSize Offset Used Total /objects/mem 4 KiB 0x0000000000000000 0x0000000040000000 0x0000000040000000 qemu -m 1024 -object memory-backend-ram,id=mem,size=1G -numa node,memdev=mem -monitor stdio (qemu) info ramblock Block Name PSize Offset Used Total mem 4 KiB 0x0000000000000000 0x0000000040000000 0x0000000040000000 Use the object id for -file and -memfd with >= 3.1 for consistency. Having a consistent naming allow to migrate to different hostmem backends. Signed-off-by: Marc-André Lureau --- include/hw/compat.h | 11 ++++++++++- include/sysemu/hostmem.h | 3 ++- backends/hostmem-file.c | 8 ++++---- backends/hostmem-memfd.c | 2 +- backends/hostmem-ram.c | 9 ++++----- backends/hostmem.c | 30 ++++++++++++++++++++++++++++++ 6 files changed, 51 insertions(+), 12 deletions(-) diff --git a/include/hw/compat.h b/include/hw/compat.h index 6f4d5fc647..60f4a939a7 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -2,7 +2,16 @@ #define HW_COMPAT_H #define HW_COMPAT_3_0 \ - /* empty */ + {\ + .driver = "memory-backend-file",\ + .property = "x-use-canonical-path-for-ramblock-id",\ + .value = "true",\ + },\ + {\ + .driver = "memory-backend-memfd",\ + .property = "x-use-canonical-path-for-ramblock-id",\ + .value = "true",\ + }, #define HW_COMPAT_2_12 \ {\ diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 6e6bd2c1cb..a023b372a4 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -53,7 +53,7 @@ struct HostMemoryBackend { /* protected */ uint64_t size; - bool merge, dump; + bool merge, dump, use_canonical_path; bool prealloc, force_prealloc, is_mapped, share; DECLARE_BITMAP(host_nodes, MAX_NODES + 1); HostMemPolicy policy; @@ -67,5 +67,6 @@ MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend); void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped); bool host_memory_backend_is_mapped(HostMemoryBackend *backend); size_t host_memory_backend_pagesize(HostMemoryBackend *memdev); +char *host_memory_backend_get_name(HostMemoryBackend *backend); #endif diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 639c8d4307..c01a7cdf8d 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -55,16 +55,16 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) error_setg(errp, "-mem-path not supported on this host"); #else if (!host_memory_backend_mr_inited(backend)) { - gchar *path; + gchar *name; backend->force_prealloc = mem_prealloc; - path = object_get_canonical_path(OBJECT(backend)); + name = host_memory_backend_get_name(backend); memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), - path, + name, backend->size, fb->align, (backend->share ? RAM_SHARED : 0) | (fb->is_pmem ? RAM_PMEM : 0), fb->mem_path, errp); - g_free(path); + g_free(name); } #endif } diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index b6836b28e5..c5a4a9b530 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -57,7 +57,7 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) return; } - name = object_get_canonical_path(OBJECT(backend)); + name = host_memory_backend_get_name(backend); memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), name, backend->size, true, fd, errp); g_free(name); diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c index 7ddd08d370..24b65d9ae3 100644 --- a/backends/hostmem-ram.c +++ b/backends/hostmem-ram.c @@ -16,21 +16,20 @@ #define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram" - static void ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { - char *path; + char *name; if (!backend->size) { error_setg(errp, "can't create backend with size 0"); return; } - path = object_get_canonical_path_component(OBJECT(backend)); - memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), path, + name = host_memory_backend_get_name(backend); + memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), name, backend->size, backend->share, errp); - g_free(path); + g_free(name); } static void diff --git a/backends/hostmem.c b/backends/hostmem.c index 1a89342039..0032232866 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -28,6 +28,16 @@ QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_BIND != MPOL_BIND); QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_INTERLEAVE != MPOL_INTERLEAVE); #endif +char * +host_memory_backend_get_name(HostMemoryBackend *self) +{ + if (!self->use_canonical_path) { + return object_get_canonical_path_component(OBJECT(self)); + } + + return object_get_canonical_path(OBJECT(self)); +} + static void host_memory_backend_get_size(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -386,6 +396,23 @@ static void host_memory_backend_set_share(Object *o, bool value, Error **errp) backend->share = value; } +static bool +host_memory_backend_get_use_canonical_path(Object *obj, Error **errp) +{ + HostMemoryBackend *self = MEMORY_BACKEND(obj); + + return self->use_canonical_path; +} + +static void +host_memory_backend_set_use_canonical_path(Object *obj, bool value, + Error **errp) +{ + HostMemoryBackend *self = MEMORY_BACKEND(obj); + + self->use_canonical_path = value; +} + static void host_memory_backend_class_init(ObjectClass *oc, void *data) { @@ -432,6 +459,9 @@ host_memory_backend_class_init(ObjectClass *oc, void *data) &error_abort); object_class_property_set_description(oc, "share", "Mark the memory as private to QEMU or shared", &error_abort); + object_class_property_add_bool(oc, "x-use-canonical-path-for-ramblock-id", + host_memory_backend_get_use_canonical_path, + host_memory_backend_set_use_canonical_path, &error_abort); } static const TypeInfo host_memory_backend_info = {