[PATCH V2 6/9] Implement the public APIs for multi-thread compress parameters.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Signed-off-by: ShaoHe Feng <shaohe.feng@xxxxxxxxx>
---
 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 d6fca47..f7c10c2 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -808,6 +808,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,
@@ -2798,8 +2806,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 909c264..20f2012 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -9140,6 +9140,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 2c653f2..32c2f7a 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -720,4 +720,9 @@ LIBVIRT_1.2.17 {
         virTypedParamsAddStringList;
 } LIBVIRT_1.2.16;
 
+LIBVIRT_1.2.18 {
+    global:
+        virDomainMigrateSetParameters;
+        virDomainMigrateGetParameters;
+} LIBVIRT_1.2.17;
 # .... define new API here using predicted next version number ....
-- 
2.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]