On Wed, 29 Apr 2026 14:48:36 +0100
Joshua Lant <[email protected]> wrote:

> Extend the capability for hiding devices, introduced for virtio-net
> device in:
> 
> commit f3a8505656935cde32e28c1c6317f725084da1e0
> Author: Jens Freimann <[email protected]>
> Date:   Tue Oct 29 12:48:55 2019 +0100
> qdev/qbus: add hidden device support
> 
> Currently only endpoint devices can be hidden with a primary device
> and failover (known static configuration). However, looking at future
> composable systems, we see a need for hidden devices which have no associated
> bus upon boot. Move the check for hidden devices to before the bus
> search, and if it is hidden ignore the case where the device was
> described on the CLI without the "bus=" field.
> 
> This is motivated by a specific use-case: implementing the VCS
> command set, part of the CXL specification (CXL r3.2 Section 7.1.3). In
> this scenario a switch controlled by a Fabric Manager is able to change the
> virtual hierarchy of devices seen by a guest within a fixed physical system
> topology. The connecting bus is not known until runtime when
> a bind command is issued by the Fabric Manager.

So this comes back to the earlier comment on whether they are completely
hidden from a guest.  They aren't quite - we need to be able to
get to them via the MCTP or cxl-switch-cci (in band mailbox) paths.

Maybe we can solve that later without any compatibility problems
or by cheating and just searching hidden devices. I'm not sure.
> 
> Signed-off-by: Joshua Lant <[email protected]>
> ---
>  system/qdev-monitor.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
> index f2aa400a77..b51dfe0645 100644
> --- a/system/qdev-monitor.c
> +++ b/system/qdev-monitor.c
> @@ -650,6 +650,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
>      DeviceState *dev;
>      BusState *bus = NULL;
>      QDict *properties;
> +    bool hide_device;
>  
>      driver = qdict_get_try_str(opts, "driver");
>      if (!driver) {
> @@ -663,6 +664,11 @@ DeviceState *qdev_device_add_from_qdict(const QDict 
> *opts,
>          return NULL;
>      }
>  
> +    /* Is the device hidden from the guest?
> +     * If yes, no need to find a default bus if none given...
> +     * Bus could be provided at runtime (i.e. in a switch)*/
> +    hide_device = qdev_should_hide_device(opts, from_json, errp);
> +
>      /* find bus */
>      path = qdict_get_try_str(opts, "bus");
>      if (path != NULL) {
> @@ -675,14 +681,14 @@ DeviceState *qdev_device_add_from_qdict(const QDict 
> *opts,
>                         driver, object_get_typename(OBJECT(bus)));
>              return NULL;
>          }
> -    } else if (dc->bus_type != NULL) {
> +    } else if (dc->bus_type != NULL && !hide_device) {
>          bus = qdev_find_default_bus(dc, errp);
>          if (!bus) {
>              return NULL;
>          }
>      }
>  
> -    if (qdev_should_hide_device(opts, from_json, errp)) {
> +    if (hide_device) {
>          if (bus && !qbus_is_hotpluggable(bus)) {
>              error_setg(errp, "Bus '%s' does not support hotplugging",
>                         bus->name);


Reply via email to