]> xenbits.xensource.com Git - libvirt.git/commitdiff
Introduce virDomainMigrate*CompressionCache APIs
authorJiri Denemark <jdenemar@redhat.com>
Mon, 18 Feb 2013 16:31:08 +0000 (17:31 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 22 Feb 2013 16:35:59 +0000 (17:35 +0100)
Introduce virDomainMigrateGetCompressionCache and
virDomainMigrateSetCompressionCache APIs.

include/libvirt/libvirt.h.in
python/generator.py
src/driver.h
src/libvirt.c
src/libvirt_public.syms

index 67d3b832dcbd6846377126c7a304f8aad6e50730..f6a7affb6ae3a0c235dfd86894702c640e1ee102 100644 (file)
@@ -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);
index 92a7f588e610dfb476336b9c47b108e0a2684747..e4c95797e99af0c6a0957532cb872d0b72a68784 100755 (executable)
@@ -444,6 +444,7 @@ skip_impl = (
     'virNodeGetCPUStats',
     'virNodeGetMemoryStats',
     'virDomainGetBlockJobInfo',
+    'virDomainMigrateGetCompressionCache',
     'virDomainMigrateGetMaxSpeed',
     'virDomainBlockStatsFlags',
     'virDomainSetBlockIoTune',
index 71b71f6a16fe08ad3decad43aae85397deffbe61..f60bf9372156dae3035728e11fbebaaa6973d068 100644 (file)
@@ -604,6 +604,15 @@ typedef int
     (*virDrvDomainMigrateSetMaxDowntime)(virDomainPtr domain,
                                          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,
@@ -1069,6 +1078,8 @@ struct _virDriver {
     virDrvDomainGetJobStats             domainGetJobStats;
     virDrvDomainAbortJob                domainAbortJob;
     virDrvDomainMigrateSetMaxDowntime   domainMigrateSetMaxDowntime;
+    virDrvDomainMigrateGetCompressionCache domainMigrateGetCompressionCache;
+    virDrvDomainMigrateSetCompressionCache domainMigrateSetCompressionCache;
     virDrvDomainMigrateGetMaxSpeed      domainMigrateGetMaxSpeed;
     virDrvDomainMigrateSetMaxSpeed      domainMigrateSetMaxSpeed;
     virDrvDomainEventRegisterAny        domainEventRegisterAny;
index f5ae26cf489240c69dabfd44598d98e49dcb3e09..934997a3a4ca344c72887d1250a44a2f1f792925 100644 (file)
@@ -17551,6 +17551,101 @@ error:
     return -1;
 }
 
+/**
+ * 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->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
index 361408fd82efdc6789f828022082ae91b5f09dde..ab993edeaf17beff2b9288ebae3aae79817448b2 100644 (file)
@@ -606,6 +606,8 @@ LIBVIRT_1.0.2 {
 LIBVIRT_1.0.3 {
     global:
         virDomainGetJobStats;
+        virDomainMigrateGetCompressionCache;
+        virDomainMigrateSetCompressionCache;
         virNodeDeviceLookupSCSIHostByWWN;
 } LIBVIRT_1.0.2;