All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Cave-Ayland <mark.caveayland@nutanix.com>
To: "Cédric Le Goater" <clg@redhat.com>,
	qemu-devel@nongnu.org, qemu-arm@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Steven Lee" <steven_lee@aspeedtech.com>,
	"Troy Lee" <leetroy@gmail.com>,
	"Jamin Lin" <jamin_lin@aspeedtech.com>,
	kane_chen@aspeedtech.com,
	"Andrew Jeffery" <andrew@codeconstruct.com.au>,
	"Joel Stanley" <joel@jms.id.au>,
	"Cédric Le Goater" <clg@kaod.org>
Subject: Re: [PATCH 1/2] hw/arm: Add /machine/labels container for Aspeed machines
Date: Wed, 9 Sep 2026 11:35:45 +0100	[thread overview]
Message-ID: <2f7465ed-9945-48e6-81dd-d7aaafd249ed@nutanix.com> (raw)
In-Reply-To: <20260904050424.4049984-2-clg@redhat.com>

On 04/09/2026 06:04, Cédric Le Goater wrote:

> Add a DT-style alias container /machine/labels where board code registers
> link<> properties pointing to well-known devices. Tests can then resolve
> a device with a single QMP call (qom-get /machine/labels/<name>) instead
> of walking the bus hierarchy.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>   include/hw/arm/aspeed.h | 12 ++++++++++++
>   hw/arm/aspeed.c         | 10 ++++++++++
>   2 files changed, 22 insertions(+)
> 
> diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h
> index 245d02e5f757..0b8b40262767 100644
> --- a/include/hw/arm/aspeed.h
> +++ b/include/hw/arm/aspeed.h
> @@ -128,4 +128,16 @@ void aspeed_machine_ast2600_class_emmc_init(ObjectClass *oc);
>    */
>   void aspeed_connect_serial_hds_to_uarts(AspeedMachineState *bmc);
>   
> +/*
> + * aspeed_machine_add_label:
> + * @bmc: pointer to the #AspeedMachineState.
> + * @label: the label name for the device.
> + * @target: the device object to register.
> + *
> + * Register a well-known device under /machine/labels/<label> as a
> + * read-only link.  Aborts on duplicate label names.
> + */
> +void aspeed_machine_add_label(AspeedMachineState *bmc, const char *label,
> +                              Object *target);
> +
>   #endif
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index 1f8d5d3e132d..79b8d55d66da 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -127,6 +127,14 @@ void aspeed_connect_serial_hds_to_uarts(AspeedMachineState *bmc)
>       }
>   }
>   
> +void aspeed_machine_add_label(AspeedMachineState *bmc, const char *label,
> +                              Object *target)
> +{
> +    Object *labels = object_resolve_path_component(OBJECT(bmc), "labels");
> +
> +    object_property_add_const_link(labels, label, target);
> +}
> +
>   static void aspeed_machine_init(MachineState *machine)
>   {
>       AspeedMachineState *bmc = ASPEED_MACHINE(machine);
> @@ -137,6 +145,8 @@ static void aspeed_machine_init(MachineState *machine)
>       DriveInfo *emmc0 = NULL;
>       bool boot_emmc;
>   
> +    object_property_add_new_container(OBJECT(machine), "labels");
> +
>       bmc->soc = ASPEED_SOC(object_new(amc->soc_name));
>       object_property_add_child(OBJECT(machine), "soc", OBJECT(bmc->soc));
>       object_unref(OBJECT(bmc->soc));

Thanks for the proposal, Cédric! A few comments from me below:

1) Is there any reason it should be called labels as opposed to aliases? 
The aliases name as used in Open Firmware feels more intuitive to me.

2) If there is agreement in this approach, is there any reason why we 
shouldn't create /machine/labels (or equivalent) for all QOM trees? I 
certainly think it would be a useful addition going forward.

3) Is there any reason why we need to provide the machine object 
directly to the aspeed_machine_add_label() function? If possible I think 
it makes sense to avoid the direct machine reference, in case the 
underlying implementation changes i.e.


   void machine_add_alias(const char *alias, Object *target)
   {
      Object *aliases = object_resolve_path("/machine/aliases",  NULL);

      object_property_add_const_link(aliases, alias, target);
   }


Even better perhaps we should also generate an error if the alias 
already exists to ensure they are always unique i.e.


   bool machine_add_alias(const char *alias, Object *target,
                          Error **errp)
   {
      Object *aliases = object_resolve_path("/machine/aliases",  NULL);

      if (object_resolve_path_component(aliases, alias)) {
          error_setg(errp, "machine alias '%s' already exists");
          return false;
      }

      return (object_property_add_const_link(aliases, alias, target) !=
              NULL);
   }


4) Should we create a page in the documentation explaining which 
devices/objects should be included in the alias list, which ones are 
added automatically, and what naming conventions should be used for 
devices e.g. serial0, net0 for a network device etc.?

5) What should happen to aliases for devices that are 
hot-plugged/hot-unplugged?


ATB,

Mark.



  reply	other threads:[~2026-09-09 10:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  5:04 [PATCH 0/2] hw/arm/aspeed: Add /machine/labels container Cédric Le Goater
2026-09-04  5:04 ` [PATCH 1/2] hw/arm: Add /machine/labels container for Aspeed machines Cédric Le Goater
2026-09-09 10:35   ` Mark Cave-Ayland [this message]
2026-09-09 11:15     ` Cédric Le Goater
2026-09-09 13:39       ` Mark Cave-Ayland
2026-09-09 17:34         ` Cédric Le Goater
2026-09-04  5:04 ` [PATCH 2/2] test/functional: anacapa: test ADC128D818 Cédric Le Goater

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=2f7465ed-9945-48e6-81dd-d7aaafd249ed@nutanix.com \
    --to=mark.caveayland@nutanix.com \
    --cc=andrew@codeconstruct.com.au \
    --cc=clg@kaod.org \
    --cc=clg@redhat.com \
    --cc=jamin_lin@aspeedtech.com \
    --cc=joel@jms.id.au \
    --cc=kane_chen@aspeedtech.com \
    --cc=leetroy@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=steven_lee@aspeedtech.com \
    /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.