Define helper function virdomainMigrateSetParameters and
virdomainMigrateGetParameters, which allow to or get multi-thread
compress parameters.
include/libvirt/libvirt-domain.h
* Define virdomainMigrateSetParameters, virdomainMigrateGetParameters
src/driver-hypervisor.h:
* Define domainMigrateSetParameters, domainMigrateGetParameters
src/libvirt-domain.c:
* Implement virdomainMigrateSetParameters
* Implement virdomainMigrateGetParameters
src/libvirt_public.syms:
* Export the new symbols
Signed-off-by: Eli Qiao <liyong.qiao(a)intel.com>
Signed-off-by: ShaoHe Feng <shaohe.feng(a)intel.com>
---
include/libvirt/libvirt-domain.h | 10 +++-
src/driver-hypervisor.h | 14 +++++
src/libvirt-domain.c | 110 +++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 5 ++
4 files changed, 137 insertions(+), 2 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 29b2b22..092d4f1 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -799,6 +799,14 @@ int virDomainMigrateGetMaxSpeed(virDomainPtr domain,
unsigned long *bandwidth,
unsigned int flags);
+int virDomainMigrateSetParameters(virDomainPtr dom,
+ virTypedParameterPtr params,
+ int nparams, unsigned int flags);
+
+int virDomainMigrateGetParameters(virDomainPtr dom,
+ virTypedParameterPtr params,
+ int *nparams, unsigned int flags);
+
char * virConnectGetDomainCapabilities(virConnectPtr conn,
const char *emulatorbin,
const char *arch,
@@ -2789,8 +2797,6 @@ int virDomainAbortJob(virDomainPtr dom);
*/
# define VIR_DOMAIN_JOB_COMPRESSION_OVERFLOW "compression_overflow"
-
-
/**
* VIR_DOMAIN_MIRGRATE_COMPRESSION_LEVEL:
*
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 3275343..7e5f619 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -712,6 +712,18 @@ typedef int
unsigned int flags);
typedef int
+(*virDrvDomainMigrateSetParameters)(virDomainPtr dom,
+ virTypedParameterPtr params,
+ int nparams,
+ unsigned int flags);
+
+typedef int
+(*virDrvDomainMigrateGetParameters)(virDomainPtr dom,
+ virTypedParameterPtr params,
+ int *nparams,
+ unsigned int flags);
+
+typedef int
(*virDrvConnectDomainEventRegisterAny)(virConnectPtr conn,
virDomainPtr dom,
int eventID,
@@ -1359,6 +1371,8 @@ struct _virHypervisorDriver {
virDrvDomainMigrateSetCompressionCache domainMigrateSetCompressionCache;
virDrvDomainMigrateGetMaxSpeed domainMigrateGetMaxSpeed;
virDrvDomainMigrateSetMaxSpeed domainMigrateSetMaxSpeed;
+ virDrvDomainMigrateSetParameters domainMigrateSetParameters;
+ virDrvDomainMigrateGetParameters domainMigrateGetParameters;
virDrvConnectDomainEventRegisterAny connectDomainEventRegisterAny;
virDrvConnectDomainEventDeregisterAny connectDomainEventDeregisterAny;
virDrvDomainManagedSave domainManagedSave;
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 2edba1a..c704af7 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -9165,6 +9165,116 @@ virDomainMigrateGetMaxSpeed(virDomainPtr domain,
/**
+ * virDomainMigrateSetParameters:
+ * @dom: a domain object
+ * @params: pointer to memory parameter objects
+ * @nparams: number of live mirgration compress parameter (this value can be
+ * the same or less than the number of parameters supported)
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * The parameters which will be used when doing live migration if we enable
+ * multi-thread compression. Currently it supports compress-level,
+ * compress-threads, decompress-threads. Not all hypervisors
+ * will support multi-thread compression.
+ *
+ * Returns 0 in case of success, -1 otherwise.
+ */
+int
+virDomainMigrateSetParameters(virDomainPtr dom,
+ virTypedParameterPtr params,
+ int nparams, unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(dom, "miagrateion set parameters "
+ "params=%p, nparams=%d, flags=%x", params, nparams,
flags);
+ VIR_TYPED_PARAMS_DEBUG(params, nparams);
+
+ virResetLastError();
+
+ virCheckDomainReturn(dom, -1);
+ conn = dom->conn;
+
+ virCheckReadOnlyGoto(conn->flags, error);
+ virCheckPositiveArgGoto(nparams, error);
+ virCheckNonNullArgGoto(params, error);
+
+ if (virTypedParameterValidateSet(dom->conn, params, nparams) < 0)
+ goto error;
+
+ if (conn->driver->domainMigrateSetParameters) {
+ if (conn->driver->domainMigrateSetParameters(
+ dom, params, nparams, flags) < 0)
+ goto error;
+ return 0;
+ }
+
+ virReportUnsupportedError();
+
+ error:
+ virDispatchError(conn);
+ return -1;
+}
+
+
+/**
+ * virDomainMigrateGetParameters:
+ * @dom: a domain object
+ * @params: pointer to memory parameter object
+ * (return value, allocated by the caller)
+ * @nparams: number of live mirgration compress parameter (this value can be
+ * the same or less than the number of parameters supported)
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Get parameters which will be used when doing live migration if we enable
+ * multi-thread compression. Currently it supports compress-level,
+ * compress-threads, decompress-threads. Not all hypervisors will
+ * support multi-thread compression.
+ *
+ * Returns 0 in case of success, -1 otherwise.
+ */
+int
+virDomainMigrateGetParameters(virDomainPtr dom,
+ virTypedParameterPtr params,
+ int *nparams, unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(dom, "miagrateion get parameters "
+ "params=%p, nparams=%d, flags=%x",
+ params, (nparams) ? *nparams : -1, flags);
+
+ virResetLastError();
+
+ virCheckDomainReturn(dom, -1);
+ conn = dom->conn;
+ virCheckNonNullArgGoto(nparams, error);
+ virCheckNonNegativeArgGoto(*nparams, error);
+ if (*nparams != 0)
+ virCheckNonNullArgGoto(params, error);
+
+ if (VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn,
+ VIR_DRV_FEATURE_TYPED_PARAM_STRING))
+ flags |= VIR_TYPED_PARAM_STRING_OKAY;
+
+
+ virCheckReadOnlyGoto(conn->flags, error);
+
+ if (conn->driver->domainMigrateGetParameters) {
+ if (conn->driver->domainMigrateGetParameters(
+ dom, params, nparams, flags) < 0)
+ goto error;
+ return 0;
+ }
+
+ virReportUnsupportedError();
+ error:
+ virDispatchError(conn);
+ return -1;
+}
+
+
+/**
* virConnectDomainEventRegisterAny:
* @conn: pointer to the connection
* @dom: pointer to the domain
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 716dd2f..b7a3cad 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -715,4 +715,9 @@ LIBVIRT_1.2.16 {
virDomainSetUserPassword;
} LIBVIRT_1.2.15;
+LIBVIRT_1.2.17 {
+ global:
+ virDomainMigrateSetParameters;
+ virDomainMigrateGetParameters;
+} LIBVIRT_1.2.16;
# .... define new API here using predicted next version number ....
--
2.1.4