[PATCH 29/68] qemu: Set XBZRLE cache size via migration parameters

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

 



Prefer xbzrle-cache-size migration parameter over the special
migrate-set-cache-size QMP command.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c        |  6 ++---
 src/qemu/qemu_migration_params.c | 42 +++++++++++++++++---------------
 src/qemu/qemu_migration_params.h |  4 +--
 3 files changed, 25 insertions(+), 27 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 6b0c7545a1..9758d20d99 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2386,8 +2386,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
     if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
         goto stopjob;
 
-    if (qemuMigrationParamsSetCompression(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
-                                          compression, migParams) < 0)
+    if (qemuMigrationParamsSetCompression(vm, compression, migParams) < 0)
         goto stopjob;
 
     /* Migrations using TLS need to add the "tls-creds-x509" object and
@@ -3386,8 +3385,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
             goto error;
     }
 
-    if (qemuMigrationParamsSetCompression(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
-                                          compression, migParams) < 0)
+    if (qemuMigrationParamsSetCompression(vm, compression, migParams) < 0)
         goto error;
 
     if (qemuMigrationParamsSetCapability(vm,
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index 83d3247017..ec1d2be6a0 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -141,6 +141,7 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver,
                          qemuMigrationParamsPtr migParams)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
+    bool xbzrleCacheSize_old = false;
     int ret = -1;
 
     if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
@@ -150,6 +151,20 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver,
                                             migParams->caps) < 0)
         goto cleanup;
 
+    /* If QEMU is too old to support xbzrle-cache-size migration parameter,
+     * we need to set it via migrate-set-cache-size and tell
+     * qemuMonitorSetMigrationParams to ignore this parameter.
+     */
+    if (migParams->params.xbzrleCacheSize_set &&
+        (!priv->job.migParams ||
+         !priv->job.migParams->params.xbzrleCacheSize_set)) {
+        if (qemuMonitorSetMigrationCacheSize(priv->mon,
+                                             migParams->params.xbzrleCacheSize) < 0)
+            goto cleanup;
+        xbzrleCacheSize_old = true;
+        migParams->params.xbzrleCacheSize_set = false;
+    }
+
     if (qemuMonitorSetMigrationParams(priv->mon, &migParams->params) < 0)
         goto cleanup;
 
@@ -159,6 +174,9 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver,
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         ret = -1;
 
+    if (xbzrleCacheSize_old)
+        migParams->params.xbzrleCacheSize_set = true;
+
     return ret;
 }
 
@@ -321,15 +339,10 @@ qemuMigrationParamsDisableTLS(virDomainObjPtr vm,
 
 
 int
-qemuMigrationParamsSetCompression(virQEMUDriverPtr driver,
-                                  virDomainObjPtr vm,
-                                  int asyncJob,
+qemuMigrationParamsSetCompression(virDomainObjPtr vm,
                                   qemuMigrationCompressionPtr compression,
                                   qemuMigrationParamsPtr migParams)
 {
-    int ret = -1;
-    qemuDomainObjPrivatePtr priv = vm->privateData;
-
     if (qemuMigrationParamsSetCapability(vm,
                                          QEMU_MONITOR_MIGRATION_CAPS_XBZRLE,
                                          compression->methods &
@@ -344,9 +357,6 @@ qemuMigrationParamsSetCompression(virQEMUDriverPtr driver,
                                          migParams) < 0)
         return -1;
 
-    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
-        return -1;
-
     migParams->params.compressLevel_set = compression->level_set;
     migParams->params.compressLevel = compression->level;
 
@@ -356,18 +366,10 @@ qemuMigrationParamsSetCompression(virQEMUDriverPtr driver,
     migParams->params.decompressThreads_set = compression->dthreads_set;
     migParams->params.decompressThreads = compression->dthreads;
 
-    if (compression->xbzrle_cache_set &&
-        qemuMonitorSetMigrationCacheSize(priv->mon,
-                                         compression->xbzrle_cache) < 0)
-        goto cleanup;
+    migParams->params.xbzrleCacheSize_set = compression->xbzrle_cache_set;
+    migParams->params.xbzrleCacheSize = compression->xbzrle_cache;
 
-    ret = 0;
-
- cleanup:
-    if (qemuDomainObjExitMonitor(driver, vm) < 0)
-        ret = -1;
-
-    return ret;
+    return 0;
 }
 
 
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
index e881ee202d..6cfac1f78f 100644
--- a/src/qemu/qemu_migration_params.h
+++ b/src/qemu/qemu_migration_params.h
@@ -94,9 +94,7 @@ qemuMigrationParamsDisableTLS(virDomainObjPtr vm,
                               qemuMigrationParamsPtr migParams);
 
 int
-qemuMigrationParamsSetCompression(virQEMUDriverPtr driver,
-                                  virDomainObjPtr vm,
-                                  int asyncJob,
+qemuMigrationParamsSetCompression(virDomainObjPtr vm,
                                   qemuMigrationCompressionPtr compression,
                                   qemuMigrationParamsPtr migParams);
 
-- 
2.17.0

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

  Powered by Linux