On Tue, Jun 28, 2022 at 06:09:39PM +0200, Tim Wiederhake wrote: > Create a function to query the hypervisor for its list of known CPU model > names. This is different from virConnectGetCPUModelNames, as this new > function will determine the list of CPU models (and alias names) at > runtime. > > Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx> > --- > include/libvirt/libvirt-host.h | 6 ++++ > src/driver-hypervisor.h | 8 +++++ > src/libvirt-host.c | 55 ++++++++++++++++++++++++++++++++++ > src/libvirt_public.syms | 1 + > 4 files changed, 70 insertions(+) > > diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h > index 3112f2b676..5aaa001adb 100644 > --- a/include/libvirt/libvirt-host.h > +++ b/include/libvirt/libvirt-host.h > @@ -962,6 +962,12 @@ int virConnectGetCPUModelNames(virConnectPtr conn, > char ***models, > unsigned int flags); > > +int virConnectGetHypervisorCPUModelNames(virConnectPtr conn, > + const char *arch, > + char ***names, > + char ***aliases, > + unsigned int flags); > + > /** > * virConnectBaselineCPUFlags: > * > diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h > index 016d5cec7c..c81e5d4c75 100644 > --- a/src/driver-hypervisor.h > +++ b/src/driver-hypervisor.h > @@ -732,6 +732,13 @@ typedef int > char ***models, > unsigned int flags); > > +typedef int > +(*virDrvConnectGetHypervisorCPUModelNames)(virConnectPtr conn, > + const char *archName, > + char ***names, > + char ***aliases, > + unsigned int flags); > + > typedef int > (*virDrvDomainGetJobInfo)(virDomainPtr domain, > virDomainJobInfoPtr info); > @@ -1712,4 +1719,5 @@ struct _virHypervisorDriver { > virDrvDomainAuthorizedSSHKeysSet domainAuthorizedSSHKeysSet; > virDrvDomainGetMessages domainGetMessages; > virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc; > + virDrvConnectGetHypervisorCPUModelNames connectGetHypervisorCPUModelNames; > }; > diff --git a/src/libvirt-host.c b/src/libvirt-host.c > index 2ee6370bce..6e734628c1 100644 > --- a/src/libvirt-host.c > +++ b/src/libvirt-host.c > @@ -1234,6 +1234,61 @@ virConnectGetCPUModelNames(virConnectPtr conn, const char *arch, char ***models, > } > > > +/** > + * virConnectGetHypervisorCPUModelNames: > + * > + * @conn: virConnect connection > + * @arch: Architecture > + * @names: Pointer to a variable to store the NULL-terminated array of the CPU > + * models supported by the hypervisor for the specified architecture. > + * Each element and the array itself must be freed by the caller. > + * @aliases: Pointer to a variable to store the NULL-terminated array of alias > + * names for CPU model names. Each element and the array itself must > + * be freed by the caller. > + * @flags: extra flags; not used yet, so callers should always pass 0. > + * > + * Get the list of CPU models supported by the hypervisor for a specific > + * architecture. > + * > + * If @aliases[x] is not an empty string, @names[x] is an alias for that CPU > + * model. Why use the empty string as a marker, as opposed to NULL which is the obvious "no data" marker ? > + * > + * Returns -1 on error, number of elements in @models on success. > + * > + * Since: 8.5.0 > + */ > +int 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 :|