Convert all callers of object_class_property_add_enum() to use the new object_class_property_add_qapi_enum() with the QAPI_ENUM_PROP() macro, which provides type information via QAPITypeInfo instead of raw lookup tables and string type names.
This enables QMP introspection to report accurate QAPI type names for enum properties. Where a separate set_description call was used, the description is now embedded in the QAPI_ENUM_PROP initializer. Signed-off-by: Marc-André Lureau <[email protected]> --- authz/list.c | 12 +++++++----- backends/hostmem.c | 14 ++++++++------ crypto/secret_common.c | 12 +++++++----- crypto/tlscreds.c | 12 +++++++----- hw/i386/pc_piix.c | 19 +++++++++++++------ hw/microblaze/petalogix_s3adsp1800_mmu.c | 19 +++++++++++-------- net/filter.c | 10 +++++++--- target/i386/kvm/kvm.c | 30 +++++++++++++++++------------- ui/dbus.c | 10 +++++++--- ui/input-linux.c | 11 +++++++---- 10 files changed, 91 insertions(+), 58 deletions(-) diff --git a/authz/list.c b/authz/list.c index 17aa0efd80e..363b2ee12c9 100644 --- a/authz/list.c +++ b/authz/list.c @@ -22,6 +22,7 @@ #include "authz/list.h" #include "trace.h" #include "qom/object_interfaces.h" +#include "qapi/qapi-type-infos-authz.h" #include "qapi/qapi-visit-authz.h" #include "qemu/module.h" @@ -120,11 +121,12 @@ qauthz_list_class_init(ObjectClass *oc, const void *data) { QAuthZClass *authz = QAUTHZ_CLASS(oc); - object_class_property_add_enum(oc, "policy", - "QAuthZListPolicy", - &QAuthZListPolicy_lookup, - qauthz_list_prop_get_policy, - qauthz_list_prop_set_policy); + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "policy", + .qapi_type = &QAuthZListPolicy_type_info, + .get = qauthz_list_prop_get_policy, + .set = qauthz_list_prop_set_policy, + )); object_class_property_add(oc, "rules", "QAuthZListRule", qauthz_list_prop_get_rules, diff --git a/backends/hostmem.c b/backends/hostmem.c index cd2085fb3cd..d0977552b40 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -16,6 +16,7 @@ #include "hw/core/boards.h" #include "qapi/error.h" #include "qapi/qapi-builtin-visit.h" +#include "qapi/qapi-type-infos-common.h" #include "qapi/visitor.h" #include "qemu/config-file.h" #include "qom/compat-properties.h" @@ -548,12 +549,13 @@ host_memory_backend_class_init(ObjectClass *oc, const void *data) NULL, NULL); object_class_property_set_description(oc, "host-nodes", "Binds memory to the list of NUMA host nodes"); - object_class_property_add_enum(oc, "policy", "HostMemPolicy", - &HostMemPolicy_lookup, - host_memory_backend_get_policy, - host_memory_backend_set_policy); - object_class_property_set_description(oc, "policy", - "Set the NUMA policy"); + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "policy", + .description = "Set the NUMA policy", + .qapi_type = &HostMemPolicy_type_info, + .get = host_memory_backend_get_policy, + .set = host_memory_backend_set_policy, + )); object_class_property_add_bool(oc, "share", host_memory_backend_get_share, host_memory_backend_set_share); object_class_property_set_description(oc, "share", diff --git a/crypto/secret_common.c b/crypto/secret_common.c index a5ecb876aeb..381d23ecc8e 100644 --- a/crypto/secret_common.c +++ b/crypto/secret_common.c @@ -22,6 +22,7 @@ #include "crypto/secret_common.h" #include "crypto/cipher.h" #include "qapi/error.h" +#include "qapi/qapi-type-infos-crypto.h" #include "qom/object_interfaces.h" #include "qemu/base64.h" #include "qemu/module.h" @@ -269,11 +270,12 @@ qcrypto_secret_class_init(ObjectClass *oc, const void *data) ucc->complete = qcrypto_secret_complete; - object_class_property_add_enum(oc, "format", - "QCryptoSecretFormat", - &QCryptoSecretFormat_lookup, - qcrypto_secret_prop_get_format, - qcrypto_secret_prop_set_format); + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "format", + .qapi_type = &QCryptoSecretFormat_type_info, + .get = qcrypto_secret_prop_get_format, + .set = qcrypto_secret_prop_set_format, + )); object_class_property_add_str(oc, "keyid", qcrypto_secret_prop_get_keyid, qcrypto_secret_prop_set_keyid); diff --git a/crypto/tlscreds.c b/crypto/tlscreds.c index fb09e295a65..54859720bf7 100644 --- a/crypto/tlscreds.c +++ b/crypto/tlscreds.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-type-infos-crypto.h" #include "qapi-types-crypto.h" #include "qemu/module.h" #include "qemu/error-report.h" @@ -221,11 +222,12 @@ qcrypto_tls_creds_class_init(ObjectClass *oc, const void *data) object_class_property_add_str(oc, "dir", qcrypto_tls_creds_prop_get_dir, qcrypto_tls_creds_prop_set_dir); - object_class_property_add_enum(oc, "endpoint", - "QCryptoTLSCredsEndpoint", - &QCryptoTLSCredsEndpoint_lookup, - qcrypto_tls_creds_prop_get_endpoint, - qcrypto_tls_creds_prop_set_endpoint); + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "endpoint", + .qapi_type = &QCryptoTLSCredsEndpoint_type_info, + .get = qcrypto_tls_creds_prop_get_endpoint, + .set = qcrypto_tls_creds_prop_set_endpoint, + )); object_class_property_add_str(oc, "priority", qcrypto_tls_creds_prop_get_priority, qcrypto_tls_creds_prop_set_priority); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 82457bdb167..91a371b12d7 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -47,6 +47,7 @@ #include "hw/acpi/acpi.h" #include "hw/vfio/types.h" #include "qapi/error.h" +#include "qapi/qapi-type-info.h" #include "qemu/error-report.h" #include "system/xen.h" #ifdef CONFIG_XEN @@ -336,6 +337,11 @@ static const QEnumLookup PCSouthBridgeOption_lookup = { .size = PC_SOUTH_BRIDGE_OPTION_MAX }; +static const QAPITypeInfo PCSouthBridgeOption_type_info = { + .name = "PCSouthBridgeOption", + .lookup = &PCSouthBridgeOption_lookup, +}; + static int pc_get_south_bridge(Object *obj, Error **errp) { PCMachineState *pcms = PC_MACHINE(obj); @@ -418,12 +424,13 @@ static void pc_i440fx_machine_options(MachineClass *m) machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE); machine_class_allow_dynamic_sysbus_dev(m, TYPE_UEFI_VARS_X64); - object_class_property_add_enum(oc, "x-south-bridge", "PCSouthBridgeOption", - &PCSouthBridgeOption_lookup, - pc_get_south_bridge, - pc_set_south_bridge); - object_class_property_set_description(oc, "x-south-bridge", - "Use a different south bridge than PIIX3"); + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "x-south-bridge", + .description = "Use a different south bridge than PIIX3", + .qapi_type = &PCSouthBridgeOption_type_info, + .get = pc_get_south_bridge, + .set = pc_set_south_bridge, + )); compat_props_add(m->compat_props, pc_piix_compat_defaults, pc_piix_compat_defaults_len); } diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c index c5f64319009..9a8fcc66781 100644 --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c @@ -27,6 +27,7 @@ #include "qemu/target-info.h" #include "qemu/units.h" #include "qapi/error.h" +#include "qapi/qapi-type-infos-common.h" #include "target/microblaze/cpu.h" #include "hw/core/sysbus.h" #include "net/net.h" @@ -174,14 +175,16 @@ static void petalogix_s3adsp1800_machine_class_init(ObjectClass *oc, mc->init = petalogix_s3adsp1800_init; mc->is_default = true; - prop = object_class_property_add_enum(oc, "endianness", "EndianMode", - &EndianMode_lookup, - machine_get_endianness, - machine_set_endianness); - object_property_set_default_str(prop, target_big_endian() ? "big" - : "little"); - object_class_property_set_description(oc, "endianness", - "Defines whether the machine runs in big or little endian mode"); + prop = object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "endianness", + .description = + "Defines whether the machine runs in big or little endian mode", + .qapi_type = &EndianMode_type_info, + .get = machine_get_endianness, + .set = machine_set_endianness, + )); + object_property_set_default_enum(prop, + target_big_endian() ? ENDIAN_MODE_BIG : ENDIAN_MODE_LITTLE); } static const TypeInfo petalogix_s3adsp1800_machine_types[] = { diff --git a/net/filter.c b/net/filter.c index c7cc6615dc9..42e5d7c9072 100644 --- a/net/filter.c +++ b/net/filter.c @@ -8,6 +8,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-type-infos-common.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" @@ -340,9 +341,12 @@ static void netfilter_class_init(ObjectClass *oc, const void *data) object_class_property_add_str(oc, "netdev", netfilter_get_netdev_id, netfilter_set_netdev_id); - object_class_property_add_enum(oc, "queue", "NetFilterDirection", - &NetFilterDirection_lookup, - netfilter_get_direction, netfilter_set_direction); + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "queue", + .qapi_type = &NetFilterDirection_type_info, + .get = netfilter_get_direction, + .set = netfilter_set_direction, + )); object_class_property_add_str(oc, "status", netfilter_get_status, netfilter_set_status); object_class_property_add_str(oc, "position", diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 9e352882c8c..ecf0c76fcdf 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -14,6 +14,8 @@ #include "qemu/osdep.h" #include "qapi/qapi-events-run-state.h" +#include "qapi/qapi-type-infos-common.h" +#include "qapi/qapi-type-infos-run-state.h" #include "qapi/error.h" #include "qapi/visitor.h" #include <math.h> @@ -7086,12 +7088,13 @@ static void kvm_arch_set_honor_guest_pat(Object *obj, int value, Error **errp) void kvm_arch_accel_class_init(ObjectClass *oc) { - object_class_property_add_enum(oc, "notify-vmexit", "NotifyVMexitOption", - &NotifyVmexitOption_lookup, - kvm_arch_get_notify_vmexit, - kvm_arch_set_notify_vmexit); - object_class_property_set_description(oc, "notify-vmexit", - "Enable notify VM exit"); + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "notify-vmexit", + .description = "Enable notify VM exit", + .qapi_type = &NotifyVmexitOption_type_info, + .get = kvm_arch_get_notify_vmexit, + .set = kvm_arch_set_notify_vmexit, + )); object_class_property_add(oc, "notify-window", "uint32", kvm_arch_get_notify_window, @@ -7124,13 +7127,14 @@ void kvm_arch_accel_class_init(ObjectClass *oc) object_class_property_set_description(oc, "xen-evtchn-max-pirq", "Maximum number of Xen PIRQs"); - object_class_property_add_enum(oc, "honor-guest-pat", "OnOffAuto", - &OnOffAuto_lookup, - kvm_arch_get_honor_guest_pat, - kvm_arch_set_honor_guest_pat); - object_class_property_set_description(oc, "honor-guest-pat", - "Disable KVM quirk that ignores guest PAT " - "memory type settings (default: auto)"); + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "honor-guest-pat", + .description = "Disable KVM quirk that ignores guest PAT " + "memory type settings (default: auto)", + .qapi_type = &OnOffAuto_type_info, + .get = kvm_arch_get_honor_guest_pat, + .set = kvm_arch_set_honor_guest_pat, + )); } void kvm_set_max_apic_id(uint32_t max_apic_id) diff --git a/ui/dbus.c b/ui/dbus.c index 794b65c4ada..a9cc0c48ac7 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -37,6 +37,7 @@ #include "qemu/audio.h" #include "audio/audio_int.h" /* FIXME: use QOM dynamic cast instead of drv->name */ #include "qapi/error.h" +#include "qapi/qapi-type-infos-ui.h" #include "trace.h" #include "dbus.h" @@ -448,9 +449,12 @@ dbus_display_class_init(ObjectClass *oc, const void *data) object_class_property_add_bool(oc, "p2p", get_dbus_p2p, set_dbus_p2p); object_class_property_add_str(oc, "addr", get_dbus_addr, set_dbus_addr); object_class_property_add_str(oc, "audiodev", get_audiodev, set_audiodev); - object_class_property_add_enum(oc, "gl-mode", - "DisplayGLMode", &DisplayGLMode_lookup, - get_gl_mode, set_gl_mode); + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "gl-mode", + .qapi_type = &DisplayGLMode_type_info, + .get = get_gl_mode, + .set = set_gl_mode, + )); } #define TYPE_CHARDEV_VC "chardev-vc" diff --git a/ui/input-linux.c b/ui/input-linux.c index 74bc8511428..5014a306e7d 100644 --- a/ui/input-linux.c +++ b/ui/input-linux.c @@ -6,6 +6,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-type-infos-common.h" #include "qemu/config-file.h" #include "qemu/main-loop.h" #include "qemu/module.h" @@ -507,10 +508,12 @@ static void input_linux_class_init(ObjectClass *oc, const void *data) object_class_property_add_bool(oc, "repeat", input_linux_get_repeat, input_linux_set_repeat); - object_class_property_add_enum(oc, "grab-toggle", "GrabToggleKeys", - &GrabToggleKeys_lookup, - input_linux_get_grab_toggle, - input_linux_set_grab_toggle); + object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP( + .name = "grab-toggle", + .qapi_type = &GrabToggleKeys_type_info, + .get = input_linux_get_grab_toggle, + .set = input_linux_set_grab_toggle, + )); } static const TypeInfo input_linux_info = { -- 2.54.0
