Re: [PATCH v3 6/7] qemu migration: add xbzrle compression options

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

 



28.01.2016 10:04, Nikolay Shirokovskiy пишет:
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
  include/libvirt/libvirt-domain.h |  8 ++++++++
  src/qemu/qemu_domain.c           |  1 +
  src/qemu/qemu_domain.h           |  1 +
  src/qemu/qemu_driver.c           | 16 ++++++++++++++++
  src/qemu/qemu_migration.c        |  8 ++++++++
  src/qemu/qemu_migration.h        |  2 ++
  6 files changed, 36 insertions(+)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 36f6e09..c7388c0 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -791,6 +791,14 @@ typedef enum {
   */
  # define VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS "compression.mt.dthreads"
+/**
+ * VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE:
+ *
+ * virDomainMigrate* params field: the size of page cache for xbzrle
+ * compression as VIR_TYPED_PARAM_ULLONG.
+ */
+# define VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE "compression.xbzrle.cache"
+
  /* Domain migration. */
  virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn,
                                 unsigned long flags, const char *dname,
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 03ddee2..2a32c94 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -494,6 +494,7 @@ qemuDomainObjPrivateAlloc(void)
      priv->migrationMT.level = 1;
      priv->migrationMT.threads = 8;
      priv->migrationMT.dthreads = 2;
+    priv->xbzrleCache = 64 * (1 << 20);
return priv; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 48554cd..98165a2 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -183,6 +183,7 @@ struct _qemuDomainObjPrivate {
      unsigned short migrationPort;
      int preMigrationState;
      qemuMonitorMigrationMTParameters migrationMT;
+    unsigned long long xbzrleCache;
virChrdevsPtr devs; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index eb3fd80..6938e13 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12473,6 +12473,20 @@ qemuGetCompression(virTypedParameterPtr params, int nparams,
          return -1;
      }
+ if (virTypedParamsGet(params, nparams,
+                          VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE) != NULL &&
+        !(compression->method & QEMU_MIGRATION_COMPESS_XBZRLE)) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("You cannot specify xbzrle compression "
+                          "parameters without turning it on."));
+        return -1;
+    }
+
+    if (virTypedParamsGetULLong(params, nparams,
+                                VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE,
+                                &compression->xbzrle_cache) < 0)
+        return -1;
+
      return 0;
  }
@@ -13491,6 +13505,8 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr dom,
      } else if (ret > 0) {
          VIR_DEBUG("Setting compression cache to %llu B", cacheSize);
          ret = qemuMonitorSetMigrationCacheSize(priv->mon, cacheSize);
+        if (ret == 0)
+            priv->xbzrleCache = cacheSize;
      }
if (qemuDomainObjExitMonitor(driver, vm) < 0)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 81ff6b3..efba84d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3340,6 +3340,10 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver,
                                              compression->mt.dthreads :
                                              priv->migrationMT.dthreads;
+ merged.xbzrle_cache = compression->xbzrle_cache != 0 ?
+                                            compression->xbzrle_cache :
+                                            priv->xbzrleCache;
+
      if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0)
          return -1;
@@ -3347,6 +3351,10 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver,
          qemuMonitorSetMigrationCompressParametersMT(priv->mon, &merged.mt) < 0)
          goto cleanup;
+ if ((compression->method & QEMU_MIGRATION_COMPESS_XBZRLE) &&
+        qemuMonitorSetMigrationCacheSize(priv->mon, merged.xbzrle_cache) < 0)
+        goto cleanup;
+
      ret = 0;
cleanup:
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 63c6a1a..70a37db 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -61,6 +61,7 @@ typedef qemuMigrationCompression *qemuMigrationCompressionPtr;
      VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL,         VIR_TYPED_PARAM_INT,   \
      VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS,       VIR_TYPED_PARAM_UINT,   \
      VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS,      VIR_TYPED_PARAM_UINT,   \
+    VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE,     VIR_TYPED_PARAM_ULLONG, \
      NULL
@@ -88,6 +89,7 @@ typedef enum {
  struct _qemuMigrationCompression {
      qemuMigrationCompressMethod method;
      qemuMonitorMigrationMTParameters mt;
+    unsigned long long xbzrle_cache;
  };
void qemuMigrationCompressionInit(qemuMigrationCompressionPtr compression);
ACK

--
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]