All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	philmd@oss.qualcomm.com,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	anjo@rev.ng
Subject: Re: [PATCH v2 1/2] qom/object: add available_if field to TypeInfo
Date: Mon, 24 Aug 2026 08:01:37 +0200	[thread overview]
Message-ID: <87ld9wvyym.fsf@pond.sub.org> (raw)
In-Reply-To: <20260821235112.193381-2-pierrick.bouvier@oss.qualcomm.com> (Pierrick Bouvier's message of "Fri, 21 Aug 2026 23:51:11 +0000")

Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:

> With the single-binary, we start mixing types for different targets,
> that may or may not be available for current one.
>
> Previously, we implemented an approach based on interfaces, but it
> proved to be too limited. It requires duplication between
> machines/cpus/devices, and does not handle specific cases where a type
> should be available based on a target configuration (Kconfig).
>
> To solve this, we add a new field, available_if, to TypeInfo.
> It is an array containing a list of requirements for type to be
> available.
>
> For now, we have only targets as requirements, but later we'll add
> specific target config entries also.
>
> We also add a TARGET_REQS macro, to declare a list of requirements. For
> sanity sake, we don't use a complex variadic macro prefixing each
> parameter. It requires a lot of macro boilerplate in C, and prevent
> readers to jump easily to definition for each parameter.
>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
> ---
>  include/qemu/target-info.h | 11 +++++++++++
>  include/qom/object.h       |  5 +++++
>  qom/object.c               | 10 ++++++++++
>  rust/qom/src/qom.rs        |  1 +
>  stubs/meson.build          |  1 +
>  stubs/target-info.c        | 11 +++++++++++
>  target-info.c              | 13 +++++++++++++
>  7 files changed, 52 insertions(+)
>  create mode 100644 stubs/target-info.c
>
> diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
> index 6c5b714288e..6379e65bbcf 100644
> --- a/include/qemu/target-info.h
> +++ b/include/qemu/target-info.h
> @@ -50,6 +50,17 @@ const char *target_cpu_type(void);
>   */
>  bool target_big_endian(void);
>  
> +typedef enum TargetReq {
> +    /* 0 is reserved for end of array */
> +    TARGET_REQ_BASE_ARM = 1,
> +    TARGET_REQ_AARCH64,
> +    TARGET_REQ_ARM,
> +} TargetReq;
> +
> +#define TARGET_REQS(...) (const TargetReq[]){__VA_ARGS__, 0}

The sentinel 0 is not a member of the enum.

Is this safe?  I'm asking because the C standard is infatuated with
undefined behavior.  Checking C99...  all I can find is Annex I "Common
warnings"

         -- A  value  is  given to an object of an enumeration type
            other than by assignment  of  an  enumeration  constant
            that  is  a  member  of  that  type,  or an enumeration
            variable that has the same type,  or  the  value  of  a
            function   that   returns  the  same  enumeration  type

Looks like it's safe.

[...]



  parent reply	other threads:[~2026-08-24  7:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21 23:51 [PATCH v2 0/2] single-binary: implement dynamic filtering for machine types Pierrick Bouvier
2026-08-21 23:51 ` [PATCH v2 1/2] qom/object: add available_if field to TypeInfo Pierrick Bouvier
2026-08-22 14:23   ` Richard Henderson
2026-08-24  6:53     ` Pierrick Bouvier
2026-08-24  8:39       ` Yonggang Luo
2026-08-24 16:17         ` Pierrick Bouvier
2026-08-24  6:01   ` Markus Armbruster [this message]
2026-08-24 15:29     ` Pierrick Bouvier
2026-08-21 23:51 ` [PATCH v2 2/2] remote/machine: add available_if for x-remote machine type Pierrick Bouvier
2026-08-28 23:06 ` [PATCH v2 0/2] single-binary: implement dynamic filtering for machine types Pierrick Bouvier

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=87ld9wvyym.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=anjo@rev.ng \
    --cc=berrange@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.