On Tue, Oct 20, 2026 at 02:46:11PM +0400, Marc-André Lureau wrote:
> PciDevfn is a bit special, since it accepts integer and string as
> setter, but only output integer as getter.
> 
> Unfortunately, we can't declare an alternate str|int QAPI type for it,
> since: branch 'string' can't be distinguished from 'integer'
> 
> Rather than declaring it as "str", use the common type instead.
> 
> Signed-off-by: Markus Armbruster <[email protected]>
> Signed-off-by: Marc-André Lureau <[email protected]>
> ---
>  hw/core/qdev-properties-system.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/core/qdev-properties-system.c 
> b/hw/core/qdev-properties-system.c
> index 5bfdfe1ab9d9..3381de1144d6 100644
> --- a/hw/core/qdev-properties-system.c
> +++ b/hw/core/qdev-properties-system.c
> @@ -904,7 +904,8 @@ static char *print_pci_devfn(Object *obj, const Property 
> *prop)
>  }
>  
>  const PropertyInfo qdev_prop_pci_devfn = {
> -    .type  = "str",
> +    /* The formatted string accepted by the setter is a CLI convenience. */

IIUC, this is not limited to the CLI, it will work anywhere the JSON
syntax is permitted which is both CLI and QMP.

libvirt uses this string syntax:

  -device 
'{"driver":"pcie-root-port","port":9,"chassis":2,"id":"pci.2","bus":"pcie.0","multifunction":true,"addr":"0x1.0x1"}'
 \

> +    .type  = "int32",
>      .description = "Slot and optional function number, example: 06.0 or 06",


Changing the type to 'int32', where 99% of usage is input only
and string based, is pretty unpleasant. Even more so that the
description doesn't even mention encoding dev+function as an
integer.

>      .print = print_pci_devfn,
>      .get   = qdev_propinfo_get_int32,

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|


Reply via email to