Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D3E1606A324 for ; Sun, 1 Nov 2026 20:23:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KuI7ChcN Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xNc2I-0002BM-Kv; Sun, 01 Nov 2026 15:20:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNbzs-00052Z-Ce for qemu-devel@nongnu.org; Sun, 01 Nov 2026 15:17:44 -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 1xNbzg-0007DL-48 for qemu-devel@nongnu.org; Sun, 01 Nov 2026 15:17:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793564251; 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=zOS9y0YqTxn2phsAqv9j41s9qyi20VmW9wn8ndp4of0=; b=KuI7ChcNGt8y/mwbmskYT30GXy7Fh/TRsn5L/4b2Zf4gzZT4ScWjY915L5aVwExu1eCFdE /cxQBLfdHr3qjQC1Pc4sbTzMjTqOkU2Kx8iSzWVmim3ND0J+Bpfxa9Ajz94F91pNXBvc86 nEe34oXW+qzLHLCV8Ka073np7mplCmU= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-1IWwMN0fN9iVn6KxF8b9PA-1; Sun, 01 Nov 2026 15:17:30 -0500 X-MC-Unique: 1IWwMN0fN9iVn6KxF8b9PA-1 X-Mimecast-MFC-AGG-ID: 1IWwMN0fN9iVn6KxF8b9PA_1793564249 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2A75E1954AE1 for ; Sun, 1 Nov 2026 20:17:29 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.2]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A4FAE7E6 for ; Sun, 1 Nov 2026 20:17:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7BAE421E683E; Sun, 01 Nov 2026 21:17:18 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, berrange@redhat.com Subject: [PATCH v8 48/56] qdev: convert system PropertyInfo definitions to use qapi_type Date: Sun, 1 Nov 2026 21:17:09 +0100 Message-ID: <20261101201717.3911097-49-armbru@redhat.com> In-Reply-To: <20261101201717.3911097-1-armbru@redhat.com> References: <20261101201717.3911097-1-armbru@redhat.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Marc-André Lureau Add a .qapi_type pointer on all PropertyInfo definitions in qdev-properties-system.c. Remove .enum_table from enum definitions, since the lookup is now accessed through .qapi_type->lookup via the qdev_propinfo_enum_lookup() fallback helper. Update file-private enum accessor functions to use .qapi_type->lookup instead of .enum_table. Note, this should be a faithful conversion, but it would be worth to consider better types than just "str" for references (block node names, chardev/netdev IDs, MAC addrs, etc) Signed-off-by: Marc-André Lureau Signed-off-by: Markus Armbruster --- hw/core/qdev-prop-internal.h | 2 + hw/core/qdev-properties-system.c | 71 +++++++++++++++++++++----------- hw/core/qdev-properties.c | 2 +- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/hw/core/qdev-prop-internal.h b/hw/core/qdev-prop-internal.h index d7b77844fe..c190b7b88c 100644 --- a/hw/core/qdev-prop-internal.h +++ b/hw/core/qdev-prop-internal.h @@ -8,6 +8,8 @@ #ifndef HW_CORE_QDEV_PROP_INTERNAL_H #define HW_CORE_QDEV_PROP_INTERNAL_H +const QEnumLookup *qdev_propinfo_enum_lookup(const PropertyInfo *info); + void qdev_propinfo_get_enum(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp); void qdev_propinfo_set_enum(Object *obj, Visitor *v, const char *name, diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 5bfdfe1ab9..8924f84806 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -27,6 +27,7 @@ #include "qemu/uuid.h" #include "qemu/error-report.h" #include "qdev-prop-internal.h" +#include "qapi/qapi-type-infos.h" #include "qemu/audio.h" #include "chardev/char-fe.h" @@ -239,6 +240,7 @@ static void release_drive(Object *obj, const char *name, void *opaque) const PropertyInfo qdev_prop_drive = { .type = "str", + .qapi_type = &str_type_info, .description = "Node name or ID of a block device to use as a backend", .realized_set_allowed = true, .get = get_drive, @@ -248,6 +250,7 @@ const PropertyInfo qdev_prop_drive = { const PropertyInfo qdev_prop_drive_iothread = { .type = "str", + .qapi_type = &str_type_info, .description = "Node name or ID of a block device to use as a backend", .realized_set_allowed = true, .get = get_drive, @@ -316,6 +319,7 @@ static void release_chr(Object *obj, const char *name, void *opaque) const PropertyInfo qdev_prop_chr = { .type = "str", + .qapi_type = &str_type_info, .description = "ID of a chardev to use as a backend", .get = get_chr, .set = set_chr, @@ -390,6 +394,7 @@ inval: const PropertyInfo qdev_prop_macaddr = { .type = "str", + .qapi_type = &str_type_info, .description = "Ethernet 6-byte MAC Address, example: 52:54:00:12:34:56", .get = get_mac, .set = set_mac, @@ -478,6 +483,7 @@ out: const PropertyInfo qdev_prop_netdev = { .type = "str", + .qapi_type = &str_type_info, .description = "ID of a netdev to use as a backend", .get = get_netdev, .set = set_netdev, @@ -515,6 +521,7 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name, const PropertyInfo qdev_prop_audiodev = { .type = "str", + .qapi_type = &str_type_info, .description = "ID of an audiodev to use as a backend", /* release done on shutdown */ .get = get_audiodev, @@ -584,7 +591,8 @@ static void qdev_propinfo_set_losttickpolicy(Object *obj, Visitor *v, int *ptr = object_field_prop_ptr(obj, prop); int value; - if (!visit_type_enum(v, name, &value, prop->info->enum_table, errp)) { + if (!visit_type_enum(v, name, &value, + qdev_propinfo_enum_lookup(prop->info), errp)) { return; } @@ -605,8 +613,8 @@ QEMU_BUILD_BUG_ON(sizeof(LostTickPolicy) != sizeof(int)); const PropertyInfo qdev_prop_losttickpolicy = { .type = "LostTickPolicy", + .qapi_type = &LostTickPolicy_type_info, .description = "Policy for handling lost ticks (discard/delay/slew)", - .enum_table = &LostTickPolicy_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_losttickpolicy, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -632,6 +640,7 @@ static void set_blocksize(Object *obj, Visitor *v, const char *name, const PropertyInfo qdev_prop_blocksize = { .type = "size", + .qapi_type = &size_type_info, .description = "A power of two between " MIN_BLOCK_SIZE_STR " and " MAX_BLOCK_SIZE_STR, .get = qdev_propinfo_get_size32, @@ -645,8 +654,8 @@ QEMU_BUILD_BUG_ON(sizeof(BlockdevOnError) != sizeof(int)); const PropertyInfo qdev_prop_blockdev_on_error = { .type = "BlockdevOnError", + .qapi_type = &BlockdevOnError_type_info, .description = "Error handling policy (report/ignore/enospc/stop/auto)", - .enum_table = &BlockdevOnError_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -658,9 +667,9 @@ QEMU_BUILD_BUG_ON(sizeof(BiosAtaTranslation) != sizeof(int)); const PropertyInfo qdev_prop_bios_chs_trans = { .type = "BiosAtaTranslation", + .qapi_type = &BiosAtaTranslation_type_info, .description = "Logical CHS translation algorithm " " (auto/none/lba/large/rechs)", - .enum_table = &BiosAtaTranslation_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -670,8 +679,8 @@ const PropertyInfo qdev_prop_bios_chs_trans = { const PropertyInfo qdev_prop_fdc_drive_type = { .type = "FloppyDriveType", + .qapi_type = &FloppyDriveType_type_info, .description = "Floppy drive type (144/288/120/none/auto)", - .enum_table = &FloppyDriveType_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -681,9 +690,9 @@ const PropertyInfo qdev_prop_fdc_drive_type = { const PropertyInfo qdev_prop_multifd_compression = { .type = "MultiFDCompression", + .qapi_type = &MultiFDCompression_type_info, .description = "multifd compression method" " (none/zlib/zstd/qpl/uadk/qatzip)", - .enum_table = &MultiFDCompression_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -695,8 +704,8 @@ QEMU_BUILD_BUG_ON(sizeof(MigMode) != sizeof(int)); const PropertyInfo qdev_prop_mig_mode = { .type = "MigMode", + .qapi_type = &MigMode_type_info, .description = "Migration mode (normal/cpr-reboot)", - .enum_table = &MigMode_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -708,8 +717,8 @@ QEMU_BUILD_BUG_ON(sizeof(GranuleMode) != sizeof(int)); const PropertyInfo qdev_prop_granule_mode = { .type = "GranuleMode", + .qapi_type = &GranuleMode_type_info, .description = "Granule page size (4k/8k/16k/64k/host)", - .enum_table = &GranuleMode_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -717,8 +726,8 @@ const PropertyInfo qdev_prop_granule_mode = { const PropertyInfo qdev_prop_zero_page_detection = { .type = "ZeroPageDetection", + .qapi_type = &ZeroPageDetection_type_info, .description = "Zero page detection (none/legacy/multifd)", - .enum_table = &ZeroPageDetection_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -730,8 +739,8 @@ QEMU_BUILD_BUG_ON(sizeof(SsidSizeMode) != sizeof(int)); const PropertyInfo qdev_prop_ssidsize_mode = { .type = "SsidSizeMode", + .qapi_type = &SsidSizeMode_type_info, .description = "ssidsize mode: auto, 0-20", - .enum_table = &SsidSizeMode_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -743,8 +752,8 @@ QEMU_BUILD_BUG_ON(sizeof(OasMode) != sizeof(int)); const PropertyInfo qdev_prop_oas_mode = { .type = "OasMode", + .qapi_type = &OasMode_type_info, .description = "oas mode: auto, 32, 36, 40, 42, 44, 48, 52, 56", - .enum_table = &OasMode_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -825,6 +834,7 @@ out: const PropertyInfo qdev_prop_reserved_region = { .type = "str", + .qapi_type = &str_type_info, .description = "Reserved Region, example: 0xFEE00000:0xFEEFFFFF:0", .get = get_reserved_region, .set = set_reserved_region, @@ -904,7 +914,16 @@ static char *print_pci_devfn(Object *obj, const Property *prop) } const PropertyInfo qdev_prop_pci_devfn = { + /* + * Both .type and .qapi_type are inaccurate. We actually accept + * string or integer. The natural QAPI type would be an + * alternate, but QAPI refuses this combination, because it + * wouldn't work with the QObject input keyval visitor. + * set_pci_devfn() bypasses this restriction by doing it manually. + * It can pick integer only with JSON input (QMP). + */ .type = "str", + .qapi_type = &int32_type_info, .description = "Slot and optional function number, example: 06.0 or 06", .print = print_pci_devfn, .get = qdev_propinfo_get_int32, @@ -1011,6 +1030,7 @@ inval: const PropertyInfo qdev_prop_pci_host_devaddr = { .type = "str", + .qapi_type = &str_type_info, .description = "Address (bus:device.function) of " "the host device, example: 04:10.0", .get = get_pci_host_devaddr, @@ -1021,8 +1041,8 @@ const PropertyInfo qdev_prop_pci_host_devaddr = { const PropertyInfo qdev_prop_off_auto_pcibar = { .type = "OffAutoPCIBAR", + .qapi_type = &OffAutoPCIBAR_type_info, .description = "off/auto/bar0/bar1/bar2/bar3/bar4/bar5", - .enum_table = &OffAutoPCIBAR_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -1061,7 +1081,8 @@ static void get_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name, abort(); } - visit_type_enum(v, name, &speed, prop->info->enum_table, errp); + visit_type_enum(v, name, &speed, + qdev_propinfo_enum_lookup(prop->info), errp); } static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name, @@ -1071,8 +1092,8 @@ static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name, PCIExpLinkSpeed *p = object_field_prop_ptr(obj, prop); int speed; - if (!visit_type_enum(v, name, &speed, prop->info->enum_table, - errp)) { + if (!visit_type_enum(v, name, &speed, + qdev_propinfo_enum_lookup(prop->info), errp)) { return; } @@ -1103,8 +1124,8 @@ static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name, const PropertyInfo qdev_prop_pcie_link_speed = { .type = "PCIELinkSpeed", + .qapi_type = &PCIELinkSpeed_type_info, .description = "2_5/5/8/16/32/64", - .enum_table = &PCIELinkSpeed_lookup, .get = get_prop_pcielinkspeed, .set = set_prop_pcielinkspeed, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -1146,7 +1167,8 @@ static void get_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name, abort(); } - visit_type_enum(v, name, &width, prop->info->enum_table, errp); + visit_type_enum(v, name, &width, + qdev_propinfo_enum_lookup(prop->info), errp); } static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name, @@ -1156,8 +1178,8 @@ static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name, PCIExpLinkWidth *p = object_field_prop_ptr(obj, prop); int width; - if (!visit_type_enum(v, name, &width, prop->info->enum_table, - errp)) { + if (!visit_type_enum(v, name, &width, + qdev_propinfo_enum_lookup(prop->info), errp)) { return; } @@ -1191,8 +1213,8 @@ static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name, const PropertyInfo qdev_prop_pcie_link_width = { .type = "PCIELinkWidth", + .qapi_type = &PCIELinkWidth_type_info, .description = "1/2/4/8/12/16/32", - .enum_table = &PCIELinkWidth_lookup, .get = get_prop_pcielinkwidth, .set = set_prop_pcielinkwidth, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -1241,6 +1263,7 @@ static void set_default_uuid_auto(ObjectProperty *op, const Property *prop) const PropertyInfo qdev_prop_uuid = { .type = "str", + .qapi_type = &str_type_info, .description = "UUID (aka GUID) or \"" UUID_VALUE_AUTO "\" for random value (default)", .get = get_uuid, @@ -1254,8 +1277,8 @@ QEMU_BUILD_BUG_ON(sizeof(S390CpuEntitlement) != sizeof(int)); const PropertyInfo qdev_prop_cpus390entitlement = { .type = "S390CpuEntitlement", + .qapi_type = &S390CpuEntitlement_type_info, .description = "auto/low/medium/high (default medium)", - .enum_table = &S390CpuEntitlement_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -1299,6 +1322,7 @@ static void release_iothread_vq_mapping_list(Object *obj, const PropertyInfo qdev_prop_iothread_vq_mapping_list = { .type = "IOThreadVirtQueueMappingList", + .qapi_type = &IOThreadVirtQueueMappingList_type_info, .description = "IOThread virtqueue mapping list [{\"iothread\":\"\", " "\"vqs\":[1,2,3,...]},...]", .get = get_iothread_vq_mapping_list, @@ -1310,8 +1334,8 @@ const PropertyInfo qdev_prop_iothread_vq_mapping_list = { const PropertyInfo qdev_prop_endian_mode = { .type = "EndianMode", + .qapi_type = &EndianMode_type_info, .description = "Endian mode, big/little/unspecified", - .enum_table = &EndianMode_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -1319,8 +1343,8 @@ const PropertyInfo qdev_prop_endian_mode = { const PropertyInfo qdev_prop_vmapple_virtio_blk_variant = { .type = "VMAppleVirtioBlkVariant", + .qapi_type = &VMAppleVirtioBlkVariant_type_info, .description = "unspecified/root/aux", - .enum_table = &VMAppleVirtioBlkVariant_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, @@ -1364,6 +1388,7 @@ static void release_virtio_gpu_output_list(Object *obj, const PropertyInfo qdev_prop_virtio_gpu_output_list = { .type = "VirtIOGPUOutputList", + .qapi_type = &VirtIOGPUOutputList_type_info, .description = "VirtIO GPU output list [{\"name\":\"\"},...]", .get = get_virtio_gpu_output_list, .set = set_virtio_gpu_output_list, diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index f891fc78ae..fb11eb1f1c 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -101,7 +101,7 @@ static ObjectPropertyAccessor *field_prop_setter(const PropertyInfo *info) return info->set ? field_prop_set : NULL; } -static const QEnumLookup *qdev_propinfo_enum_lookup(const PropertyInfo *info) +const QEnumLookup *qdev_propinfo_enum_lookup(const PropertyInfo *info) { if (info->qapi_type) { assert(info->qapi_type->lookup); -- 2.55.0