[PATCH v1 1/4] Introduce virConnectGetHypervisorCPUNames public API

Daniel P. Berrangé berrange at redhat.com
Wed Mar 22 15:51:18 UTC 2023


On Wed, Mar 22, 2023 at 11:39:15AM -0400, Collin Walling wrote:
> The new API collects a list of CPU model names supported by the
> specified hypervisor. This is a more useful version of
> virConnectGetCPUNames, which does not consider any hypervisor
> capabilities when querying model names.
> 
> Signed-off-by: Collin Walling <walling at linux.ibm.com>
> Reviewed-by: Boris Fiuczynski <fiuczy at linux.ibm.com>
> ---
>  include/libvirt/libvirt-host.h |  6 ++++
>  src/driver-hypervisor.h        |  9 ++++++
>  src/libvirt-host.c             | 54 ++++++++++++++++++++++++++++++++++
>  src/libvirt_public.syms        |  5 ++++
>  4 files changed, 74 insertions(+)
> 
> diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h
> index 3112f2b676..a70a4d9971 100644
> --- a/include/libvirt/libvirt-host.h
> +++ b/include/libvirt/libvirt-host.h
> @@ -961,6 +961,12 @@ int virConnectGetCPUModelNames(virConnectPtr conn,
>                                 const char *arch,
>                                 char ***models,
>                                 unsigned int flags);
> +char *virConnectGetHypervisorCPUModelNames(virConnectPtr conn,
> +                                           const char *emulator,
> +                                           const char *arch,
> +                                           const char *machine,
> +                                           const char *virttype,
> +                                           unsigned int flags);
>  
>  /**
>   * virConnectBaselineCPUFlags:
> diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
> index 5219344b72..725c1db752 100644
> --- a/src/driver-hypervisor.h
> +++ b/src/driver-hypervisor.h
> @@ -732,6 +732,14 @@ typedef int
>                                   char ***models,
>                                   unsigned int flags);
>  
> +typedef char *
> +(*virDrvConnectGetHypervisorCPUModelNames)(virConnectPtr conn,
> +                                           const char *emulator,
> +                                           const char *arch,
> +                                           const char *machine,
> +                                           const char *virttype,
> +                                           unsigned int flags);
> +
>  typedef int
>  (*virDrvDomainGetJobInfo)(virDomainPtr domain,
>                            virDomainJobInfoPtr info);
> @@ -1701,6 +1709,7 @@ struct _virHypervisorDriver {
>      virDrvDomainSetLifecycleAction domainSetLifecycleAction;
>      virDrvConnectCompareHypervisorCPU connectCompareHypervisorCPU;
>      virDrvConnectBaselineHypervisorCPU connectBaselineHypervisorCPU;
> +    virDrvConnectGetHypervisorCPUModelNames connectGetHypervisorCPUModelNames;
>      virDrvNodeGetSEVInfo nodeGetSEVInfo;
>      virDrvDomainGetLaunchSecurityInfo domainGetLaunchSecurityInfo;
>      virDrvDomainSetLaunchSecurityState domainSetLaunchSecurityState;
> diff --git a/src/libvirt-host.c b/src/libvirt-host.c
> index a2ba347d54..407d19ffa9 100644
> --- a/src/libvirt-host.c
> +++ b/src/libvirt-host.c
> @@ -1379,6 +1379,60 @@ virConnectBaselineHypervisorCPU(virConnectPtr conn,
>  }
>  
>  
> +/**
> + * virConnectGetHypervisorCPUModelNames:
> + *
> + * @conn: pointer to the hypervisor connection
> + * @emulator: path to the emulator binary
> + * @arch: CPU architecture
> + * @machine: machine type
> + * @virttype: virtualization type
> + * @flags: extra flags; not used yet, so callers should always pass 0.
> + *
> + * Get the list of CPU models recognized by the hypervisor for a specific
> + * architecture. Note that even if the hypervisor reports a particular CPU
> + * model, hardware limitations may impose restrictions on which CPU models
> + * may be supported on the  host (e.g. on s390 the hypervisor may report
> + * model gen15a, but this model will not run on an older machine such as z14).
> + *
> + * Returns NULL on error, or a string of CPU models on success.

This API appears to be duplicating information that is already
made available in the domain capabilities output, except it is
worse as this API is actually providing less information.

Also returning this as a single newline separated string is
making the assumption that the caller merely wishes to print
this on the console.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


More information about the libvir-list mailing list