Set up the types for the numa functions and insert them into the
virDriver structure definition.
---
include/libvirt/libvirt.h.in | 39 +++++++++++++
python/generator.py | 2 +
src/conf/domain_conf.h | 8 ---
src/driver.h | 15 +++++
src/libvirt.c | 129 ++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 6 ++
6 files changed, 191 insertions(+), 8 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 2480add..7f26521 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -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
*/
diff --git a/python/generator.py b/python/generator.py
index 1657f4f..181f70e 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -383,6 +383,8 @@ skip_impl = (
'virDomainGetBlkioParameters',
'virDomainSetMemoryParameters',
'virDomainGetMemoryParameters',
+ 'virDomainSetNumaParameters',
+ 'virDomainGetNumaParameters',
'virDomainGetVcpus',
'virDomainPinVcpu',
'virDomainPinVcpuFlags',
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3229a6f..189b8f6 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -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 {
diff --git a/src/driver.h b/src/driver.h
index 941ff51..bbd6417 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -158,6 +158,19 @@ typedef int
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,
virTypedParameterPtr params,
@@ -816,6 +829,8 @@ struct _virDriver {
virDrvDomainSetMemoryFlags domainSetMemoryFlags;
virDrvDomainSetMemoryParameters domainSetMemoryParameters;
virDrvDomainGetMemoryParameters domainGetMemoryParameters;
+ virDrvDomainSetNumaParameters domainSetNumaParameters;
+ virDrvDomainGetNumaParameters domainGetNumaParameters;
virDrvDomainSetBlkioParameters domainSetBlkioParameters;
virDrvDomainGetBlkioParameters domainGetBlkioParameters;
virDrvDomainGetInfo domainGetInfo;
diff --git a/src/libvirt.c b/src/libvirt.c
index 9977915..574be16 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3769,6 +3769,135 @@ error:
}
/**
+ * 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
* @params: pointer to blkio parameter objects
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 164039a..3709f08 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -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 ....
--
1.7.4.4