提交 c57ca570 编写于 作者: H Hu Tao 提交者: Eric Blake

add new API virDomain{G, S}etNumaParameters

Set up the types for the numa functions and insert them into the
virDriver structure definition.
上级 9d3a721a
......@@ -1344,6 +1344,45 @@ typedef enum {
} virDomainMemoryModFlags;
/* Manage numa parameters */
/**
* virDomainNumatuneMemMode:
* Representation of the various modes in the <numatune> element of
* a domain.
*/
typedef enum {
VIR_DOMAIN_NUMATUNE_MEM_STRICT = 0,
VIR_DOMAIN_NUMATUNE_MEM_PREFERRED = 1,
VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE = 2,
/* This constant is subject to change */
VIR_DOMAIN_NUMATUNE_MEM_LAST
} virDomainNumatuneMemMode;
/**
* VIR_DOMAIN_NUMA_NODESET:
*
* Macro for typed parameter name that lists the numa nodeset of a
* domain, as a string.
*/
#define VIR_DOMAIN_NUMA_NODESET "numa_nodeset"
/**
* VIR_DOMAIN_NUMA_MODE:
*
* Macro for typed parameter name that lists the numa mode of a domain,
* as an int containing a virDomainNumatuneMemMode value.
*/
#define VIR_DOMAIN_NUMA_MODE "numa_mode"
int virDomainSetNumaParameters(virDomainPtr domain,
virTypedParameterPtr params,
int nparams, unsigned int flags);
int virDomainGetNumaParameters(virDomainPtr domain,
virTypedParameterPtr params,
int *nparams, unsigned int flags);
/*
* Dynamic control of domains
*/
......
......@@ -383,6 +383,8 @@ skip_impl = (
'virDomainGetBlkioParameters',
'virDomainSetMemoryParameters',
'virDomainGetMemoryParameters',
'virDomainSetNumaParameters',
'virDomainGetNumaParameters',
'virDomainGetVcpus',
'virDomainPinVcpu',
'virDomainPinVcpuFlags',
......
......@@ -1355,14 +1355,6 @@ virDomainVcpuPinDefPtr virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def,
int nvcpupin,
int vcpu);
enum virDomainNumatuneMemMode {
VIR_DOMAIN_NUMATUNE_MEM_STRICT,
VIR_DOMAIN_NUMATUNE_MEM_PREFERRED,
VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE,
VIR_DOMAIN_NUMATUNE_MEM_LAST
};
typedef struct _virDomainNumatuneDef virDomainNumatuneDef;
typedef virDomainNumatuneDef *virDomainNumatuneDefPtr;
struct _virDomainNumatuneDef {
......
......@@ -157,6 +157,19 @@ typedef int
virTypedParameterPtr params,
int *nparams,
unsigned int flags);
typedef int
(*virDrvDomainSetNumaParameters)
(virDomainPtr domain,
virTypedParameterPtr params,
int nparams,
unsigned int flags);
typedef int
(*virDrvDomainGetNumaParameters)
(virDomainPtr domain,
virTypedParameterPtr params,
int *nparams,
unsigned int flags);
typedef int
(*virDrvDomainSetBlkioParameters)
(virDomainPtr domain,
......@@ -816,6 +829,8 @@ struct _virDriver {
virDrvDomainSetMemoryFlags domainSetMemoryFlags;
virDrvDomainSetMemoryParameters domainSetMemoryParameters;
virDrvDomainGetMemoryParameters domainGetMemoryParameters;
virDrvDomainSetNumaParameters domainSetNumaParameters;
virDrvDomainGetNumaParameters domainGetNumaParameters;
virDrvDomainSetBlkioParameters domainSetBlkioParameters;
virDrvDomainGetBlkioParameters domainGetBlkioParameters;
virDrvDomainGetInfo domainGetInfo;
......
......@@ -3768,6 +3768,135 @@ error:
return -1;
}
/**
* virDomainSetNumaParameters:
* @domain: pointer to domain object
* @params: pointer to numa parameter objects
* @nparams: number of numa parameters (this value can be the same or
* less than the number of parameters supported)
* @flags: bitwise-OR of virDomainModificationImpact
*
* Change all or a subset of the numa tunables.
* This function may require privileged access to the hypervisor.
*
* Returns -1 in case of error, 0 in case of success.
*/
int
virDomainSetNumaParameters(virDomainPtr domain,
virTypedParameterPtr params,
int nparams, unsigned int flags)
{
virConnectPtr conn;
VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%d, flags=%x",
params, nparams, flags);
virResetLastError();
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
virDispatchError(NULL);
return -1;
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
goto error;
}
if ((nparams <= 0) || (params == NULL)) {
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
if (virTypedParameterValidateSet(domain, params, nparams) < 0)
return -1;
conn = domain->conn;
if (conn->driver->domainSetNumaParameters) {
int ret;
ret = conn->driver->domainSetNumaParameters(domain, params, nparams,
flags);
if (ret < 0)
goto error;
return ret;
}
virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
error:
virDispatchError(domain->conn);
return -1;
}
/**
* virDomainGetNumaParameters:
* @domain: pointer to domain object
* @params: pointer to numa parameter object
* (return value, allocated by the caller)
* @nparams: pointer to number of numa parameters
* @flags: bitwise-OR of virDomainModificationImpact and virTypedParameterFlags
*
* Get all numa parameters. On input, @nparams gives the size of the
* @params array; on output, @nparams gives how many slots were filled
* with parameter information, which might be less but will not exceed
* the input value.
*
* As a special case, calling with @params as NULL and @nparams as 0 on
* input will cause @nparams on output to contain the number of parameters
* supported by the hypervisor. The caller should then allocate @params
* array, i.e. (sizeof(@virTypedParameter) * @nparams) bytes and call the API
* again.
*
* See virDomainGetMemoryParameters() for an equivalent usage example.
*
* This function may require privileged access to the hypervisor. This function
* expects the caller to allocate the @params.
*
* Returns -1 in case of error, 0 in case of success.
*/
int
virDomainGetNumaParameters(virDomainPtr domain,
virTypedParameterPtr params,
int *nparams, unsigned int flags)
{
virConnectPtr conn;
VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%d, flags=%x",
params, (nparams) ? *nparams : -1, flags);
virResetLastError();
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
virDispatchError(NULL);
return -1;
}
if ((nparams == NULL) || (*nparams < 0) ||
(params == NULL && *nparams != 0)) {
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_TYPED_PARAM_STRING))
flags |= VIR_TYPED_PARAM_STRING_OKAY;
conn = domain->conn;
if (conn->driver->domainGetNumaParameters) {
int ret;
ret = conn->driver->domainGetNumaParameters(domain, params, nparams,
flags);
if (ret < 0)
goto error;
return ret;
}
virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
error:
virDispatchError(domain->conn);
return -1;
}
/**
* virDomainSetBlkioParameters:
* @domain: pointer to domain object
......
......@@ -508,4 +508,10 @@ LIBVIRT_0.9.8 {
virNodeSuspendForDuration;
} LIBVIRT_0.9.7;
LIBVIRT_0.9.9 {
global:
virDomainGetNumaParameters;
virDomainSetNumaParameters;
} LIBVIRT_0.9.8;
# .... define new API here using predicted next version number ....
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册