QEMU-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
Subject: Re: [PATCH v5 13/62] qom: add object_{class_}property_add_qapi_enum
Date: Mon, 19 Oct 2026 09:39:55 +0200	[thread overview]
Message-ID: <87o6cq2l6c.fsf@pond.sub.org> (raw)
In-Reply-To: <20260911-qom-qapi-v5-13-7732a55b7760@redhat.com> ("Marc-André Lureau"'s message of "Fri, 11 Sep 2026 20:34:47 +0400")

Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/qom/object.h | 73 ++++++++++++++++++++++++++++++++++++++++++
>  qom/object.c         | 89 +++++++++++++++++++++++++++++++++++++++++++++++++---
>  2 files changed, 157 insertions(+), 5 deletions(-)
>
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 083fe646c390..c9a5fe4934d0 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -1993,6 +1993,79 @@ ObjectProperty *object_class_property_add_enum(ObjectClass *klass,
>                                      int (*get)(Object *, Error **),
>                                      void (*set)(Object *, int, Error **));
>  
> +/**
> + * struct QapiEnumProp - Descriptor for a QOM property backed by a QAPI enum type

Elsewhere in this file, we use

   /**
    * struct SomeName:

and

   /**
    * typedef SomeName:

When to use struct and when to use typedef?

None of them have a description.  In other files, I see

   /**
    * struct SomeName: a description

and

   /**
    * struct SomeName - a description

Colon or dash?

If the answer is "whatever you like", then I'd recommend colon for local
consistency.

scripts/checkpatch.pl gripes

    WARNING: line over 80 characters

> + *
> + * Binds a QOM object property to a QAPI enum, providing automatic
> + * string<->int conversion through QAPI visitors and optional
> + * default-value initialization during object instance init.
> + *
> + * Use the QAPI_ENUM_PROP() macro to construct instances inline.
> + *
> + * @name: property name exposed on the QOM object
> + * @description: human-readable description (shown in ``-device help``, etc.)
> + * @default_value: initial enum value applied via @set during instance init,
> + *                 or -1 (the QAPI_ENUM_PROP default) to skip initialization
> + * @qapi_type: pointer to the generated QAPITypeInfo for the enum
> + *             (provides the string<->int lookup table)
> + * @get: getter that returns the current enum value as int, or -1 on error
> + * @set: setter that receives the enum value as int; %NULL for read-only props
> + */
> +typedef struct QapiEnumProp {
> +    const char *name;
> +    const char *description;
> +    const int default_value;
> +    const QAPITypeInfo *qapi_type;
> +    int (*get)(Object *, Error **);
> +    void (*set)(Object *, int, Error **);
> +} QapiEnumProp;
> +
> +#define QAPI_ENUM_PROP(...) ({                                           \
> +    static const QapiEnumProp _prop = {                                  \
> +        .default_value = -1, __VA_ARGS__                                 \
> +    };                                                                   \
> +    &_prop; })
> +
> +/**
> + * object_property_add_qapi_enum:
> + * @obj: the object to add a property to
> + * @prop: property descriptor
> + *
> + * Add an enum property with QAPI type association.
> + *
> + * Returns: The newly added property on success, or %NULL on failure.
> + */
> +ObjectProperty *
> +object_property_add_qapi_enum(Object *obj, const QapiEnumProp *prop);
> +
> +/**
> + * object_class_property_add_qapi_enum:
> + * @klass: the class object to add a property to
> + * @prop: property descriptor
> + *
> + * Add an enum property with QAPI type association.
> + *
> + * Use the QAPI_ENUM_PROP() macro to construct the property descriptor
> + * inline. If .default_value is not set, the property is not initialized
> + * (default_value is -1). Otherwise, the setter is called with
> + * default_value during object instance init.
> + *
> + * Example::
> + *
> + *   object_class_property_add_qapi_enum(oc, QAPI_ENUM_PROP(
> + *       .name = "policy",
> + *       .description = "Set the NUMA policy",
> + *       .default_value = HOST_MEM_POLICY_DEFAULT,
> + *       .qapi_type = &HostMemPolicy_type_info,
> + *       .get = my_get_policy,
> + *       .set = my_set_policy,
> + *   ));
> + *
> + * Returns: The newly added property on success, or %NULL on failure.
> + */
> +ObjectProperty *
> +object_class_property_add_qapi_enum(ObjectClass *klass, const QapiEnumProp *prop);

Another

    WARNING: line over 80 characters

