mirror of https://gitee.com/openkylin/libvirt.git
virNodeGetCPUMap: Define public API.
Adding a new API to obtain information about the host node's present, online and offline CPUs. int virNodeGetCPUMap(virConnectPtr conn, unsigned char **cpumap, unsigned int *online, unsigned int flags); The function will return the number of CPUs present on the host or -1 on failure; If cpumap is non-NULL virNodeGetCPUMap will allocate an array containing a bit map representation of the online CPUs. It's the callers responsibility to deallocate cpumap using free(). If online is non-NULL, the variable pointed to will contain the number of online host node CPUs. The variable flags has been added to support future extensions and must be set to 0. Extend the driver structure by nodeGetCPUMap entry in support of the new API virNodeGetCPUMap. Added implementation of virNodeGetCPUMap to libvirt.c Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
5a2e1185bd
commit
7ecc1d814a
|
@ -750,6 +750,14 @@ int virNodeSetMemoryParameters(virConnectPtr conn,
|
|||
int nparams,
|
||||
unsigned int flags);
|
||||
|
||||
/*
|
||||
* node CPU map
|
||||
*/
|
||||
int virNodeGetCPUMap(virConnectPtr conn,
|
||||
unsigned char **cpumap,
|
||||
unsigned int *online,
|
||||
unsigned int flags);
|
||||
|
||||
|
||||
/* Management of scheduler parameters */
|
||||
|
||||
|
|
|
@ -429,6 +429,7 @@ skip_impl = (
|
|||
'virConnectRegisterCloseCallback',
|
||||
'virNodeGetMemoryParameters',
|
||||
'virNodeSetMemoryParameters',
|
||||
'virNodeGetCPUMap',
|
||||
)
|
||||
|
||||
qemu_skip_impl = (
|
||||
|
|
|
@ -898,6 +898,12 @@ typedef int
|
|||
int nparams,
|
||||
unsigned int flags);
|
||||
|
||||
typedef int
|
||||
(*virDrvNodeGetCPUMap)(virConnectPtr conn,
|
||||
unsigned char **cpumap,
|
||||
unsigned int *online,
|
||||
unsigned int flags);
|
||||
|
||||
/**
|
||||
* _virDriver:
|
||||
*
|
||||
|
@ -1087,6 +1093,7 @@ struct _virDriver {
|
|||
virDrvDomainGetMetadata domainGetMetadata;
|
||||
virDrvNodeGetMemoryParameters nodeGetMemoryParameters;
|
||||
virDrvNodeSetMemoryParameters nodeSetMemoryParameters;
|
||||
virDrvNodeGetCPUMap nodeGetCPUMap;
|
||||
};
|
||||
|
||||
typedef int
|
||||
|
|
|
@ -20106,3 +20106,54 @@ error:
|
|||
virDispatchError(domain->conn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* virNodeGetCPUMap:
|
||||
* @conn: pointer to the hypervisor connection
|
||||
* @cpumap: optional pointer to a bit map of real CPUs on the host node
|
||||
* (in 8-bit bytes) (OUT)
|
||||
* In case of success each bit set to 1 means that corresponding
|
||||
* CPU is online.
|
||||
* Bytes are stored in little-endian order: CPU0-7, 8-15...
|
||||
* In each byte, lowest CPU number is least significant bit.
|
||||
* The bit map is allocated by virNodeGetCPUMap and needs
|
||||
* to be released using free() by the caller.
|
||||
* @online: optional number of online CPUs in cpumap (OUT)
|
||||
* Contains the number of online CPUs if the call was successful.
|
||||
* @flags: extra flags; not used yet, so callers should always pass 0
|
||||
*
|
||||
* Get CPU map of host node CPUs.
|
||||
*
|
||||
* Returns number of CPUs present on the host node,
|
||||
* or -1 if there was an error.
|
||||
*/
|
||||
int
|
||||
virNodeGetCPUMap(virConnectPtr conn,
|
||||
unsigned char **cpumap,
|
||||
unsigned int *online,
|
||||
unsigned int flags)
|
||||
{
|
||||
VIR_DEBUG("conn=%p, cpumap=%p, online=%p, flags=%x",
|
||||
conn, cpumap, online, flags);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
if (!VIR_IS_CONNECT(conn)) {
|
||||
virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__);
|
||||
virDispatchError(NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (conn->driver->nodeGetCPUMap) {
|
||||
int ret = conn->driver->nodeGetCPUMap(conn, cpumap, online, flags);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
|
||||
error:
|
||||
virDispatchError(conn);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -569,4 +569,9 @@ LIBVIRT_0.10.2 {
|
|||
virStoragePoolListAllVolumes;
|
||||
} LIBVIRT_0.10.0;
|
||||
|
||||
LIBVIRT_1.0.0 {
|
||||
global:
|
||||
virNodeGetCPUMap;
|
||||
} LIBVIRT_0.10.2;
|
||||
|
||||
# .... define new API here using predicted next version number ....
|
||||
|
|
Loading…
Reference in New Issue