Prefer xbzrle-cache-size migration parameter over the special
migrate-set-cache-size QMP command.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
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 e01c2a209d..476417c15d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2383,8 +2383,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
@@ -3383,8 +3382,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 53e105bec8..faaaa29cc9 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 e341f73900..4cb70f62a4 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