> +
>  /**
>   * object_property_add_qapi:
>   * @obj: the object to add a property to

[...]



  reply	other threads:[~2026-10-19  8:08 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 16:34 [PATCH v5 00/62] qom/qdev: associate properties with QAPI schema types Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 01/62] qapi: add QAPITypeInfo struct definition Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 02/62] qapi/gen: fix _module_basename for multi-dash 'what' parameters Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 03/62] qapi: factor out QAPISchemaUsedTypes from introspect visitor Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 04/62] qapi: register all introspectable types, not just QMP-reachable ones Marc-André Lureau
2026-09-18 13:36   ` Markus Armbruster
2026-09-18 14:02     ` Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 05/62] qapi: add type-infos generator Marc-André Lureau
2026-10-17  9:27   ` Markus Armbruster
2026-09-11 16:34 ` [PATCH v5 06/62] meson: add qapi-type-infos-*.c/h to build Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 07/62] qom: add qapi_type field to ObjectProperty Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 08/62] qapi/qom: add qapi-type field to ObjectPropertyInfo Marc-André Lureau
2026-10-15 11:27   ` Markus Armbruster
2026-09-11 16:34 ` [PATCH v5 09/62] qom/qmp: populate qapi-type in QMP handlers Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 10/62] qom/qmp: populate description & default-value in qom_property_info() Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 11/62] qom: add object_property_set_default_enum() Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 12/62] qom: add object_{class_}property_add_qapi Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 13/62] qom: add object_{class_}property_add_qapi_enum Marc-André Lureau
2026-10-19  7:39   ` Markus Armbruster [this message]
2026-09-11 16:34 ` [PATCH v5 14/62] tests: update check-qom-proplist for QAPI-aware property registration Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 15/62] qom: convert enum properties to QAPI-aware registration Marc-André Lureau
2026-10-13 13:40   ` Markus Armbruster
2026-09-11 16:34 ` [PATCH v5 16/62] qom: remove old enum property registration API Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 17/62] qom: convert struct properties to QAPI-aware registration Marc-André Lureau
2026-10-19 13:05   ` Markus Armbruster
2026-09-11 16:34 ` [PATCH v5 18/62] x86: convert OnOffAuto " Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 19/62] microvm: " Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 20/62] pc: convert OnOffAuto vmport property " Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 21/62] arm/virt: convert OnOffAuto acpi " Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 22/62] riscv/virt: convert OnOffAuto properties " Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 23/62] loongarch/virt: " Marc-André Lureau
2026-09-14  1:16   ` Bibo Mao
2026-09-11 16:34 ` [PATCH v5 24/62] hostmem-file: convert OnOffAuto rom property " Marc-André Lureau
2026-09-11 16:34 ` [PATCH v5 25/62] sev: convert OnOffAuto legacy-vm-type " Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 26/62] whpx: convert OnOffAuto hyperv " Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 27/62] whpx: convert OnOffAuto arch properties " Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 28/62] accel/kvm: convert OnOffSplit property " Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 29/62] whpx: " Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 30/62] hw/ppc/spapr_caps: fix property type name Marc-André Lureau
2026-09-14  7:25   ` Amit Machhiwal
2026-09-11 16:35 ` [PATCH v5 31/62] ppc/spapr-caps: convert to QAPI-aware property registration Marc-André Lureau
2026-09-14  7:28   ` Amit Machhiwal
2026-09-11 16:35 ` [PATCH v5 32/62] net/colo-compare: fix compare_timeout setter visitor type Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 33/62] net/colo-compare: fix max_queue_size " Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 34/62] hw/misc/xlnx-versal-trng: add missing getter for fips-fault-events Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 35/62] qom: convert scalar properties to QAPI-aware registration Marc-André Lureau
2026-10-19  7:41   ` Markus Armbruster
2026-09-11 16:35 ` [PATCH v5 36/62] i386/cpu: convert strList property " Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 37/62] accel/hvf: convert OnOffSplit " Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 38/62] i386/x86: convert SgxEPCList " Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 39/62] virtio-balloon: convert guest-stats property to QAPI type Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 40/62] qom: replace object_property_add_tm with StructTm " Marc-André Lureau
2026-09-14  7:42   ` Amit Machhiwal
2026-09-11 16:35 ` [PATCH v5 41/62] hw/nvdimm: convert UUID property to QAPI-aware registration Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 42/62] hw/s390-virtio-ccw: convert loadparm " Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 43/62] hw/ppc/spapr_drc: convert fdt " Marc-André Lureau
2026-09-14  7:43   ` Amit Machhiwal
2026-09-11 16:35 ` [PATCH v5 44/62] hw/gpio/pca955x: use QAPI enums for led and pin properties Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 45/62] include: add QEMU_REPEAT helper macro Marc-André Lureau
2026-10-19  7:45   ` Markus Armbruster
2026-09-11 16:35 ` [PATCH v5 46/62] hw/gpio/pca955x: convert pin/led property to QAPI-aware enum Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 47/62] hw/pci: change the busnr type to uint8 Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 48/62] qdev: add qapi_type field to PropertyInfo with fallback registration Marc-André Lureau
2026-10-19 13:14   ` Markus Armbruster
2026-09-11 16:35 ` [PATCH v5 49/62] qdev: convert core PropertyInfo definitions to use qapi_type Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 50/62] qdev: adjust PciDevfn declared type Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 51/62] qdev: convert system PropertyInfo definitions to use qapi_type Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 52/62] hw: convert device-local " Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 53/62] target/riscv: convert " Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 54/62] qdev: " Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 55/62] qdev: introduce typed array PropertyInfos Marc-André Lureau
2026-10-19 13:17   ` Markus Armbruster
2026-09-11 16:35 ` [PATCH v5 56/62] qdev: simplify DEFINE_PROP_ARRAY and remove generic array PropertyInfo Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 57/62] qdev: remove deprecated PropertyInfo.type and .enum_table fields Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 58/62] hw/i386: convert PCSouthBridgeOption to QAPI enum Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 59/62] qom: use QAPITypeInfo in object_property_get_enum Marc-André Lureau
2026-10-19 13:21   ` Markus Armbruster
2026-09-11 16:35 ` [PATCH v5 60/62] qapi: expose integer signedness and width in introspection Marc-André Lureau
2026-10-13 13:56   ` Markus Armbruster
2026-10-13 15:29     ` Marc-André Lureau
2026-10-14  6:05       ` Markus Armbruster
2026-10-14 19:14         ` Marc-André Lureau
2026-10-15  9:46           ` Markus Armbruster
2026-09-11 16:35 ` [PATCH v5 61/62] tests/qmp-cmd-test: assert qapi-type resolves in query-qmp-schema Marc-André Lureau
2026-09-11 16:35 ` [PATCH v5 62/62] qapi: select introspectable types directly Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o6cq2l6c.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@oss.qualcomm.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox