From nobody Sat Nov 23 21:35:59 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 ARC-Seal: i=1; a=rsa-sha256; t=1731275875; cv=none; d=zohomail.com; s=zohoarc; b=FvSuT+XHrS7/HwWZV+5fdp41tWcoaq7n3FT+CHMXfOR2RO3kykaxB1eU5tL8qCkWnDiZMkUk47JCkP+8r1saeH+NYslyjZVPkD/9Vwoxr2zRPbwJczulcN4QtLLhkKd6RwcFRbfQj439+n+fgwb1Xt77KdZACSRqi2lCeL9AtAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731275875; 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=lOADvMyilhJdl701XbZfD35fREWVUG8E1q7FxctgBFw=; b=FW2qRuqP8a1s6r52KvD4qVgp3NtMobU3TrgGUHNwqYChwdR1Ms+NjMFj1YXn9UL9I7lJZwOxA2MtUmLd1nqHLdqde9RIGNStgHSfQcZpLUbqz0AvxA50GFlxuGJuc4jkEMUQdXqErelHsrfitBg1fX+5NWLAs6xAeLlgyKLrgIU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 173127587516280.22097269907295; Sun, 10 Nov 2024 13:57:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tAFuf-00047r-Ma; Sun, 10 Nov 2024 16:56:05 -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 1tAFuc-00043U-Ln for qemu-devel@nongnu.org; Sun, 10 Nov 2024 16:56:02 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tAFuZ-00047l-Kq for qemu-devel@nongnu.org; Sun, 10 Nov 2024 16:56:02 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4315eeb2601so49803355e9.2 for ; Sun, 10 Nov 2024 13:55:59 -0800 (PST) Received: from localhost.localdomain (h082218084190.host.wavenet.at. [82.218.84.190]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9ee0e2f731sm523715566b.189.2024.11.10.13.55.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 10 Nov 2024 13:55:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1731275758; x=1731880558; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lOADvMyilhJdl701XbZfD35fREWVUG8E1q7FxctgBFw=; b=lxmIonQ3lcNmfp89UHOe9Enb8MUEHKEl9x0mwCNW2/G4KBMEOhJr4qv4uu02OGgh+N P+sZXJkqVi+UKdLsSIIw6Q20RxoYX6hXvY7ONm7HmWjUKPmwvtatHPSPVYqWQuQ0jLxE gK3x9eKlrv1SFIjRL7mTilsCJLaXEi5Qq1CeVuCwu7llF5BzZjKpTW662cZ1iJTg9pTY 7cxkBc5RDZAiqZYVr8777lHebrnmq4GA9LsxkjHnuDcSZWFjIQslHtBf0t9rPoRRBNV8 r+gYx8rFweXLbJa3ywqlWKtVCWB7vhDQcy3Rnjew6t2Q0sWw1zGw7NLSIP8nZ+5ko4qT mU0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731275758; x=1731880558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lOADvMyilhJdl701XbZfD35fREWVUG8E1q7FxctgBFw=; b=uTS+NaINxE6+mCzMKyh1ao8chQ5Svt+Xru7604KIhXSkZVHgal0WpVsVj0wSXrDltO fvd5r48cfI4XTDiRyHaloBl0zNAx6hYn0ngJyi/WutsooooLQq1e6BPlBSiYJUnue7af c4co/3E6nThehwWAsN7anOBO6JnDdRrcH2nQzPjX84v/fIOTxLQG5X1v5Nsitvm4Lepl oDM3uB4ebHX0yFzEzgY3Jel4YPno5MLbVMi2nEf7Y89uj91WiNihaJg8kgqjSDMM+3Qo 9NsIaElkumSJ2EVNHa9yRbrA1mkJYofpNnDNcL1a6VzibTWadf1cyxR3SxvOR9S9d6I6 2Vew== X-Gm-Message-State: AOJu0YyGgKY2HuWRWiuyF3PwgOGeXXFmsmy0XdpWnGA/YtVPkTuFVCiF TnR+xg60nbpwKBeUku5xX+QzOWLdJBfYY8IpZIrZXG4DiGPXTSbakEeEBc4AAsn2/AAUh/ZQs6U 6DQ== X-Google-Smtp-Source: AGHT+IEFbjiiwU9zB8jMymdr+GwT/4fjVFw9eHeb3I77suCfG08PD3RNZXvd0DtQ9MK7JtI5WhgbKg== X-Received: by 2002:a05:6000:385:b0:37d:4a16:81d7 with SMTP id ffacd0b85a97d-381f1866abfmr10417155f8f.8.1731275758104; Sun, 10 Nov 2024 13:55:58 -0800 (PST) From: Phil Dennis-Jordan To: qemu-devel@nongnu.org Cc: agraf@csgraf.de, phil@philjordan.eu, peter.maydell@linaro.org, pbonzini@redhat.com, rad@semihalf.com, quic_llindhol@quicinc.com, stefanha@redhat.com, mst@redhat.com, slp@redhat.com, richard.henderson@linaro.org, eduardo@habkost.net, marcel.apfelbaum@gmail.com, gaosong@loongson.cn, jiaxun.yang@flygoat.com, chenhuacai@kernel.org, kwolf@redhat.com, hreitz@redhat.com, philmd@linaro.org, shorne@gmail.com, palmer@dabbelt.com, alistair.francis@wdc.com, bmeng.cn@gmail.com, liwei1518@gmail.com, dbarboza@ventanamicro.com, zhiwei_liu@linux.alibaba.com, jcmvbkbc@gmail.com, marcandre.lureau@redhat.com, berrange@redhat.com, akihiko.odaki@daynix.com, qemu-arm@nongnu.org, qemu-block@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v9 16/16] hw/vmapple/virtio-blk: Replace variant types with property on base Date: Sun, 10 Nov 2024 22:55:19 +0100 Message-Id: <20241110215519.49150-17-phil@philjordan.eu> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20241110215519.49150-1-phil@philjordan.eu> References: <20241110215519.49150-1-phil@philjordan.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: neutral client-ip=2a00:1450:4864:20::32d; envelope-from=phil@philjordan.eu; helo=mail-wm1-x32d.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 autolearn=no 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 @philjordan-eu.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1731275876731116600 Content-Type: text/plain; charset="utf-8" This reduces the type hierarchy of the vmapple-virtio-blk-pci-base type and vmapple-virtio-root/vmapple-virtio-aux leaf types with a single vmapple-virtio-blk-pci type which exposes a 'variant' enum property which can be set to 'aux' or 'root'. This change removes a bunch of device type boilerplate at the cost of defining a new qapi enum and qdev property type. Documentation for the vmapple machine type is also updated. Signed-off-by: Phil Dennis-Jordan --- docs/system/arm/vmapple.rst | 4 +-- hw/core/qdev-properties-system.c | 8 +++++ hw/vmapple/virtio-blk.c | 50 +++++++---------------------- include/hw/qdev-properties-system.h | 6 ++++ include/hw/vmapple/vmapple.h | 4 +-- qapi/virtio.json | 14 ++++++++ 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/docs/system/arm/vmapple.rst b/docs/system/arm/vmapple.rst index 67942474b93..efe39b68dc4 100644 --- a/docs/system/arm/vmapple.rst +++ b/docs/system/arm/vmapple.rst @@ -56,8 +56,8 @@ to get better interactive access into the target system: -drive file=3D"$DISK",if=3Dpflash,format=3Draw \ -drive file=3D"$AUX",if=3Dnone,id=3Daux,format=3Draw \ -drive file=3D"$DISK",if=3Dnone,id=3Droot,format=3Draw \ - -device vmapple-virtio-aux,drive=3Daux \ - -device vmapple-virtio-root,drive=3Droot \ + -device vmapple-virtio-blk-pci,variant=3Daux,drive=3Daux \ + -device vmapple-virtio-blk-pci,variant=3Droot,drive=3Droot \ -netdev user,id=3Dnet0,ipv6=3Doff,hostfwd=3Dtcp::2222-:22,hostfwd= =3Dtcp::5901-:5900 \ -device virtio-net-pci,netdev=3Dnet0 =20 diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index 35deef05f32..8bf8a3442d6 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -1239,3 +1239,11 @@ const PropertyInfo qdev_prop_iothread_vq_mapping_lis= t =3D { .set =3D set_iothread_vq_mapping_list, .release =3D release_iothread_vq_mapping_list, }; + +const PropertyInfo qdev_prop_vmapple_virtio_blk_variant =3D { + .name =3D "VMAppleVirtioBlkVariant", + .enum_table =3D &VMAppleVirtioBlkVariant_lookup, + .get =3D qdev_propinfo_get_enum, + .set =3D qdev_propinfo_set_enum, + .set_default_value =3D qdev_propinfo_set_default_value_enum, +}; diff --git a/hw/vmapple/virtio-blk.c b/hw/vmapple/virtio-blk.c index 40b33bbdac5..f883e65a5de 100644 --- a/hw/vmapple/virtio-blk.c +++ b/hw/vmapple/virtio-blk.c @@ -24,6 +24,7 @@ #include "qemu/module.h" #include "qapi/error.h" =20 +#define TYPE_VMAPPLE_VIRTIO_BLK "vmapple-virtio-blk" OBJECT_DECLARE_TYPE(VMAppleVirtIOBlk, VMAppleVirtIOBlkClass, VMAPPLE_VIRTI= O_BLK) =20 typedef struct VMAppleVirtIOBlkClass { @@ -41,14 +42,10 @@ typedef struct VMAppleVirtIOBlk { /* * vmapple-virtio-blk-pci: This extends VirtioPCIProxy. */ -#define TYPE_VMAPPLE_VIRTIO_BLK_PCI "vmapple-virtio-blk-pci-base" OBJECT_DECLARE_SIMPLE_TYPE(VMAppleVirtIOBlkPCI, VMAPPLE_VIRTIO_BLK_PCI) =20 #define VIRTIO_BLK_T_APPLE_BARRIER 0x10000 =20 -#define VIRTIO_APPLE_TYPE_ROOT 1 -#define VIRTIO_APPLE_TYPE_AUX 2 - static bool vmapple_virtio_blk_handle_unknown_request(VirtIOBlockReq *req, MultiReqBuffer *mrb, uint32_t type) @@ -109,7 +106,7 @@ static const TypeInfo vmapple_virtio_blk_info =3D { struct VMAppleVirtIOBlkPCI { VirtIOPCIProxy parent_obj; VMAppleVirtIOBlk vdev; - uint32_t apple_type; + VMAppleVirtioBlkVariant variant; }; =20 =20 @@ -119,6 +116,8 @@ static Property vmapple_virtio_blk_pci_properties[] =3D= { VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, DEV_NVECTORS_UNSPECIFIED), + DEFINE_PROP_VMAPPLE_VIRTIO_BLK_VARIANT("variant", VMAppleVirtIOBlkPCI,= variant, + VM_APPLE_VIRTIO_BLK_VARIANT_UNS= PECIFIED), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -128,6 +127,12 @@ static void vmapple_virtio_blk_pci_realize(VirtIOPCIPr= oxy *vpci_dev, Error **err DeviceState *vdev =3D DEVICE(&dev->vdev); VirtIOBlkConf *conf =3D &dev->vdev.parent_obj.conf; =20 + if (dev->variant =3D=3D VM_APPLE_VIRTIO_BLK_VARIANT_UNSPECIFIED) { + error_setg(errp, "Device " TYPE_VMAPPLE_VIRTIO_BLK_PCI ": must spe= cify " + "a variant, 'aux' or 'root'"); + return; + } + if (conf->num_queues =3D=3D VIRTIO_BLK_AUTO_NUM_QUEUES) { conf->num_queues =3D virtio_pci_optimal_num_queues(0); } @@ -143,7 +148,7 @@ static void vmapple_virtio_blk_pci_realize(VirtIOPCIPro= xy *vpci_dev, Error **err */ virtio_add_feature(&dev->vdev.parent_obj.host_features, VIRTIO_BLK_F_Z= ONED); /* Propagate the apple type down to the virtio-blk device */ - dev->vdev.apple_type =3D dev->apple_type; + dev->vdev.apple_type =3D dev->variant; /* and spawn the virtio-blk device */ qdev_realize(vdev, BUS(&vpci_dev->bus), errp); =20 @@ -181,47 +186,16 @@ static void vmapple_virtio_blk_pci_instance_init(Obje= ct *obj) } =20 static const VirtioPCIDeviceTypeInfo vmapple_virtio_blk_pci_info =3D { - .base_name =3D TYPE_VMAPPLE_VIRTIO_BLK_PCI, - .generic_name =3D "vmapple-virtio-blk-pci", + .generic_name =3D TYPE_VMAPPLE_VIRTIO_BLK_PCI, .instance_size =3D sizeof(VMAppleVirtIOBlkPCI), .instance_init =3D vmapple_virtio_blk_pci_instance_init, .class_init =3D vmapple_virtio_blk_pci_class_init, }; =20 -static void vmapple_virtio_root_instance_init(Object *obj) -{ - VMAppleVirtIOBlkPCI *dev =3D VMAPPLE_VIRTIO_BLK_PCI(obj); - - dev->apple_type =3D VIRTIO_APPLE_TYPE_ROOT; -} - -static const TypeInfo vmapple_virtio_root_info =3D { - .name =3D TYPE_VMAPPLE_VIRTIO_ROOT, - .parent =3D "vmapple-virtio-blk-pci", - .instance_size =3D sizeof(VMAppleVirtIOBlkPCI), - .instance_init =3D vmapple_virtio_root_instance_init, -}; - -static void vmapple_virtio_aux_instance_init(Object *obj) -{ - VMAppleVirtIOBlkPCI *dev =3D VMAPPLE_VIRTIO_BLK_PCI(obj); - - dev->apple_type =3D VIRTIO_APPLE_TYPE_AUX; -} - -static const TypeInfo vmapple_virtio_aux_info =3D { - .name =3D TYPE_VMAPPLE_VIRTIO_AUX, - .parent =3D "vmapple-virtio-blk-pci", - .instance_size =3D sizeof(VMAppleVirtIOBlkPCI), - .instance_init =3D vmapple_virtio_aux_instance_init, -}; - static void vmapple_virtio_blk_register_types(void) { type_register_static(&vmapple_virtio_blk_info); virtio_pci_types_register(&vmapple_virtio_blk_pci_info); - type_register_static(&vmapple_virtio_root_info); - type_register_static(&vmapple_virtio_aux_info); } =20 type_init(vmapple_virtio_blk_register_types) diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properti= es-system.h index cdcc63056e5..6e428f3fcad 100644 --- a/include/hw/qdev-properties-system.h +++ b/include/hw/qdev-properties-system.h @@ -27,6 +27,8 @@ extern const PropertyInfo qdev_prop_pcie_link_speed; extern const PropertyInfo qdev_prop_pcie_link_width; extern const PropertyInfo qdev_prop_cpus390entitlement; extern const PropertyInfo qdev_prop_iothread_vq_mapping_list; +extern const PropertyInfo qdev_prop_vmapple_virtio_blk_variant; + =20 #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) @@ -94,4 +96,8 @@ extern const PropertyInfo qdev_prop_iothread_vq_mapping_l= ist; DEFINE_PROP(_name, _state, _field, qdev_prop_iothread_vq_mapping_list,= \ IOThreadVirtQueueMappingList *) =20 +#define DEFINE_PROP_VMAPPLE_VIRTIO_BLK_VARIANT(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_vmapple_virtio_blk_varian= t, \ + VMAppleVirtioBlkVariant) + #endif diff --git a/include/hw/vmapple/vmapple.h b/include/hw/vmapple/vmapple.h index b20956e1286..9c1ad1bd8c3 100644 --- a/include/hw/vmapple/vmapple.h +++ b/include/hw/vmapple/vmapple.h @@ -18,8 +18,6 @@ =20 #define TYPE_VMAPPLE_CFG "vmapple-cfg" =20 -#define TYPE_VMAPPLE_VIRTIO_BLK "vmapple-virtio-blk" -#define TYPE_VMAPPLE_VIRTIO_ROOT "vmapple-virtio-root" -#define TYPE_VMAPPLE_VIRTIO_AUX "vmapple-virtio-aux" +#define TYPE_VMAPPLE_VIRTIO_BLK_PCI "vmapple-virtio-blk-pci" =20 #endif /* HW_VMAPPLE_VMAPPLE_H */ diff --git a/qapi/virtio.json b/qapi/virtio.json index 2529c2d8b20..d351d2166ef 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -992,3 +992,17 @@ ## { 'enum': 'GranuleMode', 'data': [ '4k', '8k', '16k', '64k', 'host' ] } + +## +# @VMAppleVirtioBlkVariant: +# +# @unspecified: The default, not a valid setting. +# +# @root: Block device holding the root volume +# +# @aux: Block device holding auxiliary data required for boot +# +# Since: 9.2 +## +{ 'enum': 'VMAppleVirtioBlkVariant', + 'data': [ 'unspecified', 'root', 'aux' ] } --=20 2.39.3 (Apple Git-145)