From nobody Thu May 16 03:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694183961; cv=none; d=zohomail.com; s=zohoarc; b=nX4+H6BJozKM5m22UdUxaYNRCb5BBU6AOOioBAhGE2K9tkEjVeyuGvF5YJF782ea+JjfdJNjjjsBpyY8f+Yq+GT1bJy4jP19NFf+IMBDlP8kYDCZ8wZMayyGJ6bz+Y56eHzdV3cJnUROBuJBUYyFbHcuZZmdVerw9IPMzIpLDP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694183961; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gN/x78zkCjmttDAG1vhbIHZqHUQBCvqc7tTYgYVzYY4=; b=dyvZUaohWmzJ8/NgnCI4XYxoLqB+1PRcWZTIBOfg9R9qJ840L+90ttdqkBFbP5lJJ2QAdrovkIxRiqv26puVvdkbBrKvRV881AWVoSdR3W6DPJQXTZiXCVdI7mwRr+TTvnsDo5VmJqsFNSeO00YWrKf/jzmQYW76Ru4lodKEGt4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694183961629856.9039058502298; Fri, 8 Sep 2023 07:39:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeccZ-0005oi-4d; Fri, 08 Sep 2023 10:38:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccJ-0005et-QL for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccG-00077f-Fa for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:50 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-iP4E2jIuPFC_Vj_R8MhPZA-1; Fri, 08 Sep 2023 10:37:44 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 13D323C0E472; Fri, 8 Sep 2023 14:37:44 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.193.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AE27140E962; Fri, 8 Sep 2023 14:37:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694183867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gN/x78zkCjmttDAG1vhbIHZqHUQBCvqc7tTYgYVzYY4=; b=YAMZ8BOSjqWQhNVi6SXSLkttuJfueIdNCXDOA8RoVy1/jtvM4YafbW47w10nPGxjQcSef9 +WnztmaQEFegwEyrEJFQ1rrMH5B1NKk8+f8O/THHCL79kReA+6PZmky6uk5OZg6C+C8TTd kWLDyLjh0omD4HHLqXl/NoNYen2FN/Q= X-MC-Unique: iP4E2jIuPFC_Vj_R8MhPZA-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, berrange@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com Subject: [PATCH 01/11] qdev: Add qdev_prop_set_array() Date: Fri, 8 Sep 2023 16:36:52 +0200 Message-ID: <20230908143703.172758-2-kwolf@redhat.com> In-Reply-To: <20230908143703.172758-1-kwolf@redhat.com> References: <20230908143703.172758-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694183964560100007 Content-Type: text/plain; charset="utf-8" Instead of exposing the ugly hack of how we represent arrays in qdev (a static "foo-len" property and after it is set, dynamically created "foo[i]" properties) to boards, add an interface that allows setting the whole array at once. Once all internal users of devices with array properties have been converted to use this function, we can change the implementation to move away from this hack. Signed-off-by: Kevin Wolf Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/qdev-properties.h | 3 +++ hw/core/qdev-properties.c | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index e1df08876c..7fa2fdb7c9 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -206,6 +206,9 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char= *name, const uint8_t *value); void qdev_prop_set_enum(DeviceState *dev, const char *name, int value); =20 +/* Takes ownership of @values */ +void qdev_prop_set_array(DeviceState *dev, const char *name, QList *values= ); + void *object_field_prop_ptr(Object *obj, Property *prop); =20 void qdev_prop_register_global(GlobalProperty *prop); diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 357b8761b5..950ef48e01 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -3,12 +3,14 @@ #include "qapi/error.h" #include "qapi/qapi-types-misc.h" #include "qapi/qmp/qerror.h" +#include "qapi/qmp/qlist.h" #include "qemu/ctype.h" #include "qemu/error-report.h" #include "qapi/visitor.h" #include "qemu/units.h" #include "qemu/cutils.h" #include "qdev-prop-internal.h" +#include "qom/qom-qobject.h" =20 void qdev_prop_set_after_realize(DeviceState *dev, const char *name, Error **errp) @@ -739,6 +741,25 @@ void qdev_prop_set_enum(DeviceState *dev, const char *= name, int value) &error_abort); } =20 +void qdev_prop_set_array(DeviceState *dev, const char *name, QList *values) +{ + const QListEntry *entry; + g_autofree char *prop_len =3D g_strdup_printf("len-%s", name); + uint32_t i =3D 0; + + object_property_set_int(OBJECT(dev), prop_len, qlist_size(values), + &error_abort); + + QLIST_FOREACH_ENTRY(values, entry) { + g_autofree char *prop_idx =3D g_strdup_printf("%s[%u]", name, i); + object_property_set_qobject(OBJECT(dev), prop_idx, entry->value, + &error_abort); + i++; + } + + qobject_unref(values); +} + static GPtrArray *global_props(void) { static GPtrArray *gp; --=20 2.41.0 From nobody Thu May 16 03:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694183939; cv=none; d=zohomail.com; s=zohoarc; b=H7XuGt3DbGW+9I04a42Nsz+vxRVQTimVDgTyaP+i46XCKYmjRz28Pfsc+toicK7bDJGvbnN6EafftdscMPXyihp/3Kgmpg4pbQuZI4PVqapHjcRwX9P689V5O7DqyAHU2AHT1Y0SuJ4r6ETit1Xjk63tK2Hq5E7qo6SWaM50Ynw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694183939; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FV0XJ/1gQlrDEcN3YkpLUuKIvHxKCLAYMZJOOHKSzc0=; b=awKGKhRxukMQCYNDBkZBpy5PrVkH/7NsoICkncFqnTSLyw0xrBwrDmJ2p8iPuAv5REgWGMktKuDAIDegBQbGrVdM5gIPd9kVKQd9we0zGzi4vgCmd/TOGtrCWXC55tqjX73kVWs3n0XRXnJ7boezfT66hzLIIhAqg8Y52Ko+/Og= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694183939727435.5939939960117; Fri, 8 Sep 2023 07:38:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeccS-0005kR-3i; Fri, 08 Sep 2023 10:38:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccK-0005ew-GY for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccH-000785-V7 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:52 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-640-UgOI-6fCOw2uW-u-Rwl0eQ-1; Fri, 08 Sep 2023 10:37:45 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 58F47281CC23; Fri, 8 Sep 2023 14:37:45 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.193.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A509140E962; Fri, 8 Sep 2023 14:37:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694183869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FV0XJ/1gQlrDEcN3YkpLUuKIvHxKCLAYMZJOOHKSzc0=; b=E01lDMrUuDjoGLGPmKu8rh1+9fgn6EXpBT7TWW1QHbh/3UKPCB7SfiIfKjKGH7BESVErSp l9hblIXyJd8Az7rnGCUv59P5aqFnfoJWki371S3pjyJWRN/Vvr/CkmL+uhfCh+OOlsnK5Q nEX94rHnMO03sX4deIW8SYj6jKI9YLs= X-MC-Unique: UgOI-6fCOw2uW-u-Rwl0eQ-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, berrange@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com Subject: [PATCH 02/11] hw/i386/pc: Use qdev_prop_set_array() Date: Fri, 8 Sep 2023 16:36:53 +0200 Message-ID: <20230908143703.172758-3-kwolf@redhat.com> In-Reply-To: <20230908143703.172758-1-kwolf@redhat.com> References: <20230908143703.172758-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694183941359100002 Content-Type: text/plain; charset="utf-8" Instead of manually setting "foo-len" and "foo[i]" properties, build a QList and use the new qdev_prop_set_array() helper to set the whole array property with a single call. Signed-off-by: Kevin Wolf Reviewed-by: Peter Maydell --- hw/i386/pc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 54838c0c41..0e84e454cb 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -81,6 +81,7 @@ #include "qapi/error.h" #include "qapi/qapi-visit-common.h" #include "qapi/qapi-visit-machine.h" +#include "qapi/qmp/qlist.h" #include "qapi/visitor.h" #include "hw/core/cpu.h" #include "hw/usb.h" @@ -1508,9 +1509,10 @@ static void pc_machine_device_pre_plug_cb(HotplugHan= dler *hotplug_dev, char *resv_prop_str =3D g_strdup_printf("0xfee00000:0xfeefffff:%d", VIRTIO_IOMMU_RESV_MEM_T_MSI); =20 - object_property_set_uint(OBJECT(dev), "len-reserved-regions", 1, e= rrp); - object_property_set_str(OBJECT(dev), "reserved-regions[0]", - resv_prop_str, errp); + QList *reserved_regions =3D qlist_new(); + qlist_append_str(reserved_regions, resv_prop_str); + qdev_prop_set_array(dev, "reserved-regions", reserved_regions); + g_free(resv_prop_str); } =20 --=20 2.41.0 From nobody Thu May 16 03:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694183972; cv=none; d=zohomail.com; s=zohoarc; b=bgKftW3VWnDWepPatYHVnKNlHcjWwJQsvrwuW3p12NBbuwkIMwT2m2J8SugeK4hjpLihcbtr1ySX6EEjxqFrfAw0W2w6SqHt0lB3VgBuaEOjvGAZyheo1JVeat2Bv+gx9IQZNFOsdrJJychCTEnNS6rN9sRRJq33WQ2Gmz30T2I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694183972; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g+53snmqqvLuiEtryNcXiqGK5O3YHAW/v8FYJ4ipa/g=; b=DQYxanCcSub5ocuq0TMHz4AdNr6kgVqFTwI5ZgmDRIe455GBYev+I0tRYYNSoO5U1t/hueVb4k1mKRWTB7Nbkh6Bi0SRCYFWt3evWwdrTN6X8EuZwI5npIsakLn77KqZ7iapkbtka4BG0deJujkxf1Zyqh4p3yjU/GN13T7Hmi4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694183972932686.0832275307375; Fri, 8 Sep 2023 07:39:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeccW-0005m4-1c; Fri, 08 Sep 2023 10:38:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccK-0005ev-1z for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccH-00077r-86 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:51 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-528-8EP5vfBlOaSbtmTh5Ob-qw-1; Fri, 08 Sep 2023 10:37:46 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8409C1C0897A; Fri, 8 Sep 2023 14:37:46 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.193.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F46A140E962; Fri, 8 Sep 2023 14:37:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694183868; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g+53snmqqvLuiEtryNcXiqGK5O3YHAW/v8FYJ4ipa/g=; b=aIn1ME4D1S2k2BBZa5ZY0D0JPz/O6lWTXmKjqB/X3DVmF2IlWGYYUl/BbqlEo2vurv169l 6wAMU40bA7SQqiQQkitxRlKDQ9sjE9oYxDZD6D2dF2e9DncwHIpnxxm+XknMMIUN1+nmog ZO1mUlQuLb3WkdWFdu1BAmcMOW6rgoU= X-MC-Unique: 8EP5vfBlOaSbtmTh5Ob-qw-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, berrange@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com Subject: [PATCH 03/11] hw/arm/mps2-tz: Use qdev_prop_set_array() Date: Fri, 8 Sep 2023 16:36:54 +0200 Message-ID: <20230908143703.172758-4-kwolf@redhat.com> In-Reply-To: <20230908143703.172758-1-kwolf@redhat.com> References: <20230908143703.172758-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694183975027100005 Content-Type: text/plain; charset="utf-8" Instead of manually setting "foo-len" and "foo[i]" properties, build a QList and use the new qdev_prop_set_array() helper to set the whole array property with a single call. Signed-off-by: Kevin Wolf Reviewed-by: Peter Maydell --- hw/arm/mps2-tz.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c index eae3639da2..668db5ed61 100644 --- a/hw/arm/mps2-tz.c +++ b/hw/arm/mps2-tz.c @@ -48,6 +48,7 @@ #include "qemu/units.h" #include "qemu/cutils.h" #include "qapi/error.h" +#include "qapi/qmp/qlist.h" #include "qemu/error-report.h" #include "hw/arm/boot.h" #include "hw/arm/armv7m.h" @@ -461,6 +462,7 @@ static MemoryRegion *make_scc(MPS2TZMachineState *mms, = void *opaque, MPS2SCC *scc =3D opaque; DeviceState *sccdev; MPS2TZMachineClass *mmc =3D MPS2TZ_MACHINE_GET_CLASS(mms); + QList *oscclk; uint32_t i; =20 object_initialize_child(OBJECT(mms), "scc", scc, TYPE_MPS2_SCC); @@ -469,11 +471,13 @@ static MemoryRegion *make_scc(MPS2TZMachineState *mms= , void *opaque, qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2); qdev_prop_set_uint32(sccdev, "scc-aid", 0x00200008); qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id); - qdev_prop_set_uint32(sccdev, "len-oscclk", mmc->len_oscclk); + + oscclk =3D qlist_new(); for (i =3D 0; i < mmc->len_oscclk; i++) { - g_autofree char *propname =3D g_strdup_printf("oscclk[%u]", i); - qdev_prop_set_uint32(sccdev, propname, mmc->oscclk[i]); + qlist_append_int(oscclk, mmc->oscclk[i]); } + qdev_prop_set_array(sccdev, "oscclk", oscclk); + sysbus_realize(SYS_BUS_DEVICE(scc), &error_fatal); return sysbus_mmio_get_region(SYS_BUS_DEVICE(sccdev), 0); } --=20 2.41.0 From nobody Thu May 16 03:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694183960; cv=none; d=zohomail.com; s=zohoarc; b=bzdU5Wr7WpszGV+X8mgnY+F12EwiWF2JWgU1IcTOfJ2o6dHdVuleo65vv1hSN/QwAnoo6okD4BEFJfGBoNr7Nj4U8f6AKhQfX5PUM6ZZeUhnQfxHNMEyEJqBIbWtDTIECsw3TPNpyBX+XYX8hO38tjmnWxnmhukoDcx0UgYsSN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694183960; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bOvMM4Dv9HP2GSEX/cl5xEIAhUooEA8Y3WJZMe/UxN4=; b=NptpPL6fkCIGyhX1RYrJKKV0uVh7rYKj3di5gtUGeOCAHSZ4hrQHh3h6WpWtqCY9G+6C0LPGbRAH1RQoVmJLV3YVbiqzY9Gaail+QOGOfL4t5+OYJfH8eN/dwIP1shNdnRok4jeVS3RHIN/nzX1fFW+oeMdXRdc3anGp9yLsEQU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694183960510331.17386629129726; Fri, 8 Sep 2023 07:39:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeccd-0005sw-9V; Fri, 08 Sep 2023 10:38:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccK-0005ex-Jl for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccI-00078A-BR for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:52 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-616-B21O53XHNeGXQ-V6gvr9XA-1; Fri, 08 Sep 2023 10:37:48 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D2A6B800969; Fri, 8 Sep 2023 14:37:47 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.193.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAA22140E962; Fri, 8 Sep 2023 14:37:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694183869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bOvMM4Dv9HP2GSEX/cl5xEIAhUooEA8Y3WJZMe/UxN4=; b=K13bOe2xT1dzGuFEK93NMxp7BtnQNYZVDvqZlq4bqy28XSi4A2Lw6NKVdMkecnQ/rs/uYO Bicj+yszPtUto6lFAETV01jVQgpj9bSLm8JFK/6quoOeUWoa7AdUVJjQzEvWOXcGV9jBwy FclRbOfB7PdQgz1BkS+SlyaUaZCn2ZI= X-MC-Unique: B21O53XHNeGXQ-V6gvr9XA-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, berrange@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com Subject: [PATCH 04/11] hw/arm/mps2: Use qdev_prop_set_array() Date: Fri, 8 Sep 2023 16:36:55 +0200 Message-ID: <20230908143703.172758-5-kwolf@redhat.com> In-Reply-To: <20230908143703.172758-1-kwolf@redhat.com> References: <20230908143703.172758-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694183960789100001 Content-Type: text/plain; charset="utf-8" Instead of manually setting "foo-len" and "foo[i]" properties, build a QList and use the new qdev_prop_set_array() helper to set the whole array property with a single call. Signed-off-by: Kevin Wolf Reviewed-by: Peter Maydell --- hw/arm/mps2.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c index d92fd60684..292a180ad2 100644 --- a/hw/arm/mps2.c +++ b/hw/arm/mps2.c @@ -48,6 +48,7 @@ #include "net/net.h" #include "hw/watchdog/cmsdk-apb-watchdog.h" #include "hw/qdev-clock.h" +#include "qapi/qmp/qlist.h" #include "qom/object.h" =20 typedef enum MPS2FPGAType { @@ -138,6 +139,7 @@ static void mps2_common_init(MachineState *machine) MemoryRegion *system_memory =3D get_system_memory(); MachineClass *mc =3D MACHINE_GET_CLASS(machine); DeviceState *armv7m, *sccdev; + QList *oscclk; int i; =20 if (strcmp(machine->cpu_type, mc->default_cpu_type) !=3D 0) { @@ -402,10 +404,12 @@ static void mps2_common_init(MachineState *machine) qdev_prop_set_uint32(sccdev, "scc-aid", 0x00200008); qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id); /* All these FPGA images have the same OSCCLK configuration */ - qdev_prop_set_uint32(sccdev, "len-oscclk", 3); - qdev_prop_set_uint32(sccdev, "oscclk[0]", 50000000); - qdev_prop_set_uint32(sccdev, "oscclk[1]", 24576000); - qdev_prop_set_uint32(sccdev, "oscclk[2]", 25000000); + oscclk =3D qlist_new(); + qlist_append_int(oscclk, 50000000); + qlist_append_int(oscclk, 24576000); + qlist_append_int(oscclk, 25000000); + qdev_prop_set_array(sccdev, "oscclk", oscclk); + sysbus_realize(SYS_BUS_DEVICE(&mms->scc), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000); object_initialize_child(OBJECT(mms), "fpgaio", --=20 2.41.0 From nobody Thu May 16 03:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694183985; cv=none; d=zohomail.com; s=zohoarc; b=LalHn4px649jFwl5RA8lMev0jDwSvR1+ODYo0Y+hQkzdIkdd0t45xBGN0Zezmmzh0/cYPVSWg6hvu3+VcOr1pBtQhmbFqs/6LTXcOluO9RszmQaxaSQGv2pS1ZPFIl5UxqpC0AVFjCAZGZpJptfm2pECV54vU8p4bF3+8mu8gfg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694183985; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hXqGEMBIzhUEnijGoV5TEpk1X/j23KZWYFtOHXVuOpQ=; b=FSEgRaepNkdf+OzIkBUGBBFJx3SqYfdLm/1puNnmz+tzDP4dgQ52N2dJhg6yS/3TwZl4Mj4yaOdKVPu7qIEGOkDjdxH5dQbzmUacj/2PzloYXQnVnXMS74afpi6wYqDBF4NYSWsTSiNCcv2IXldOBz8t/qbYgy7EcyJpDimN+Bc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694183985065546.7966022914673; Fri, 8 Sep 2023 07:39:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeccd-0005sr-9D; Fri, 08 Sep 2023 10:38:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccL-0005ie-TV for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccJ-00078H-Jj for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:53 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-646-2ad4dDm5Mxu6Dkmgn3oC_w-1; Fri, 08 Sep 2023 10:37:49 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0AAF3948FEE; Fri, 8 Sep 2023 14:37:49 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.193.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15664140E962; Fri, 8 Sep 2023 14:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694183870; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hXqGEMBIzhUEnijGoV5TEpk1X/j23KZWYFtOHXVuOpQ=; b=FVt+HGr9eNgop+v7fXfUw6dH6ltOHoViIX89A7tlLaqtP6y8IFqQXs2AWd3HmHvph/cRJm 4j7cNhYVeehic6o4NJQ399rTHXLm1R8djpzHGkoNApAZCqYRt5pFNsYNV6e7yKklRiTI8B a2hLtZpnutLwUW28gfaZbHFeZ9Jbonk= X-MC-Unique: 2ad4dDm5Mxu6Dkmgn3oC_w-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, berrange@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com Subject: [PATCH 05/11] hw/arm/sbsa-ref: Use qdev_prop_set_array() Date: Fri, 8 Sep 2023 16:36:56 +0200 Message-ID: <20230908143703.172758-6-kwolf@redhat.com> In-Reply-To: <20230908143703.172758-1-kwolf@redhat.com> References: <20230908143703.172758-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694183985327100002 Content-Type: text/plain; charset="utf-8" Instead of manually setting "foo-len" and "foo[i]" properties, build a QList and use the new qdev_prop_set_array() helper to set the whole array property with a single call. Signed-off-by: Kevin Wolf Reviewed-by: Peter Maydell --- hw/arm/sbsa-ref.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index bc89eb4806..354c1a037d 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -46,6 +46,7 @@ #include "hw/char/pl011.h" #include "hw/watchdog/sbsa_gwdt.h" #include "net/net.h" +#include "qapi/qmp/qlist.h" #include "qom/object.h" =20 #define RAMLIMIT_GB 8192 @@ -441,6 +442,7 @@ static void create_gic(SBSAMachineState *sms, MemoryReg= ion *mem) SysBusDevice *gicbusdev; const char *gictype; uint32_t redist0_capacity, redist0_count; + QList *redist_region_count; int i; =20 gictype =3D gicv3_class_name(); @@ -459,8 +461,9 @@ static void create_gic(SBSAMachineState *sms, MemoryReg= ion *mem) sbsa_ref_memmap[SBSA_GIC_REDIST].size / GICV3_REDIST_SIZE; redist0_count =3D MIN(smp_cpus, redist0_capacity); =20 - qdev_prop_set_uint32(sms->gic, "len-redist-region-count", 1); - qdev_prop_set_uint32(sms->gic, "redist-region-count[0]", redist0_count= ); + redist_region_count =3D qlist_new(); + qlist_append_int(redist_region_count, redist0_count); + qdev_prop_set_array(sms->gic, "redist-region-count", redist_region_cou= nt); =20 object_property_set_link(OBJECT(sms->gic), "sysmem", OBJECT(mem), &error_fatal); --=20 2.41.0 From nobody Thu May 16 03:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694183954; cv=none; d=zohomail.com; s=zohoarc; b=hayHjmYbsZC8IDpLjZnb6C3F/7P4425jlZNjAfb4hYjpyjb/O1MfehnA4HneOwXas1nprWgA1xKGfhVxiZ2ePbhtr4vx5bBPCcEnv6ZoQn9fpDmKCCdVmzatWzXGHRWVi7D501Hv00qjt/R0zYe1L2hGe71TQZIU0DKPbHldlnY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694183954; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6vlbOC4oGOGeEU2j2KiZMeSRmOxWKk8y7VJU+mcI9Dc=; b=ivVt5slpFPXFwYBnpMX4gXDnY07o4LEECcv1MNngXN0qvGYDrnqlPFkQ93oqoCwt+wePVm2p3uKHxQL4QKy6PEYNgI7Gr+kUs65/YXuHgKIzC685JPZvjpUKdMLwGPCNbj0xs3CAqCWwPB+xmDx2pBfpV2QzUHmFCYjRWRvEGrk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169418395406724.101494980199504; Fri, 8 Sep 2023 07:39:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qecce-0005vS-UJ; Fri, 08 Sep 2023 10:38:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccP-0005kj-TT for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccN-00079M-OC for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:57 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-602-X4rgFHUeOCu_t3DuUoZINw-1; Fri, 08 Sep 2023 10:37:50 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 513AD281CC20; Fri, 8 Sep 2023 14:37:50 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.193.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CD6F140E962; Fri, 8 Sep 2023 14:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694183874; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6vlbOC4oGOGeEU2j2KiZMeSRmOxWKk8y7VJU+mcI9Dc=; b=Z1JhnrUzsMraRoSVT4NLaYPhonBdhq2/9nMYw1vPAupg/JA/OGXyQtXUWX6dLI1Yp2NLdJ LDnYlPWPiSHsu6prBbYvLM+SvK3tTzbZn8Ap3kWqsdd/mXqLnfDsmzLL5aV3rWNYn5Hr/4 OaFEei7AnhtpgDVP9UbKcZhONVwSqck= X-MC-Unique: X4rgFHUeOCu_t3DuUoZINw-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, berrange@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com Subject: [PATCH 06/11] hw/arm/vexpress: Use qdev_prop_set_array() Date: Fri, 8 Sep 2023 16:36:57 +0200 Message-ID: <20230908143703.172758-7-kwolf@redhat.com> In-Reply-To: <20230908143703.172758-1-kwolf@redhat.com> References: <20230908143703.172758-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694183954869100001 Content-Type: text/plain; charset="utf-8" Instead of manually setting "foo-len" and "foo[i]" properties, build a QList and use the new qdev_prop_set_array() helper to set the whole array property with a single call. Signed-off-by: Kevin Wolf Reviewed-by: Peter Maydell --- hw/arm/vexpress.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 56abadd9b8..7c7af0a9cb 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -43,6 +43,7 @@ #include "hw/cpu/a15mpcore.h" #include "hw/i2c/arm_sbcon_i2c.h" #include "hw/sd/sd.h" +#include "qapi/qmp/qlist.h" #include "qom/object.h" =20 #define VEXPRESS_BOARD_ID 0x8e0 @@ -551,6 +552,7 @@ static void vexpress_common_init(MachineState *machine) ram_addr_t vram_size, sram_size; MemoryRegion *sysmem =3D get_system_memory(); const hwaddr *map =3D daughterboard->motherboard_map; + QList *db_voltage, *db_clock; int i; =20 daughterboard->init(vms, machine->ram_size, machine->cpu_type, pic); @@ -591,20 +593,19 @@ static void vexpress_common_init(MachineState *machin= e) sysctl =3D qdev_new("realview_sysctl"); qdev_prop_set_uint32(sysctl, "sys_id", sys_id); qdev_prop_set_uint32(sysctl, "proc_id", daughterboard->proc_id); - qdev_prop_set_uint32(sysctl, "len-db-voltage", - daughterboard->num_voltage_sensors); + + db_voltage =3D qlist_new(); for (i =3D 0; i < daughterboard->num_voltage_sensors; i++) { - char *propname =3D g_strdup_printf("db-voltage[%d]", i); - qdev_prop_set_uint32(sysctl, propname, daughterboard->voltages[i]); - g_free(propname); + qlist_append_int(db_voltage, daughterboard->voltages[i]); } - qdev_prop_set_uint32(sysctl, "len-db-clock", - daughterboard->num_clocks); + qdev_prop_set_array(sysctl, "db-voltage", db_voltage); + + db_clock =3D qlist_new(); for (i =3D 0; i < daughterboard->num_clocks; i++) { - char *propname =3D g_strdup_printf("db-clock[%d]", i); - qdev_prop_set_uint32(sysctl, propname, daughterboard->clocks[i]); - g_free(propname); + qlist_append_int(db_clock, daughterboard->clocks[i]); } + qdev_prop_set_array(sysctl, "db-clock", db_clock); + sysbus_realize_and_unref(SYS_BUS_DEVICE(sysctl), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(sysctl), 0, map[VE_SYSREGS]); =20 --=20 2.41.0 From nobody Thu May 16 03:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694183994; cv=none; d=zohomail.com; s=zohoarc; b=mkxgv+XdGYDO1n2/E2DAR78pDLIxMrbO8I9pdXvypZYyaxFhEU6eKbk+b/9NLD59IpruWIEP04PFGJyUBPQHdKMEgJEu7dZO4XV0znfFUoaTI3DLZ1svPUp38gZyyrnYBquYTgqjGG4trVRZs90cHRlvRic2KBT0iT+c2rsFbms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694183994; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LIVQ//NnxGjyPy+YCbQ84aG0M7IFAZvAvmqP7j48JgE=; b=IFTkiGcRh6QMSZBcbz/xA2TVf/NGM3u9U/GNJoXSzznjhzBLS2yGSA4Rp92x9gT2gR7KfT5oU4Oo2RoneaQ9s61QY1tFunl8pPJ4CwqUYx+TPMhtIIQJBKze00pm9nNnifyHpaQeJkpob8AyuIbDE7oQGC3WK+UitLsJpQNZHIQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694183994158720.9323289237899; Fri, 8 Sep 2023 07:39:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qecce-0005uu-Gb; Fri, 08 Sep 2023 10:38:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccO-0005kW-Mm for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccM-00079F-GI for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:56 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-453-KzcgjCD5Pn6tH4cIvHW-aA-1; Fri, 08 Sep 2023 10:37:51 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94311281CC20; Fri, 8 Sep 2023 14:37:51 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.193.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87BD6140E962; Fri, 8 Sep 2023 14:37:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694183873; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LIVQ//NnxGjyPy+YCbQ84aG0M7IFAZvAvmqP7j48JgE=; b=duztdAQUV6ogyIJNFz+Fyye/mZ68KGoDfyF10ziHGehk4YmJ5zri50g5ggUgt4oMr81g1a LTLX6pVPGLzc44E8RnGUBju+yAWNk1WwEOfoT4qYq76WBcTE2Y8FyjyU+bfme9Wx2Egz6B CwF3PmTSdm8lmt5YffDAMadB4NBJi8g= X-MC-Unique: KzcgjCD5Pn6tH4cIvHW-aA-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, berrange@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com Subject: [PATCH 07/11] hw/arm/virt: Use qdev_prop_set_array() Date: Fri, 8 Sep 2023 16:36:58 +0200 Message-ID: <20230908143703.172758-8-kwolf@redhat.com> In-Reply-To: <20230908143703.172758-1-kwolf@redhat.com> References: <20230908143703.172758-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694183995732100004 Content-Type: text/plain; charset="utf-8" Instead of manually setting "foo-len" and "foo[i]" properties, build a QList and use the new qdev_prop_set_array() helper to set the whole array property with a single call. Signed-off-by: Kevin Wolf Reviewed-by: Peter Maydell --- hw/arm/virt.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index a13c658bbf..be04f68b48 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -69,6 +69,7 @@ #include "hw/firmware/smbios.h" #include "qapi/visitor.h" #include "qapi/qapi-visit-common.h" +#include "qapi/qmp/qlist.h" #include "standard-headers/linux/input.h" #include "hw/arm/smmuv3.h" #include "hw/acpi/acpi.h" @@ -746,14 +747,23 @@ static void create_gic(VirtMachineState *vms, MemoryR= egion *mem) } =20 if (vms->gic_version !=3D VIRT_GIC_VERSION_2) { + QList *redist_region_count; uint32_t redist0_capacity =3D virt_redist_capacity(vms, VIRT_GIC_R= EDIST); uint32_t redist0_count =3D MIN(smp_cpus, redist0_capacity); =20 nb_redist_regions =3D virt_gicv3_redist_region_count(vms); =20 - qdev_prop_set_uint32(vms->gic, "len-redist-region-count", - nb_redist_regions); - qdev_prop_set_uint32(vms->gic, "redist-region-count[0]", redist0_c= ount); + redist_region_count =3D qlist_new(); + qlist_append_int(redist_region_count, redist0_count); + if (nb_redist_regions =3D=3D 2) { + uint32_t redist1_capacity =3D + virt_redist_capacity(vms, VIRT_HIGH_GIC_REDIST2); + + qlist_append_int(redist_region_count, + MIN(smp_cpus - redist0_count, redist1_capacity)); + } + qdev_prop_set_array(vms->gic, "redist-region-count", + redist_region_count); =20 if (!kvm_irqchip_in_kernel()) { if (vms->tcg_its) { @@ -762,14 +772,6 @@ static void create_gic(VirtMachineState *vms, MemoryRe= gion *mem) qdev_prop_set_bit(vms->gic, "has-lpi", true); } } - - if (nb_redist_regions =3D=3D 2) { - uint32_t redist1_capacity =3D - virt_redist_capacity(vms, VIRT_HIGH_GIC_REDIST2); - - qdev_prop_set_uint32(vms->gic, "redist-region-count[1]", - MIN(smp_cpus - redist0_count, redist1_capacity)); - } } else { if (!kvm_irqchip_in_kernel()) { qdev_prop_set_bit(vms->gic, "has-virtualization-extensions", @@ -2743,6 +2745,7 @@ static void virt_machine_device_pre_plug_cb(HotplugHa= ndler *hotplug_dev, virtio_md_pci_pre_plug(VIRTIO_MD_PCI(dev), MACHINE(hotplug_dev), e= rrp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { hwaddr db_start =3D 0, db_end =3D 0; + QList *reserved_regions; char *resv_prop_str; =20 if (vms->iommu !=3D VIRT_IOMMU_NONE) { @@ -2769,9 +2772,9 @@ static void virt_machine_device_pre_plug_cb(HotplugHa= ndler *hotplug_dev, db_start, db_end, VIRTIO_IOMMU_RESV_MEM_T_MSI); =20 - object_property_set_uint(OBJECT(dev), "len-reserved-regions", 1, e= rrp); - object_property_set_str(OBJECT(dev), "reserved-regions[0]", - resv_prop_str, errp); + reserved_regions =3D qlist_new(); + qlist_append_str(reserved_regions, resv_prop_str); + qdev_prop_set_array(dev, "reserved-regions", reserved_regions); g_free(resv_prop_str); } } --=20 2.41.0 From nobody Thu May 16 03:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694183993; cv=none; d=zohomail.com; s=zohoarc; b=RM9njDEAMa7RVzEsQvC7MrKDX7d1gNLFcQ3TkkSk6ZsVGoFjEWSwZFeO8G2oX0Vw5oFeWwZpPTwJFuuchi2zbRMEYNMBHpE4LwNW1sUrzA1MAGN3xt2yukPvBJrJqOU8aegIHlbm4iVckSApZrAWABAdIyy6FBu436Hom6QTIGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694183993; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Rbf4uwtAqXl7GsAOLz54dF4jC8RLbokt3ceTEwkS1xA=; b=IPlvGWU7gu7Lj+9ChsVBwCdnJjKQrcRkXYF4Xkt7BNPEk5AcJlLVSbGkswjyDyzwbHLBPlJmqAE23x2fPuyAX7HtqgU//thUPWG17uL0SlZksOi5JQMMl40c+mI8aDOeGtQ619Cn/AyfPjhtixJJ9OlzJ5Xh8/WzyaS8oAS5HEA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694183993836733.7450912932752; Fri, 8 Sep 2023 07:39:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qecce-0005uM-66; Fri, 08 Sep 2023 10:38:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccQ-0005l9-Ji for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:38:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccN-00079U-Or for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:37:58 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-1-7Q4VS2wzMTmY_sHutk109Q-1; Fri, 08 Sep 2023 10:37:53 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BFCE0281CC20; Fri, 8 Sep 2023 14:37:52 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.193.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAB2F140E962; Fri, 8 Sep 2023 14:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694183874; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rbf4uwtAqXl7GsAOLz54dF4jC8RLbokt3ceTEwkS1xA=; b=EBoPXKRGi8fN/JNz0eoXwvpLNRfL5jIAyk2Qv0hMmKBcD3A6WwR/5cNF0M3WIY3ZrjFabd Ms4uFXbq5rJbXHc8FquS3Sz8OMqPaVcIZnBDmxwMbavOgFvyViIuaNKEGC4xUwLJjC0ELp VaM023kUYwnYOSjwfNSZjKe3WVEaVVc= X-MC-Unique: 7Q4VS2wzMTmY_sHutk109Q-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, berrange@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com Subject: [PATCH 08/11] hw/arm/xlnx-versal: Use qdev_prop_set_array() Date: Fri, 8 Sep 2023 16:36:59 +0200 Message-ID: <20230908143703.172758-9-kwolf@redhat.com> In-Reply-To: <20230908143703.172758-1-kwolf@redhat.com> References: <20230908143703.172758-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694183995725100003 Content-Type: text/plain; charset="utf-8" Instead of manually setting "foo-len" and "foo[i]" properties, build a QList and use the new qdev_prop_set_array() helper to set the whole array property with a single call. Signed-off-by: Kevin Wolf Reviewed-by: Peter Maydell --- hw/arm/xlnx-versal.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c index 60bf5fe657..fe2a810f9f 100644 --- a/hw/arm/xlnx-versal.c +++ b/hw/arm/xlnx-versal.c @@ -12,6 +12,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "qapi/error.h" +#include "qapi/qmp/qlist.h" #include "qemu/module.h" #include "hw/sysbus.h" #include "net/net.h" @@ -69,6 +70,7 @@ static void versal_create_apu_gic(Versal *s, qemu_irq *pi= c) }; SysBusDevice *gicbusdev; DeviceState *gicdev; + QList *redist_region_count; int nr_apu_cpus =3D ARRAY_SIZE(s->fpd.apu.cpu); int i; =20 @@ -79,8 +81,11 @@ static void versal_create_apu_gic(Versal *s, qemu_irq *p= ic) qdev_prop_set_uint32(gicdev, "revision", 3); qdev_prop_set_uint32(gicdev, "num-cpu", nr_apu_cpus); qdev_prop_set_uint32(gicdev, "num-irq", XLNX_VERSAL_NR_IRQS + 32); - qdev_prop_set_uint32(gicdev, "len-redist-region-count", 1); - qdev_prop_set_uint32(gicdev, "redist-region-count[0]", nr_apu_cpus); + + redist_region_count =3D qlist_new(); + qlist_append_int(redist_region_count, nr_apu_cpus); + qdev_prop_set_array(gicdev, "redist-region-count", redist_region_count= ); + qdev_prop_set_bit(gicdev, "has-security-extensions", true); =20 sysbus_realize(SYS_BUS_DEVICE(&s->fpd.apu.gic), &error_fatal); --=20 2.41.0 From nobody Thu May 16 03:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694183997; cv=none; d=zohomail.com; s=zohoarc; b=dqzuc8A+ysv5Ao8yGCm506gzUG2ycXWetnVEc0BuzDE31aN5bPJisb4cmWikvl3TdBjqs5Py1RnyujTAc2SLRX96MXdLDBsWxxEj+x+/fTx7jY8E/lLNXgImRd2EpE4sVS8f7Gq8sQ2/YHS+wK4bEF3xwIcNAbMpFy/bgnbsWl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694183997; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=divFIUG/OUTYweaoDUOYkKY/435y7H7fTd8g1oJWrsI=; b=bTIYkJV0P52zuEzs7nYk4YzZc0x0ljUbKNo4UE08gABwW44jD7wakwGcZYyXiGvhD/xEb5Dbpd8XpVaau/9DXo5bqy3E9gwR3mkVTZi29yeAcWpuHBU+WLPiU84PGaTKBtwSlc0gh13bkBlwP+OMaGNEndj65sKkvWBYUkdnCEw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694183997038312.32964987862874; Fri, 8 Sep 2023 07:39:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qecce-0005uK-3P; Fri, 08 Sep 2023 10:38:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccT-0005m5-Ap for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:38:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccQ-0007BO-W9 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:38:00 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-195-NtoVZMrHOsylfScdVHjkjw-1; Fri, 08 Sep 2023 10:37:54 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0E9323C0F694; Fri, 8 Sep 2023 14:37:54 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.193.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01C1A140E962; Fri, 8 Sep 2023 14:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694183878; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=divFIUG/OUTYweaoDUOYkKY/435y7H7fTd8g1oJWrsI=; b=D+NIPPYhkxUGtY5elWUn0Mnhdwss3mPRfzy5ZbcMlYExG6CQyyy0NdnboLb0eknV/NkFtm W2P/593sEdKPxLCE+kTAEn1O0CgGYaCC4KYZ6O6/dnA4S8FoVwh3PwhBtgGCplKTiN6Sk7 QHXDt5UwtXcxd8XGsaoLFRajY9YyVN8= X-MC-Unique: NtoVZMrHOsylfScdVHjkjw-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, berrange@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com Subject: [PATCH 09/11] hw/rx/rx62n: Use qdev_prop_set_array() Date: Fri, 8 Sep 2023 16:37:00 +0200 Message-ID: <20230908143703.172758-10-kwolf@redhat.com> In-Reply-To: <20230908143703.172758-1-kwolf@redhat.com> References: <20230908143703.172758-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694183998770100001 Content-Type: text/plain; charset="utf-8" Instead of manually setting "foo-len" and "foo[i]" properties, build a QList and use the new qdev_prop_set_array() helper to set the whole array property with a single call. Signed-off-by: Kevin Wolf Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/rx/rx62n.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/hw/rx/rx62n.c b/hw/rx/rx62n.c index 3e887a0fc7..6990096642 100644 --- a/hw/rx/rx62n.c +++ b/hw/rx/rx62n.c @@ -28,6 +28,7 @@ #include "hw/sysbus.h" #include "hw/qdev-properties.h" #include "sysemu/sysemu.h" +#include "qapi/qmp/qlist.h" #include "qom/object.h" =20 /* @@ -130,22 +131,22 @@ static void register_icu(RX62NState *s) { int i; SysBusDevice *icu; + QList *ipr_map, *trigger_level; =20 object_initialize_child(OBJECT(s), "icu", &s->icu, TYPE_RX_ICU); icu =3D SYS_BUS_DEVICE(&s->icu); - qdev_prop_set_uint32(DEVICE(icu), "len-ipr-map", NR_IRQS); + + ipr_map =3D qlist_new(); for (i =3D 0; i < NR_IRQS; i++) { - char propname[32]; - snprintf(propname, sizeof(propname), "ipr-map[%d]", i); - qdev_prop_set_uint32(DEVICE(icu), propname, ipr_table[i]); + qlist_append_int(ipr_map, ipr_table[i]); } - qdev_prop_set_uint32(DEVICE(icu), "len-trigger-level", - ARRAY_SIZE(levelirq)); + qdev_prop_set_array(sysctl, "ipr-map", ipr_map); + + trigger_level =3D qlist_new(); for (i =3D 0; i < ARRAY_SIZE(levelirq); i++) { - char propname[32]; - snprintf(propname, sizeof(propname), "trigger-level[%d]", i); - qdev_prop_set_uint32(DEVICE(icu), propname, levelirq[i]); + qlist_append_int(trigger_level, levelirq[i]); } + qdev_prop_set_array(sysctl, "trigger-level", trigger_level); =20 for (i =3D 0; i < NR_IRQS; i++) { s->irq[i] =3D qdev_get_gpio_in(DEVICE(icu), i); --=20 2.41.0 From nobody Thu May 16 03:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694183939; cv=none; d=zohomail.com; s=zohoarc; b=Lo8iJT8cw6u7rY1DuJlD+IXikbKr13IQq1a/A3Oa0PvgXnC/6aHP+p21l0x8ox93Vrac6K/5iiM4beEfu4YpPZAlDbDUdHrelZHwC7OLYnOpp9+Y3Hptc/EOPINEA4rkjoLs8etsw2lL27D4ttPEd+2EwJqqQFEkoAMqR7fr2Z0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694183939; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OVP8qdl8sCZdn+zA+TK/tpiK62y+dCro0dUwvWo/ETU=; b=U9DAa38YJsHha5/wVpc0XY3vYRnDwmUMAvD8ehWss6cPaSsp+ZnNIJ6C+kw/pLw2Xx1D3RnPQHCvX3QF6LIuYpcMOqKgBCVhfW6AvZ9EFK+juKLANsTFIBSvtOB3L2UaL2dflT3YzMugGxCn0gOP8YE5M9KY/LSPPI38UjcXbVE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694183939733820.0212400499948; Fri, 8 Sep 2023 07:38:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qecch-0005yA-Nl; Fri, 08 Sep 2023 10:38:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccg-0005xa-Kl for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:38:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccR-0007BV-6z for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:38:14 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-692-NPhzwVSNP5-vKbGNF8VXlg-1; Fri, 08 Sep 2023 10:37:55 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 577DE8001EA; Fri, 8 Sep 2023 14:37:55 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.193.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 453E9140E962; Fri, 8 Sep 2023 14:37:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694183878; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OVP8qdl8sCZdn+zA+TK/tpiK62y+dCro0dUwvWo/ETU=; b=WpFUekBxDaMBZ372/Z/Z8ftQ+yLrz8QOAPfMLoe+4IVmKxr3xYKH8swdCdTFZHIH+Gx4pT OMgpwXVBrN1QtPOrr6Y/irYHnV77Txs2w00Zbqz8Y5w/x8SyYz+UCxYQRPq/8SJNOFqrF+ GLz8vLzF+HDU+dQsYm1Wil09CZiXtmw= X-MC-Unique: NPhzwVSNP5-vKbGNF8VXlg-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, berrange@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com Subject: [PATCH 10/11] qom: Add object_property_set_default_list() Date: Fri, 8 Sep 2023 16:37:01 +0200 Message-ID: <20230908143703.172758-11-kwolf@redhat.com> In-Reply-To: <20230908143703.172758-1-kwolf@redhat.com> References: <20230908143703.172758-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694183941388100004 Content-Type: text/plain; charset="utf-8" This function provides a default for properties that are accessed using the list visitor interface. The default is always an empty list. Signed-off-by: Kevin Wolf Reviewed-by: Peter Maydell --- include/qom/object.h | 8 ++++++++ qom/object.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index ef7258a5e1..afccd24ca7 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1093,6 +1093,14 @@ void object_property_set_default_bool(ObjectProperty= *prop, bool value); */ void object_property_set_default_str(ObjectProperty *prop, const char *val= ue); =20 +/** + * object_property_set_default_list: + * @prop: the property to set + * + * Set the property default value to be an empty list. + */ +void object_property_set_default_list(ObjectProperty *prop); + /** * object_property_set_default_int: * @prop: the property to set diff --git a/qom/object.c b/qom/object.c index e25f1e96db..c328591dba 100644 --- a/qom/object.c +++ b/qom/object.c @@ -31,6 +31,7 @@ * of the QOM core on QObject? */ #include "qom/qom-qobject.h" #include "qapi/qmp/qbool.h" +#include "qapi/qmp/qlist.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" #include "qemu/error-report.h" @@ -1574,6 +1575,11 @@ void object_property_set_default_str(ObjectProperty = *prop, const char *value) object_property_set_default(prop, QOBJECT(qstring_from_str(value))); } =20 +void object_property_set_default_list(ObjectProperty *prop) +{ + object_property_set_default(prop, QOBJECT(qlist_new())); +} + void object_property_set_default_int(ObjectProperty *prop, int64_t value) { object_property_set_default(prop, QOBJECT(qnum_from_int(value))); --=20 2.41.0 From nobody Thu May 16 03:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694183973; cv=none; d=zohomail.com; s=zohoarc; b=SHO4yqHpv/rMR4Qvun+E3L5PL/LgNt+Rpk3qPDMml5Rb9UqCVW3sI2LAgCXy0klPR8ph7HnknJwWARW91FEe+vLr+cDkuuHUup0GMpqQBMbNeIA1U0LBhNLMsCUHbkIMBDVL3N0WdZxoMhNdJs5X0K+JuGDRD6E3SH08R5j+K04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694183973; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AfP346v659jH0sqRPDlwzG5Y4WVxtTc8BydPOZ82mQs=; b=NLoYQRIkvhM8kjR4JDIrP6w9e8LP6g5STso6n5UaDQO5rKPt8ECz9443SwoOJBE3cj7wC+x2FNaHVE3vZgdEK5sRjN4O5SAvUT/U1f4l68enkFv/jbvUEIiwGD+HcnbbFNf0CKBasiFFwKO+IfG4bVqOkjMpekhcX8kTl76lGTY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169418397306874.86786279886269; Fri, 8 Sep 2023 07:39:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeccf-0005vi-Fr; Fri, 08 Sep 2023 10:38:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccX-0005oA-83 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:38:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeccT-0007Bn-31 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 10:38:04 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-WM3XjZkHM62tGoOOZNN3OA-1; Fri, 08 Sep 2023 10:37:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 81BDC802E5A; Fri, 8 Sep 2023 14:37:56 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.193.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D8E6140E962; Fri, 8 Sep 2023 14:37:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694183879; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AfP346v659jH0sqRPDlwzG5Y4WVxtTc8BydPOZ82mQs=; b=JlMsFLLRz61JXF2gnlctqPUmUJi17A6AoxdIpTBW9pu4Kz8jMwuQchuVpU0kaiGyFvAKTo Yi1/llUaHT2v6SGdbRGiagS90ASISTWPz7gI3vZFHEHGdHby2lFgZ2yupP9x9F1dx1YoQz K+ZyH5D3+CVm9oj7qQ+KoREDpBuVYDQ= X-MC-Unique: WM3XjZkHM62tGoOOZNN3OA-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, berrange@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com Subject: [PATCH 11/11] qdev: Rework array properties based on list visitor Date: Fri, 8 Sep 2023 16:37:02 +0200 Message-ID: <20230908143703.172758-12-kwolf@redhat.com> In-Reply-To: <20230908143703.172758-1-kwolf@redhat.com> References: <20230908143703.172758-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694183975052100006 Content-Type: text/plain; charset="utf-8" Until now, array properties are actually implemented with a hack that uses multiple properties on the QOM level: a static "foo-len" property and after it is set, dynamically created "foo[i]" properties. In external interfaces (-device on the command line and device_add in QMP), this interface was broken by commit f3558b1b ('qdev: Base object creation on QDict rather than QemuOpts') because QDicts are unordered and therefore it could happen that QEMU tried to set the indexed properties before setting the length, which fails and effectively makes array properties inaccessible. In particular, this affects the 'ports' property of the 'rocker' device. This patch reworks the external interface so that instead of using a separate top-level property for the length and for each element, we use a single true array property that accepts a list value. In the external interfaces, this is naturally expressed as a JSON list and makes array properties accessible again. Creating an array property on the command line without using JSON format is currently not possible. This could be fixed by switching from QemuOpts to a keyval parser, which however requires consideration of the compatibility implications. All internal users of devices with array properties go through qdev_prop_set_array() at this point, so updating it takes care of all of them. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1090 Fixes: f3558b1b763683bb877f7dd5b282469cdadc65c3 Signed-off-by: Kevin Wolf Reviewed-by, of course. --- include/hw/qdev-properties.h | 23 ++-- hw/core/qdev-properties-system.c | 2 +- hw/core/qdev-properties.c | 204 +++++++++++++++++++------------ 3 files changed, 133 insertions(+), 96 deletions(-) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 7fa2fdb7c9..9370b36b72 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -61,7 +61,7 @@ extern const PropertyInfo qdev_prop_size; extern const PropertyInfo qdev_prop_string; extern const PropertyInfo qdev_prop_on_off_auto; extern const PropertyInfo qdev_prop_size32; -extern const PropertyInfo qdev_prop_arraylen; +extern const PropertyInfo qdev_prop_array; extern const PropertyInfo qdev_prop_link; =20 #define DEFINE_PROP(_name, _state, _field, _prop, _type, ...) { \ @@ -115,8 +115,6 @@ extern const PropertyInfo qdev_prop_link; .bitmask =3D (_bitmask), \ .set_default =3D false) =20 -#define PROP_ARRAY_LEN_PREFIX "len-" - /** * DEFINE_PROP_ARRAY: * @_name: name of the array @@ -127,24 +125,21 @@ extern const PropertyInfo qdev_prop_link; * @_arrayprop: PropertyInfo defining what property the array elements have * @_arraytype: C type of the array elements * - * Define device properties for a variable-length array _name. A - * static property "len-arrayname" is defined. When the device creator - * sets this property to the desired length of array, further dynamic - * properties "arrayname[0]", "arrayname[1]", ... are defined so the - * device creator can set the array element values. Setting the - * "len-arrayname" property more than once is an error. + * Define device properties for a variable-length array _name. The array = is + * represented as a list in the visitor interface. + * + * @_arraytype is required to be movable with memcpy(). * - * When the array length is set, the @_field member of the device + * When the array property is set, the @_field member of the device * struct is set to the array length, and @_arrayfield is set to point - * to (zero-initialised) memory allocated for the array. For a zero - * length array, @_field will be set to 0 and @_arrayfield to NULL. + * to the memory allocated for the array. + * * It is the responsibility of the device deinit code to free the * @_arrayfield memory. */ #define DEFINE_PROP_ARRAY(_name, _state, _field, \ _arrayfield, _arrayprop, _arraytype) \ - DEFINE_PROP((PROP_ARRAY_LEN_PREFIX _name), \ - _state, _field, qdev_prop_arraylen, uint32_t, \ + DEFINE_PROP(_name, _state, _field, qdev_prop_array, uint32_t, \ .set_default =3D true, \ .defval.u =3D 0, \ .arrayinfo =3D &(_arrayprop), \ diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index 6d5d43eda2..f557ee886e 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -450,7 +450,7 @@ static void set_netdev(Object *obj, Visitor *v, const c= har *name, peers_ptr->queues =3D queues; =20 out: - error_set_from_qdev_prop_error(errp, err, obj, name, str); + error_set_from_qdev_prop_error(errp, err, obj, prop->name, str); g_free(str); } =20 diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 950ef48e01..b2303a6fbc 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -546,98 +546,152 @@ const PropertyInfo qdev_prop_size32 =3D { =20 /* --- support for array properties --- */ =20 -/* Used as an opaque for the object properties we add for each - * array element. Note that the struct Property must be first - * in the struct so that a pointer to this works as the opaque - * for the underlying element's property hooks as well as for - * our own release callback. - */ -typedef struct { - struct Property prop; - char *propname; - ObjectPropertyRelease *release; -} ArrayElementProperty; - -/* object property release callback for array element properties: - * we call the underlying element's property release hook, and - * then free the memory we allocated when we added the property. +static Property array_elem_prop(Object *obj, Property *parent_prop, + const char *name, char *elem) +{ + return (Property) { + .info =3D parent_prop->arrayinfo, + .name =3D name, + /* + * This ugly piece of pointer arithmetic sets up the offset so + * that when the underlying release hook calls qdev_get_prop_ptr + * they get the right answer despite the array element not actually + * being inside the device struct. + */ + .offset =3D elem - (char *) obj, + }; +} + +/* + * Object property release callback for array properties: We call the unde= rlying + * element's property release hook for each element. + * + * Note that it is the responsibility of the individual device's deinit to= free + * the array proper. */ -static void array_element_release(Object *obj, const char *name, void *opa= que) +static void release_prop_array(Object *obj, const char *name, void *opaque) { - ArrayElementProperty *p =3D opaque; - if (p->release) { - p->release(obj, name, opaque); + Property *prop =3D opaque; + uint32_t *alenptr =3D object_field_prop_ptr(obj, prop); + void **arrayptr =3D (void *)obj + prop->arrayoffset; + char *elem =3D *arrayptr; + int i; + + for (i =3D 0; i < *alenptr; i++) { + Property elem_prop =3D array_elem_prop(obj, prop, name, elem); + prop->arrayinfo->release(obj, NULL, &elem_prop); + elem +=3D prop->arrayfieldsize; } - g_free(p->propname); - g_free(p); } =20 -static void set_prop_arraylen(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) +/* + * Setter for an array property. This sets both the array length (which is + * technically the property field in the object) and the array itself (a p= ointer + * to which is stored in the additional field described by prop->arrayoffs= et). + */ +static void set_prop_array(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) { - /* Setter for the property which defines the length of a - * variable-sized property array. As well as actually setting the - * array-length field in the device struct, we have to create the - * array itself and dynamically add the corresponding properties. - */ + ERRP_GUARD(); + Property *prop =3D opaque; uint32_t *alenptr =3D object_field_prop_ptr(obj, prop); void **arrayptr =3D (void *)obj + prop->arrayoffset; - void *eltptr; - const char *arrayname; - int i; + GenericList *list, *elem, *next; + const size_t list_elem_size =3D sizeof(*list) + prop->arrayfieldsize; + char *elemptr; + bool ok =3D true; =20 if (*alenptr) { error_setg(errp, "array size property %s may not be set more than = once", name); return; } - if (!visit_type_uint32(v, name, alenptr, errp)) { + + if (!visit_start_list(v, name, &list, list_elem_size, errp)) { return; } - if (!*alenptr) { + + /* Read the whole input into a temporary list */ + elem =3D list; + while (elem) { + Property elem_prop =3D array_elem_prop(obj, prop, name, elem->padd= ing); + prop->arrayinfo->set(obj, v, NULL, &elem_prop, errp); + if (*errp) { + ok =3D false; + goto out_obj; + } + (*alenptr)++; + elem =3D visit_next_list(v, elem, list_elem_size); + } + + ok =3D visit_check_list(v, errp); +out_obj: + visit_end_list(v, (void**) &list); + + if (!ok) { + for (elem =3D list; elem; elem =3D next) { + next =3D elem->next; + g_free(elem); + } return; } =20 - /* DEFINE_PROP_ARRAY guarantees that name should start with this prefi= x; - * strip it off so we can get the name of the array itself. + /* + * Now that we know how big the array has to be, move the data over to= a + * linear array and free the temporary list. */ - assert(strncmp(name, PROP_ARRAY_LEN_PREFIX, - strlen(PROP_ARRAY_LEN_PREFIX)) =3D=3D 0); - arrayname =3D name + strlen(PROP_ARRAY_LEN_PREFIX); + *arrayptr =3D g_malloc_n(*alenptr, prop->arrayfieldsize); + elemptr =3D *arrayptr; + for (elem =3D list; elem; elem =3D next) { + memcpy(elemptr, elem->padding, prop->arrayfieldsize); + elemptr +=3D prop->arrayfieldsize; + next =3D elem->next; + g_free(elem); + } +} =20 - /* Note that it is the responsibility of the individual device's deinit - * to free the array proper. - */ - *arrayptr =3D eltptr =3D g_malloc0(*alenptr * prop->arrayfieldsize); - for (i =3D 0; i < *alenptr; i++, eltptr +=3D prop->arrayfieldsize) { - char *propname =3D g_strdup_printf("%s[%d]", arrayname, i); - ArrayElementProperty *arrayprop =3D g_new0(ArrayElementProperty, 1= ); - arrayprop->release =3D prop->arrayinfo->release; - arrayprop->propname =3D propname; - arrayprop->prop.info =3D prop->arrayinfo; - arrayprop->prop.name =3D propname; - /* This ugly piece of pointer arithmetic sets up the offset so - * that when the underlying get/set hooks call qdev_get_prop_ptr - * they get the right answer despite the array element not actually - * being inside the device struct. - */ - arrayprop->prop.offset =3D eltptr - (void *)obj; - assert(object_field_prop_ptr(obj, &arrayprop->prop) =3D=3D eltptr); - object_property_add(obj, propname, - arrayprop->prop.info->name, - field_prop_getter(arrayprop->prop.info), - field_prop_setter(arrayprop->prop.info), - array_element_release, - arrayprop); +static void get_prop_array(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + ERRP_GUARD(); + + Property *prop =3D opaque; + uint32_t *alenptr =3D object_field_prop_ptr(obj, prop); + void **arrayptr =3D (void *)obj + prop->arrayoffset; + char *elem =3D *arrayptr; + GenericList *list; + const size_t list_elem_size =3D sizeof(*list) + prop->arrayfieldsize; + int i; + + if (!visit_start_list(v, name, &list, list_elem_size, errp)) { + return; } + + for (i =3D 0; i < *alenptr; i++) { + Property elem_prop =3D array_elem_prop(obj, prop, name, elem); + prop->arrayinfo->get(obj, v, NULL, &elem_prop, errp); + if (*errp) { + goto out_obj; + } + elem +=3D prop->arrayfieldsize; + } + +out_obj: + visit_end_list(v, (void**) &list); } =20 -const PropertyInfo qdev_prop_arraylen =3D { - .name =3D "uint32", - .get =3D get_uint32, - .set =3D set_prop_arraylen, - .set_default_value =3D qdev_propinfo_set_default_value_uint, +static void default_prop_array(ObjectProperty *op, const Property *prop) +{ + object_property_set_default_list(op); +} + +const PropertyInfo qdev_prop_array =3D { + .name =3D "list", + .get =3D get_prop_array, + .set =3D set_prop_array, + .release =3D release_prop_array, + .set_default_value =3D default_prop_array, }; =20 /* --- public helpers --- */ @@ -743,20 +797,8 @@ void qdev_prop_set_enum(DeviceState *dev, const char *= name, int value) =20 void qdev_prop_set_array(DeviceState *dev, const char *name, QList *values) { - const QListEntry *entry; - g_autofree char *prop_len =3D g_strdup_printf("len-%s", name); - uint32_t i =3D 0; - - object_property_set_int(OBJECT(dev), prop_len, qlist_size(values), - &error_abort); - - QLIST_FOREACH_ENTRY(values, entry) { - g_autofree char *prop_idx =3D g_strdup_printf("%s[%u]", name, i); - object_property_set_qobject(OBJECT(dev), prop_idx, entry->value, - &error_abort); - i++; - } - + object_property_set_qobject(OBJECT(dev), name, QOBJECT(values), + &error_abort); qobject_unref(values); } =20 --=20 2.41.0