mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
libvirt: add new public API virConnectGetCPUModelNames
The new function virConnectGetCPUModelNames allows to retrieve the list of CPU models known by the hypervisor for a specific architecture. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
b0d9207bc6
commit
f90857b32a
@ -4006,6 +4006,10 @@ int virConnectCompareCPU(virConnectPtr conn,
|
||||
const char *xmlDesc,
|
||||
unsigned int flags);
|
||||
|
||||
int virConnectGetCPUModelNames(virConnectPtr conn,
|
||||
const char *arch,
|
||||
char ***models,
|
||||
unsigned int flags);
|
||||
|
||||
/**
|
||||
* virConnectBaselineCPUFlags
|
||||
|
@ -366,6 +366,7 @@ foreign_encoding_args = (
|
||||
# Class methods which are written by hand in libvirt.c but the Python-level
|
||||
# code is still automatically generated (so they are not in skip_function()).
|
||||
skip_impl = (
|
||||
"virConnectGetCPUModelNames",
|
||||
'virConnectGetVersion',
|
||||
'virConnectGetLibVersion',
|
||||
'virConnectListDomainsID',
|
||||
|
@ -681,6 +681,12 @@ typedef char *
|
||||
unsigned int ncpus,
|
||||
unsigned int flags);
|
||||
|
||||
typedef int
|
||||
(*virDrvConnectGetCPUModelNames)(virConnectPtr conn,
|
||||
const char *args,
|
||||
char ***models,
|
||||
unsigned int flags);
|
||||
|
||||
typedef int
|
||||
(*virDrvDomainGetJobInfo)(virDomainPtr domain,
|
||||
virDomainJobInfoPtr info);
|
||||
@ -1332,6 +1338,7 @@ struct _virDriver {
|
||||
virDrvDomainMigratePerform3Params domainMigratePerform3Params;
|
||||
virDrvDomainMigrateFinish3Params domainMigrateFinish3Params;
|
||||
virDrvDomainMigrateConfirm3Params domainMigrateConfirm3Params;
|
||||
virDrvConnectGetCPUModelNames connectGetCPUModelNames;
|
||||
};
|
||||
|
||||
|
||||
|
@ -18524,6 +18524,57 @@ error:
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virConnectGetCPUModelNames:
|
||||
*
|
||||
* @conn: virConnect connection
|
||||
* @arch: Architecture
|
||||
* @models: Pointer to a variable to store the NULL-terminated array of the
|
||||
* CPU models supported for the specified architecture. Each element
|
||||
* and the array itself must be freed by the caller with free. Pass
|
||||
* NULL if only the list length is needed.
|
||||
* @flags: extra flags; not used yet, so callers should always pass 0.
|
||||
*
|
||||
* Get the list of supported CPU models for a specific architecture.
|
||||
*
|
||||
* Returns -1 on error, number of elements in @models on success.
|
||||
*/
|
||||
int
|
||||
virConnectGetCPUModelNames(virConnectPtr conn, const char *arch, char ***models,
|
||||
unsigned int flags)
|
||||
{
|
||||
VIR_DEBUG("conn=%p, arch=%s, models=%p, flags=%x",
|
||||
conn, arch, models, flags);
|
||||
virResetLastError();
|
||||
|
||||
if (models)
|
||||
*models = NULL;
|
||||
|
||||
if (!VIR_IS_CONNECT(conn)) {
|
||||
virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__);
|
||||
virDispatchError(NULL);
|
||||
return -1;
|
||||
}
|
||||
virCheckNonNullArgReturn(arch, -1);
|
||||
|
||||
if (conn->driver->connectGetCPUModelNames) {
|
||||
int ret;
|
||||
|
||||
ret = conn->driver->connectGetCPUModelNames(conn, arch, models, flags);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
|
||||
error:
|
||||
virDispatchError(conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virConnectBaselineCPU:
|
||||
*
|
||||
|
@ -634,4 +634,9 @@ LIBVIRT_1.1.1 {
|
||||
virDomainSetMemoryStatsPeriod;
|
||||
} LIBVIRT_1.1.0;
|
||||
|
||||
LIBVIRT_1.1.3 {
|
||||
global:
|
||||
virConnectGetCPUModelNames;
|
||||
} LIBVIRT_1.1.1;
|
||||
|
||||
# .... define new API here using predicted next version number ....
|
||||
|
Loading…
Reference in New Issue
Block a user