From nobody Wed Nov 27 09:53: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=1699365094; cv=none; d=zohomail.com; s=zohoarc; b=VSYXpEtIIjjRHDh1lZa/WPVkmQM8mZfuUAGs5TJ4f44OCuG6wV171B82MY/VFpwbdnnAxJHGM5AcKpneb5byhVx2t2HVssabSqcZD0mpVOr4hIwqHdTzHi+jcQo58BzINYSs73yePejSfANZliBzOe26Z4oUCCoqdYpGg4EPRkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699365094; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Yc4UI/0VIctcRUXbgmM6tNOL5qhLM1pjyGCIyxRuDYY=; b=Hal3vtoMr7u+v2i+9FSHe+cabluxzainYrrOp9KEzvl12fz4eE2WRqXuQSSuHFku3Jfq2yErqZhO+hftMaIAJfczT7nWI00kVUIISd88S5UhLE9FTE3LBE3vLJBasn4iFvaJT8yWtyvOB7tS9bBvfQ7R/n+hYjEtb6fxSmq3JbI= 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 169936509462450.70725420245992; Tue, 7 Nov 2023 05:51:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0MSD-0008KT-5H; Tue, 07 Nov 2023 08:49:17 -0500 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 1r0MSB-0008By-Df for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:15 -0500 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 1r0MS8-0007SG-N7 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:15 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-577-AAhKC92QPueXDS3blEIGnA-1; Tue, 07 Nov 2023 08:49:00 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 14B8D810FDD for ; Tue, 7 Nov 2023 13:48:46 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C40C1C0D502; Tue, 7 Nov 2023 13:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699364951; 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=Yc4UI/0VIctcRUXbgmM6tNOL5qhLM1pjyGCIyxRuDYY=; b=MUntjFAdCKo1OgrwVGAq5BrRAIooIWCkvwyEf8a13vl5Hu3k4YIzgde9K4u5HXjNHcSWAs iH4w1mcGUVt/76kkkca+uneCKGiQMPo6jfm/dOLmmI/f5vKW3yQa1oUdYGPAZ3tEBw2Pru 1kFhFKdITiCkeK/ELdGrD8ADJUBQERA= X-MC-Unique: AAhKC92QPueXDS3blEIGnA-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com Subject: [PULL 01/11] hw/i386/pc: Use qdev_prop_set_array() Date: Tue, 7 Nov 2023 14:48:18 +0100 Message-ID: <20231107134828.35909-2-kwolf@redhat.com> In-Reply-To: <20231107134828.35909-1-kwolf@redhat.com> References: <20231107134828.35909-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1699365096289100005 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 Message-ID: <20231030142658.182193-3-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- 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 1aef21aa2c..9963c1d7ec 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -44,6 +44,7 @@ #include "sysemu/reset.h" #include "kvm/kvm_i386.h" #include "hw/xen/xen.h" +#include "qapi/qmp/qlist.h" #include "qemu/error-report.h" #include "hw/acpi/cpu_hotplug.h" #include "acpi-build.h" @@ -1452,10 +1453,11 @@ static void pc_machine_device_pre_plug_cb(HotplugHa= ndler *hotplug_dev, /* Declare the APIC range as the reserved MSI region */ char *resv_prop_str =3D g_strdup_printf("0xfee00000:0xfeefffff:%d", VIRTIO_IOMMU_RESV_MEM_T_MSI); + QList *reserved_regions =3D qlist_new(); + + qlist_append_str(reserved_regions, resv_prop_str); + qdev_prop_set_array(dev, "reserved-regions", reserved_regions); =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); g_free(resv_prop_str); } =20 --=20 2.41.0 From nobody Wed Nov 27 09:53: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=1699365037; cv=none; d=zohomail.com; s=zohoarc; b=AOLScpdWg55ylQ/B45jwWQ8k687RhjFp/e/LHDlHBhIwyvoFata8U0FM+s2mRHah2GpyoGYABnz0+Y7x2JWeZ4nSSMKbFgxZotTzTaoxg5SkZpR/kfdQgvZKdtjQIGStW4rYxWWXPqsuC0Vj02cyPS1/4GrB2SdNK29lDuHN2fM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699365037; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1dzjtZxIp/0MeaXcaRk/DmM71/5DhnIe+8v62dTtdOw=; b=GRCFwyxUtcypckJAoZxmK/Kh73ZmuyiZt4yPcQfyJEX/cdQX0p1Ew+x3eDoU8Ap50JjGij8Hb7hMNdyqO0CluPQBrRD6Fb+Vyte93YVZx/E7e7JAMcIY66tdQnBOu57TqymtLsURvdASspwqFf+OBb29vxKAJz5c9+YnL51l79I= 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 1699365037490420.9631661884591; Tue, 7 Nov 2023 05:50:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0MS3-0007th-DV; Tue, 07 Nov 2023 08:49:11 -0500 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 1r0MRp-0007rO-0E for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:48:53 -0500 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 1r0MRn-0007Kc-En for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:48:52 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-588-aYE0y0LmPyeXqMm8CxGMgQ-1; Tue, 07 Nov 2023 08:48:48 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 23972380406A for ; Tue, 7 Nov 2023 13:48:48 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id E91B51C03403; Tue, 7 Nov 2023 13:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699364930; 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=1dzjtZxIp/0MeaXcaRk/DmM71/5DhnIe+8v62dTtdOw=; b=Il3rMyCPAEnHSDoar9PPxPNLPHlDFVEdz56EDAwNhVSFYFnAKhDFhKFboay9ofHqf8b2N+ hVxwXTwtANHlRwYM97/SW8MwvD+RWhAdKnYCkHeA4vL1loh18D83gqycN2VCswxtm0rECZ XltDCIo8fk48Pc9ZVRTWufCX3TpqHLU= X-MC-Unique: aYE0y0LmPyeXqMm8CxGMgQ-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com Subject: [PULL 02/11] hw/arm/mps2-tz: Use qdev_prop_set_array() Date: Tue, 7 Nov 2023 14:48:19 +0100 Message-ID: <20231107134828.35909-3-kwolf@redhat.com> In-Reply-To: <20231107134828.35909-1-kwolf@redhat.com> References: <20231107134828.35909-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1699365038107100001 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 Message-ID: <20231030142658.182193-4-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- 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 Wed Nov 27 09:53: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=1699364968; cv=none; d=zohomail.com; s=zohoarc; b=l/jIINK3HfJ0ARaVkWgnvSfMxXqrWGbsUBAxGLlrclqPwj+HvZ+4I120xIkuX1jZ+PDccqKPVFMGznPpK1NZMx4WByBauRPn9w0bVcahQMaURJGi3zXXfsV9uWx1HDwvxDXx5Y/MV5NOP6fDB7PWEYztRDsyGTpPMeQBWL5C/II= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699364968; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jEHGvF/V0kahcbxmh0GMCSV8wO+p1lGL81F/osP3gTM=; b=ljFF2qIWT2C7+xqMXkhw8tiMkhyzBUpjjN2KF2I8E4Hywu2SI+snJYsCCijZL8vS9pSwMykp0i+cjfO4o4Lap3EWSFOMoBgZSfvdn2SjRnVMZVFpX1kue4q9HgJVSOIXKfEawKqyzQV5i2C/2GQi3ARjZ+kA/OcYDbyhSEm+SG0= 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 1699364968192337.84056349363607; Tue, 7 Nov 2023 05:49:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0MS9-00086i-WE; Tue, 07 Nov 2023 08:49:14 -0500 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 1r0MRw-0007t5-Dd for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:01 -0500 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 1r0MRt-0007Ly-9v for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:48:59 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-625-_eiRCGKFN9ORMwkhsD2drg-1; Tue, 07 Nov 2023 08:48:54 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC2091854C70 for ; Tue, 7 Nov 2023 13:48:47 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id 035E31C060CC; Tue, 7 Nov 2023 13:48:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699364936; 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=jEHGvF/V0kahcbxmh0GMCSV8wO+p1lGL81F/osP3gTM=; b=KYQyZltXtY3Xukx4CpzGXfNhqTU0N8GQoavHXy/hHEEJdahTrOvu2dPIipyE1wzNmfqghQ ZEyY0B7kL3iDoxhhBF5sWLGGUevxY0mGvXlHd+Y98Kr/+Vd6NWtFc9nnz27LtMhOz6oeXl f8D0g7qCh78F4XIiSFY/hvm4UqlrJqc= X-MC-Unique: _eiRCGKFN9ORMwkhsD2drg-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com Subject: [PULL 03/11] hw/arm/mps2: Use qdev_prop_set_array() Date: Tue, 7 Nov 2023 14:48:20 +0100 Message-ID: <20231107134828.35909-4-kwolf@redhat.com> In-Reply-To: <20231107134828.35909-1-kwolf@redhat.com> References: <20231107134828.35909-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1699364969957100003 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 Message-ID: <20231030142658.182193-5-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- 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 Wed Nov 27 09:53: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=1699365009; cv=none; d=zohomail.com; s=zohoarc; b=aCiOO+1ZnFmdC2i0FKBgmZWhMZVyL3rZaahafkqYh8S/5fI5SaZV4n+rqSxRVxjzn8F7LW2EQAD1/2/UbGnpsywBc5992L606ArHTwyHONHk1BOxu4D3dRijiuqhlBU9YG5uuxaUnYKnEfIpacyNjadSi300YhsUv2m1KhFWPRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699365009; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=q7y0cNDsqHl5M2QoqjYfqz/hZPdY3sTuJi8yDXOn4l0=; b=OUt97TpBAIvQeD+ar5yC7zw8zDXaIndoJ0QDG/gHRcit32ozwNh4mGdZARZSf1kR9PEA1rXhMrAp0UON74/JSmhlDHLOTbAt2wz8uuAdaMFePUVKHdNiJm/EStMlTxYUnKhQsQ72UT2KfMYOzipyQTiKqEiWbZ6YVU8lgjoMc0Y= 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 1699365009297683.8290878789192; Tue, 7 Nov 2023 05:50:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0MS7-0007vU-3A; Tue, 07 Nov 2023 08:49:11 -0500 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 1r0MRp-0007rP-HH for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:48:53 -0500 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 1r0MRn-0007KZ-PX for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:48:53 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-5FTqEhmiMN6jcT9WPtp4kg-1; Tue, 07 Nov 2023 08:48:49 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8207410138B0 for ; Tue, 7 Nov 2023 13:48:48 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5ED01C008C3; Tue, 7 Nov 2023 13:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699364930; 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=q7y0cNDsqHl5M2QoqjYfqz/hZPdY3sTuJi8yDXOn4l0=; b=VH9FJ0B74nBgYj1cmYOKI+0ftl7YRYh5n+EpVenjzvJSrjp1Sn9FeJe3UmwUF5w5Tfeabn 6WN1AwTT9XNBcbZJ1I0scSUmkHvuXkzwm/LtZsqcLQnor3W4hWEmpVEmlp+u5/S+22Rmrw N0ZDpWNLe5xLmHOfT9Q2sLRIJiM+778= X-MC-Unique: 5FTqEhmiMN6jcT9WPtp4kg-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com Subject: [PULL 04/11] hw/arm/sbsa-ref: Use qdev_prop_set_array() Date: Tue, 7 Nov 2023 14:48:21 +0100 Message-ID: <20231107134828.35909-5-kwolf@redhat.com> In-Reply-To: <20231107134828.35909-1-kwolf@redhat.com> References: <20231107134828.35909-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1699365010001100001 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 Message-ID: <20231030142658.182193-6-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- 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 bce44690e5..f3c9704693 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -48,6 +48,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 @@ -437,6 +438,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(); @@ -455,8 +457,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 Wed Nov 27 09:53: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=1699365113; cv=none; d=zohomail.com; s=zohoarc; b=Zpbgrt0taxbWflI2tn7tg97TQF1aHbV1YXyT9MwbyUHbKwzmr+kRSCiF2xl89sP34Pd49NeF1J0z38H2L6YvbVoof1o0dgraNzcv9Nsc+iIyGYjFtdCk82oOhn/JIUN2wQ+STPeMg2cu05qHFk4f3e9p/g82NhC3n4doG5AT0do= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699365113; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2i2nunhfPHqaGNtnGc+CfAIME4c3JurbLNEsQvtE70k=; b=oGnfYia3j5cOL243Ej5s+Oc3Fl2SUpcuNj/yfkmIK0uBr3H6DzSemcIZkfPbgJu660GHaWkMkc8GDsBohuHyc/A9xtFlKItOO4a5BdhpWOllIAWicgAU6lhf4+B+GlJFUD7u4BMta9rhYXsZWBZRrZorPIaKb+yNef9tQWJLN0Q= 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 1699365113207168.60427301946254; Tue, 7 Nov 2023 05:51:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0MSD-0008MB-T0; Tue, 07 Nov 2023 08:49:17 -0500 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 1r0MS8-00082i-VH for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:13 -0500 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 1r0MS6-0007RA-Pn for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:12 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-544-QaBcYxeHP_6Vhoqvp_1vzA-1; Tue, 07 Nov 2023 08:48:59 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 83DE5810F4E for ; Tue, 7 Nov 2023 13:48:49 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id A73071C060C0; Tue, 7 Nov 2023 13:48:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699364950; 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=2i2nunhfPHqaGNtnGc+CfAIME4c3JurbLNEsQvtE70k=; b=ZTNIce7dRs1BGwHi0nEIzvKFaxMfx+yxby0SJEsLK0tHd2e3+Y0Djt8CwQ9xH9lKq0fVHw 4+q6pu4r97FknKZuE8SRTt/pQtHWK9ZCxMi9VZOPS3Ho7oXDF5OiPJNLNmumCB6B09Jm+f c1/7gjYx+1c6LUffVf5q/Qo49RZkT7s= X-MC-Unique: QaBcYxeHP_6Vhoqvp_1vzA-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com Subject: [PULL 05/11] hw/arm/vexpress: Use qdev_prop_set_array() Date: Tue, 7 Nov 2023 14:48:22 +0100 Message-ID: <20231107134828.35909-6-kwolf@redhat.com> In-Reply-To: <20231107134828.35909-1-kwolf@redhat.com> References: <20231107134828.35909-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1699365114328100003 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 Message-ID: <20231030142658.182193-7-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- 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 c08ea34e92..fd981f4c33 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" #include "audio/audio.h" =20 @@ -544,6 +545,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); @@ -584,20 +586,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 Wed Nov 27 09:53: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=1699364970; cv=none; d=zohomail.com; s=zohoarc; b=Gx/Ok11zLVN3lix6oo3+f9/ez7yutSCJnKLbH3GIcwnnsSCga1rqUwlrMr/ZJ+6RmcgYhuF8i00PWV1l7FvtaxoRkFFQqaswHs7YzQY6c1cv7iHbPeXaA/8TI7fYCA05COJbiDrbNJ4DtVrkNsUYALA6k/+5PDpjphMYkl4mG/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699364970; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3oPG8ghG0XBBbnrTpFlCljk7qZfDTeT88Kb2PJa6mb4=; b=ZT8S5ZipD7O3BopEhHHYQ4O0Q49YXZEiSb0bF7MByWjr/XCB2TFUwxHj3+WfncfLeT5afaFs4uQqFjPAQv8s9ZNMMi43o6lKMpKlV4VJjGYzX9tcKOVHMocIAbz/LQKFBNlIJTBXvmTebQQgBx+sIE+d5x9QJVOtU8WjFWCpxAU= 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 1699364970832252.8575716816665; Tue, 7 Nov 2023 05:49:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0MS7-0007yJ-54; Tue, 07 Nov 2023 08:49:11 -0500 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 1r0MRq-0007rj-QB for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:48:55 -0500 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 1r0MRp-0007L9-32 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:48:54 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-209-vfdtOWmbMh2m6bX2HGm-0w-1; Tue, 07 Nov 2023 08:48:50 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 59BA41DD35DA for ; Tue, 7 Nov 2023 13:48:50 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id A04391C0005A; Tue, 7 Nov 2023 13:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699364932; 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=3oPG8ghG0XBBbnrTpFlCljk7qZfDTeT88Kb2PJa6mb4=; b=COZYuxiCYIEOZFrsgWV3IDOcPvUM9CmoZ2TIj3GA6G9iN3id6TJ8Lje80B3r622R1skrMD QmNQFjHBgyRl7V8ae5THaBIBnX5mNBf0JLFlWBt+LeNlBBKu/IwaMucsoYT2U/u/VisXuU fWUD/duJxrxAYgL52LybLy7Fs5ElJFo= X-MC-Unique: vfdtOWmbMh2m6bX2HGm-0w-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com Subject: [PULL 06/11] hw/arm/virt: Use qdev_prop_set_array() Date: Tue, 7 Nov 2023 14:48:23 +0100 Message-ID: <20231107134828.35909-7-kwolf@redhat.com> In-Reply-To: <20231107134828.35909-1-kwolf@redhat.com> References: <20231107134828.35909-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1699364971956100005 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 Message-ID: <20231030142658.182193-8-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- 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 0a16ab3095..85e3c5ba9d 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" @@ -752,14 +753,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) { @@ -768,14 +778,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", @@ -2748,6 +2750,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) { @@ -2774,9 +2777,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 Wed Nov 27 09:53: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=1699365054; cv=none; d=zohomail.com; s=zohoarc; b=Cx6SBShqC+2UJSnvRJdwWZ5zUg/2IluP7lqwLx8NLGu5SViZAxFRO/IqjJERNiEDCzU7eCZ3a9eV2T3rWBAhyu2B+vVLidzCCw1nxn1bzPGN58xX09auDqd7hcz/jj33WgqkcHgjaKvMJBjcwyItVzQ86wm6TZM/L+U5THE5AJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699365054; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AA67E7ojjCXUqLOGvr7IGtS9Tmr2bxpuS7oIf82FeCs=; b=IldK/Q6I/3ybrXLPDfKJFrpjFhDSm0hUb2giguonlPIvDByas1VIA0s9Zn8tqoW3d+sVNLov3CsboGexnY3hus/agw0dcyL6hJJW02plCNz57UVveTUp+fCr7eaD7I7K96vzFHzHsr9HYf+yZRgCnEBYQAHRQVI2sUPwGZrdJrw= 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 1699365054197225.4472948168824; Tue, 7 Nov 2023 05:50:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0MS9-00084e-MP; Tue, 07 Nov 2023 08:49:13 -0500 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 1r0MRs-0007rw-NX for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:01 -0500 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 1r0MRq-0007Lb-Lw for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:48:55 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-384-8Et6M9YVNS-zPsXodcEeVw-1; Tue, 07 Nov 2023 08:48:52 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D1C43C0021E for ; Tue, 7 Nov 2023 13:48:51 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5DCC1C00060; Tue, 7 Nov 2023 13:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699364933; 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=AA67E7ojjCXUqLOGvr7IGtS9Tmr2bxpuS7oIf82FeCs=; b=Q52+LP22PbEvoO8VbL1b7LvA7j0GBXworWkruHq237PieBljD/aYkLHkbRaNkHwe9d+DtI d98jM8fUJDZWT5e/HjWaKuwytQVQTdj4y2zM+zkO7N3kRB1Fv6hn729n/upWDJphoEljgn wnql4Hr+X+Kt3YHwfImo43O1R0wSHbM= X-MC-Unique: 8Et6M9YVNS-zPsXodcEeVw-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com Subject: [PULL 07/11] hw/arm/xlnx-versal: Use qdev_prop_set_array() Date: Tue, 7 Nov 2023 14:48:24 +0100 Message-ID: <20231107134828.35909-8-kwolf@redhat.com> In-Reply-To: <20231107134828.35909-1-kwolf@redhat.com> References: <20231107134828.35909-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1699365056158100003 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 Message-ID: <20231030142658.182193-9-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- 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 4f74a64a0d..9600551c44 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 Wed Nov 27 09:53: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=1699365017; cv=none; d=zohomail.com; s=zohoarc; b=I4O3XU4zekhtBAzEH3eXcw4UY2Sw4RSxEIyvpaGklOBV5OottzNefkT8z2meBZQJWy6yDuBRV7myFiUTYo907TFNeezrdmpE47mKvCDqQhT0P219lD3IYah7HxjXB2dMUXmcD2+BXF51zM4KCpDYL5C7PP6wyAmoFXShpX9keLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699365017; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mhVG8ozxTYftc0Jozia3MkEJPxYJKBz8YJ/vINgEQks=; b=BoZ24I1yjXvjfknE31ytlVpkGYD/S5SMvdqAqeR8teWeDHAGSsTg4lo+yiUd2l7KnTbS3UslUVrX6IjFVNQoJ7ig1GejsRDyX7K2LYAeCH8SMcBlhKVzR2UIP/0pMbOg1v0fJ3TZjKG4PLpa3KwA8AgWVOKJWkgTkNCPvUwBbBA= 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 1699365017710907.7599222086985; Tue, 7 Nov 2023 05:50:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0MSB-0008C6-Gi; Tue, 07 Nov 2023 08:49:15 -0500 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 1r0MRy-0007tt-If for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:03 -0500 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 1r0MRw-0007MR-6A for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:02 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-543-c2nr0kZQPNGEcDfUFsD_OQ-1; Tue, 07 Nov 2023 08:48:57 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DEAC22803023 for ; Tue, 7 Nov 2023 13:48:51 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6128E1C060C2; Tue, 7 Nov 2023 13:48:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699364939; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mhVG8ozxTYftc0Jozia3MkEJPxYJKBz8YJ/vINgEQks=; b=QHzpLNJ//pu1yn0+QCXygL0FMtf5lAEOwXBUnR1+XZ3uwCwawC1/AGpwYqzQpP43jsEUGv TfXo91LAV2ZB/lIKNFtMQEtUl7dCx1e0bkm3QE/QAmhbZYPdOI06d2ByqqMtfAUbm60swO rYNBH1ORDmtMXv/XEuRx+yD5GxGRH2o= X-MC-Unique: c2nr0kZQPNGEcDfUFsD_OQ-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com Subject: [PULL 08/11] hw/rx/rx62n: Use qdev_prop_set_array() Date: Tue, 7 Nov 2023 14:48:25 +0100 Message-ID: <20231107134828.35909-9-kwolf@redhat.com> In-Reply-To: <20231107134828.35909-1-kwolf@redhat.com> References: <20231107134828.35909-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1699365018008100001 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 Message-ID: <20231030142658.182193-10-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- 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 d00fcb0ef0..4dc44afd9d 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(DEVICE(icu), "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(DEVICE(icu), "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 Wed Nov 27 09:53: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=1699365062; cv=none; d=zohomail.com; s=zohoarc; b=kYboWRu+S9d0RR6ooF1pbZ3/sT8zVv0/3QDguGOF6rlJLLSLI4rzjZQ1jthgBOxNQxgX6ZGEgTmJSknnuNlIQmm54R9kCGm3p6lmf9WdDKMQYmFENvK1nlZMRDY4dl3cfYvJURr5kY3v64apSRfWOm0htJ6aTWn16CjRSoFkbaU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699365062; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WVclUr8dSQzAq2CqSXcZEndcCdvkQtncYA0IP2ciocw=; b=mgsw9oz+NpOUwbO74pcAGHFJdyUA88uR91JpSBZL7hVCY14wgy7ruz/DoFVs9uLD10LUHMpSe1ieGJSu5oSgC7EzIkqeazvqRxNNJICe/mib5H67xG8hDP6zMnp7xpCYw+3OrS9X3tekxonm/E8WSg68VoJgwn2HaXTkyIg629U= 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 169936506291287.060952835163; Tue, 7 Nov 2023 05:51:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0MSC-0008E6-0t; Tue, 07 Nov 2023 08:49:16 -0500 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 1r0MS6-0007yi-6q for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:11 -0500 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 1r0MRw-0007MF-DD for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:04 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-104-ytMzj34nMSKWWylO6PbmFQ-1; Tue, 07 Nov 2023 08:48:52 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC3FE1DD35C0 for ; Tue, 7 Nov 2023 13:48:52 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E4141C060BE; Tue, 7 Nov 2023 13:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699364938; 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=WVclUr8dSQzAq2CqSXcZEndcCdvkQtncYA0IP2ciocw=; b=h3t1pnHH0x11NPTbIILCBwP0otTbwqoKm5ykJ/kq/FPtUrLhuxWFUwlu6n/oNgdB/1vIfV GyaN43VtRnOP9ZaaeKhHOmTYsZOX3YneAHPNkIlzUI70ILGp23sfZrmwpFHpVoZke2lDEi Pqmh3HhiDcRe/aNzBh2G3pMWXITgreo= X-MC-Unique: ytMzj34nMSKWWylO6PbmFQ-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com Subject: [PULL 09/11] qom: Add object_property_set_default_list() Date: Tue, 7 Nov 2023 14:48:26 +0100 Message-ID: <20231107134828.35909-10-kwolf@redhat.com> In-Reply-To: <20231107134828.35909-1-kwolf@redhat.com> References: <20231107134828.35909-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1699365064196100001 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 Message-ID: <20231030142658.182193-11-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- 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 8557fe8e4e..95c0dc8285 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" @@ -1588,6 +1589,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 Wed Nov 27 09:53: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=1699365021; cv=none; d=zohomail.com; s=zohoarc; b=lWyDydI/Vn6+prFLWtoPrZhTiTNPeJMNRPwrxhp5Y6iKANcnag/vrxPn+07EmQoH78QibbzFGrYiRf4Hm+YKHHtl36DA4K6ROqMkT9Qtz3TFVLd5FisWzspU/EDksfSZhMk6joZmEaf1GtNKRs/9vsZEd8ks8TDeJebRkoF4jTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699365021; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=j6uzFlbktyVba/3T1STvsjngwIV89c8c8UysbVWjgkI=; b=PKQTYLczdytV0mMFSXFVIfvBtQJon+qQP88zA6kQZPKQl2cK8/9/NaTHiCgah5TRD9rfGDpjRU4oTyhM7+nlXhz9ZRL4Y7Sf6XO6WXtG2UFWN/S+TGEKKhFcplJ3JWRKvcFDCeZAl4rMgGq62BvQpuOLdr3TY18kZDm7xQEsGtg= 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 169936502171186.27680047658089; Tue, 7 Nov 2023 05:50:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0MSE-0008MN-76; Tue, 07 Nov 2023 08:49:19 -0500 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 1r0MSA-0008AZ-FH for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:14 -0500 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 1r0MS8-0007Rg-4D for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:14 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-332-FtsfTN0xMnGL29CUkyyEvg-1; Tue, 07 Nov 2023 08:49:10 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5F8B880D2C3 for ; Tue, 7 Nov 2023 13:48:53 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFEF91C060BE; Tue, 7 Nov 2023 13:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699364951; 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=j6uzFlbktyVba/3T1STvsjngwIV89c8c8UysbVWjgkI=; b=YPLDU9K4JopOlJmmHSbrRmpOj1e19kSrTED5mzWbPDJE8gcLTWVwWuV5ZYLzdJ04Dp929h GWMVuHmj2+b9pqWusyMRzqDf86A1YmqfHDGoAfhyitNyHCpBNY39/E/8LJOnH/8LbKzeLp fnpHQz7nVMyrmHwlECbyRGihOXhff8s= X-MC-Unique: FtsfTN0xMnGL29CUkyyEvg-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com Subject: [PULL 10/11] qdev: Make netdev properties work as list elements Date: Tue, 7 Nov 2023 14:48:27 +0100 Message-ID: <20231107134828.35909-11-kwolf@redhat.com> In-Reply-To: <20231107134828.35909-1-kwolf@redhat.com> References: <20231107134828.35909-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1699365022015100001 Content-Type: text/plain; charset="utf-8" The 'name' parameter of QOM setters is primarily used to specify the name of the currently parsed input element in the visitor interface. For top-level qdev properties, this is always set and matches 'prop->name'. However, for list elements it is NULL, because each element of a list doesn't have a separate name. Passing a non-NULL value runs into assertion failures in the visitor code. Therefore, using 'name' in error messages is not right for property types that are used in lists, because "(null)" (or even a segfault) isn't very helpful to identify what QEMU is complaining about. Change netdev properties to use 'prop->name' instead, which will contain the name of the array property after switching array properties to lists in the external interface. (This is still not perfect, as it doesn't identify which element in the list caused the error, but strictly better than before.) Signed-off-by: Kevin Wolf Message-ID: <20231030142658.182193-12-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- hw/core/qdev-properties-system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index b46d16cd2c..1473ab3d5e 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 --=20 2.41.0 From nobody Wed Nov 27 09:53: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=1699365094; cv=none; d=zohomail.com; s=zohoarc; b=m0zpBw9i8pyc1sRoet+tf2NXjLTZPNslhmwQu5Vi4armRuUlub40ij+JQsNV34XJRjC/udEf217TlW+HaWwlR1Vi4NPaE9XqV6I8v33NdjXI+pfc04e0J6kayAE4qNU/OSMoD0pSih/H8aHgfkJek1mmKWMOFMXqrLwjnetZMaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699365094; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sSv2i15i579/KCuDTINwxGQbK6Z9nfCzTYTS3zqF80o=; b=PXqXqhxzbQlgR3Qi+qPcp16laGfphVUJyM5Pxn+FQY8KgaMm1ohwlKU5uOGXsBRH+SLpM5gdql0skSpxDPYbYrzgCLJJFp9j8lm6mDwEre4wp0bi1zxtJjnJFDCJG4jIlO3OVcIfBLJ+oyIRepWc2Gv6xvW8g2b/1SDRZelT1OM= 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 1699365094255419.4982504601736; Tue, 7 Nov 2023 05:51:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0MSA-00086j-1H; Tue, 07 Nov 2023 08:49:14 -0500 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 1r0MS6-0007yh-5h for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:11 -0500 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 1r0MRy-0007Nj-Ja for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:49:06 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-625-yxCgfQ26MVaUd7_pfQQADg-1; Tue, 07 Nov 2023 08:48:54 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1569B811001 for ; Tue, 7 Nov 2023 13:48:54 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id 932BA1C060AE; Tue, 7 Nov 2023 13:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699364941; 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=sSv2i15i579/KCuDTINwxGQbK6Z9nfCzTYTS3zqF80o=; b=Yj4uWUkSuNxO0tU+SlSyWsjmWRyM6SdehvbuwMrBPo0oW9j3bO8n2C4XJwCFpC1NsdyHdI DdkLoH2z6rY2OwTzhpCplyPBxhx8TWHg2XOv41f5ba42YyTyOtHTEC+12xhBF58YWjCL1w i8S+Rx+JiMAYgt+fs7WTGEkpRR8/vFo= X-MC-Unique: yxCgfQ26MVaUd7_pfQQADg-1 From: Kevin Wolf To: qemu-devel@nongnu.org Cc: kwolf@redhat.com Subject: [PULL 11/11] qdev: Rework array properties based on list visitor Date: Tue, 7 Nov 2023 14:48:28 +0100 Message-ID: <20231107134828.35909-12-kwolf@redhat.com> In-Reply-To: <20231107134828.35909-1-kwolf@redhat.com> References: <20231107134828.35909-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1699365096311100006 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, which used to be configured like this: -device rocker,len-ports=3D2,ports[0]=3Ddev0,ports[1]=3Ddev1 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. The new syntax looks like this: -device '{"driver":"rocker","ports":["dev0","dev1"]}' 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 Message-ID: <20231030142658.182193-13-kwolf@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Kevin Wolf --- include/hw/qdev-properties.h | 57 +++++---- hw/core/qdev-properties.c | 224 ++++++++++++++++++++++------------- 2 files changed, 181 insertions(+), 100 deletions(-) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 7fa2fdb7c9..256d9e5024 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -2,6 +2,7 @@ #define QEMU_QDEV_PROPERTIES_H =20 #include "hw/qdev-core.h" +#include "qapi/visitor.h" =20 /** * Property: @@ -61,7 +62,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 +116,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,28 +126,46 @@ 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() and to have an alig= nment + * such that it can be stored at GenericList.padding. * - * 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, \ - .set_default =3D true, \ - .defval.u =3D 0, \ - .arrayinfo =3D &(_arrayprop), \ - .arrayfieldsize =3D sizeof(_arraytype), \ +#define DEFINE_PROP_ARRAY(_name, _state, _field, \ + _arrayfield, _arrayprop, _arraytype) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_array, uint32_t, \ + .set_default =3D true, \ + .defval.u =3D 0, \ + .arrayinfo =3D &(_arrayprop), \ + /* \ + * set_prop_array() temporarily stores elements at \ + * GenericList.padding. Make sure that this has the \ + * right alignment for @_arraytype. \ + * \ + * Hack: In this place, neither static assertions work \ + * nor is a statement expression allowed. This \ + * abomination of an expression works because inside \ + * the declaration of a dummy struct, static assertions \ + * are possible. Using the comma operator causes \ + * warnings about an unused value and casting to void \ + * makes the expression not constant in gcc, so instead \ + * of ignoring the first part, make it evaluate to 0 \ + * and add it to the actual result. \ + */ \ + .arrayfieldsize =3D (!sizeof(struct { \ + QEMU_BUILD_BUG_ON( \ + !QEMU_IS_ALIGNED(sizeof(GenericList), \ + __alignof__(_arraytype))); \ + int dummy; \ + }) + sizeof(_arraytype)), \ .arrayoffset =3D offsetof(_state, _arrayfield)) =20 #define DEFINE_PROP_LINK(_name, _state, _field, _type, _ptr_type) \ diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 950ef48e01..4f3e1152be 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -546,98 +546,174 @@ 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. +/* + * Given an array property @parent_prop in @obj, return a Property for a + * specific element of the array. Arrays are backed by an uint32_t length = field + * and an element array. @elem points at an element in this element array. */ -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 (uintptr_t)elem - (uintptr_t)obj, + }; +} + +/* + * Object property release callback for array properties: We call the + * underlying 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; + + if (!prop->arrayinfo->release) { + return; + } + + 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 pointer to which is stored in the additional field described by + * prop->arrayoffset). + */ +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; + } + if (*alenptr =3D=3D INT_MAX) { + error_setg(errp, "array is too big"); + return; + } + (*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) { + Property elem_prop =3D array_elem_prop(obj, prop, name, + elem->padding); + if (prop->arrayinfo->release) { + prop->arrayinfo->release(obj, NULL, &elem_prop); + } + 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; + bool ok; + + 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; + } + + /* visit_check_list() can only fail for input visitors */ + ok =3D visit_check_list(v, errp); + assert(ok); + +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 +819,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