[libvirt] [PATCH 2/6] qemu: Add -machine suffix automatically

Pavel Hrdina phrdina at redhat.com
Fri May 17 11:41:23 UTC 2019


On Thu, May 16, 2019 at 05:35:32PM +0200, Andrea Bolognani wrote:
> The QOM type for machine types is the machine type name
> followed by the -machine suffix. Since this is always the
> case, we can make virQEMUCapsMachineProps more readable
> and avoid repetition by not including the suffix there and
> adding it automatically while processing the data.
> 
> Signed-off-by: Andrea Bolognani <abologna at redhat.com>
> ---
>  src/qemu/qemu_capabilities.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 66745ab4e2..34d162b9d1 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -1407,7 +1407,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsMachinePropsSPAPR[] = {
>  };
>  
>  static virQEMUCapsObjectTypeProps virQEMUCapsMachineProps[] = {
> -    { "spapr-machine", virQEMUCapsMachinePropsSPAPR,
> +    { "spapr", virQEMUCapsMachinePropsSPAPR,
>        ARRAY_CARDINALITY(virQEMUCapsMachinePropsSPAPR),
>        -1 },
>  };
> @@ -2358,7 +2358,12 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps,
>  
>      for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsMachineProps); i++) {
>          virQEMUCapsObjectTypeProps props = virQEMUCapsMachineProps[i];
> -        const char *type = props.type;
> +        VIR_AUTOFREE(char *) type = NULL;
> +
> +        /* The QOM type for machine types is the machine type name
> +         * followed by the -machine suffix */
> +        if (virAsprintf(&type, "%s-machine", props.type) < 0)
> +            return -1;
>  
>          if ((nvalues = qemuMonitorGetObjectProps(mon, type, &values)) < 0)
>              return -1;

This patch on its own doesn't make that much sense and only adds some
extra memory allocation, but looking forward to the following
patches it is required to canonicalize the machine type.

Please move the patch next to the one which introduces the canonicalize
code and modify the commit message to reflect the actual need for this
change.

Pavel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190517/c6a3bd06/attachment-0001.sig>


More information about the libvir-list mailing list