[libvirt] [PATCH 10/14] Introduce virDomainMigrate*CompressionCache APIs

Jiri Denemark jdenemar at redhat.com
Tue Feb 19 12:35:48 UTC 2013


Introduce virDomainMigrateGetCompressionCache and
virDomainMigrateSetCompressionCache APIs.
---
 include/libvirt/libvirt.h.in |   7 +++
 python/generator.py          |   1 +
 src/driver.h                 |  11 +++++
 src/libvirt.c                | 100 +++++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms      |   2 +
 5 files changed, 121 insertions(+)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 9d1c6ea..7e89e2e 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1215,6 +1215,13 @@ int virDomainMigrateSetMaxDowntime (virDomainPtr domain,
                                     unsigned long long downtime,
                                     unsigned int flags);
 
+int virDomainMigrateGetCompressionCache(virDomainPtr domain,
+                                        unsigned long long *cacheSize,
+                                        unsigned int flags);
+int virDomainMigrateSetCompressionCache(virDomainPtr domain,
+                                        unsigned long long cacheSize,
+                                        unsigned int flags);
+
 int virDomainMigrateSetMaxSpeed(virDomainPtr domain,
                                 unsigned long bandwidth,
                                 unsigned int flags);
diff --git a/python/generator.py b/python/generator.py
index 92a7f58..e4c9579 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -444,6 +444,7 @@ skip_impl = (
     'virNodeGetCPUStats',
     'virNodeGetMemoryStats',
     'virDomainGetBlockJobInfo',
+    'virDomainMigrateGetCompressionCache',
     'virDomainMigrateGetMaxSpeed',
     'virDomainBlockStatsFlags',
     'virDomainSetBlockIoTune',
diff --git a/src/driver.h b/src/driver.h
index 71b71f6..f60bf93 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -605,6 +605,15 @@ typedef int
                                          unsigned long long downtime,
                                          unsigned int flags);
 typedef int
+    (*virDrvDomainMigrateGetCompressionCache)(virDomainPtr domain,
+                                              unsigned long long *cacheSize,
+                                              unsigned int flags);
+typedef int
+    (*virDrvDomainMigrateSetCompressionCache)(virDomainPtr domain,
+                                              unsigned long long cacheSize,
+                                              unsigned int flags);
+
+typedef int
     (*virDrvDomainMigrateSetMaxSpeed)(virDomainPtr domain,
                                       unsigned long bandwidth,
                                       unsigned int flags);
@@ -1069,6 +1078,8 @@ struct _virDriver {
     virDrvDomainGetJobStats             domainGetJobStats;
     virDrvDomainAbortJob                domainAbortJob;
     virDrvDomainMigrateSetMaxDowntime   domainMigrateSetMaxDowntime;
+    virDrvDomainMigrateGetCompressionCache domainMigrateGetCompressionCache;
+    virDrvDomainMigrateSetCompressionCache domainMigrateSetCompressionCache;
     virDrvDomainMigrateGetMaxSpeed      domainMigrateGetMaxSpeed;
     virDrvDomainMigrateSetMaxSpeed      domainMigrateSetMaxSpeed;
     virDrvDomainEventRegisterAny        domainEventRegisterAny;
diff --git a/src/libvirt.c b/src/libvirt.c
index 3611839..d1dca40 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -17550,6 +17550,106 @@ error:
 }
 
 /**
+ * virDomainMigrateGetCompressionCache:
+ * @domain: a domain object
+ * @cacheSize: return value of current size of the cache (in bytes)
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Gets current size of the cache (in bytes) used for compressing repeatedly
+ * transferred memory pages during live migration.
+ *
+ * Returns 0 in case of success, -1 otherwise.
+ */
+int
+virDomainMigrateGetCompressionCache(virDomainPtr domain,
+                                    unsigned long long *cacheSize,
+                                    unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain, "cacheSize=%p, flags=%x", cacheSize, flags);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+        virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+        virDispatchError(NULL);
+        return -1;
+    }
+
+    conn = domain->conn;
+
+    virCheckNonNullArgGoto(cacheSize, error);
+
+    if (conn->flags & VIR_CONNECT_RO) {
+        virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+        goto error;
+    }
+
+    if (conn->driver->domainMigrateGetCompressionCache) {
+        if (conn->driver->domainMigrateGetCompressionCache(domain, cacheSize,
+                                                           flags) < 0)
+            goto error;
+        return 0;
+    }
+
+    virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+error:
+    virDispatchError(conn);
+    return -1;
+}
+
+/**
+ * virDomainMigrateSetCompressionCache:
+ * @domain: a domain object
+ * @cacheSize: size of the cache (in bytes) used for compression
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Sets size of the cache (in bytes) used for compressing repeatedly
+ * transferred memory pages during live migration. It's supposed to be called
+ * while the domain is being live-migrated as a reaction to migration progress
+ * and increasing number of compression cache misses obtained from
+ * virDomainGetJobStats.
+ *
+ * Returns 0 in case of success, -1 otherwise.
+ */
+int
+virDomainMigrateSetCompressionCache(virDomainPtr domain,
+                                    unsigned long long cacheSize,
+                                    unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain, "cacheSize=%llu, flags=%x", cacheSize, flags);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+        virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+        virDispatchError(NULL);
+        return -1;
+    }
+
+    conn = domain->conn;
+    if (conn->flags & VIR_CONNECT_RO) {
+        virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+        goto error;
+    }
+
+    if (conn->driver->domainMigrateSetCompressionCache) {
+        if (conn->driver->domainMigrateSetCompressionCache(domain, cacheSize,
+                                                           flags) < 0)
+            goto error;
+        return 0;
+    }
+
+    virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+error:
+    virDispatchError(conn);
+    return -1;
+}
+
+/**
  * virDomainMigrateSetMaxSpeed:
  * @domain: a domain object
  * @bandwidth: migration bandwidth limit in Mbps
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 361408f..ab993ed 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -606,6 +606,8 @@ LIBVIRT_1.0.2 {
 LIBVIRT_1.0.3 {
     global:
         virDomainGetJobStats;
+        virDomainMigrateGetCompressionCache;
+        virDomainMigrateSetCompressionCache;
         virNodeDeviceLookupSCSIHostByWWN;
 } LIBVIRT_1.0.2;
 
-- 
1.8.1.2




More information about the libvir-list mailing list