Since every parameter or capability set in qemuMigrationCompression
structure is now reflected in qemuMigrationParams structure, we can
replace qemuMigrationAnyCompressionDump with a new API which will work
on qemuMigrationParams.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_driver.c | 6 ++--
src/qemu/qemu_migration.c | 16 ++++------
src/qemu/qemu_migration.h | 1 -
src/qemu/qemu_migration_params.c | 52 ++++++++++++++------------------
src/qemu/qemu_migration_params.h | 10 +++---
5 files changed, 37 insertions(+), 48 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3b0c3a3ffb..5e79e90609 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12297,7 +12297,7 @@ qemuDomainMigratePerform(virDomainPtr dom,
*/
ret = qemuMigrationSrcPerform(driver, dom->conn, vm, NULL,
NULL, dconnuri, uri, NULL, NULL, 0, NULL, 0,
- compression, migParams, cookie, cookielen,
+ migParams, cookie, cookielen,
NULL, NULL, /* No output cookies in v2 */
flags, dname, resource, false);
@@ -12743,7 +12743,7 @@ qemuDomainMigratePerform3(virDomainPtr dom,
ret = qemuMigrationSrcPerform(driver, dom->conn, vm, xmlin, NULL,
dconnuri, uri, NULL, NULL, 0, NULL, 0,
- compression, migParams,
+ migParams,
cookiein, cookieinlen,
cookieout, cookieoutlen,
flags, dname, resource, true);
@@ -12836,7 +12836,7 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
ret = qemuMigrationSrcPerform(driver, dom->conn, vm, dom_xml, persist_xml,
dconnuri, uri, graphicsuri, listenAddress,
nmigrate_disks, migrate_disks, nbdPort,
- compression, migParams,
+ migParams,
cookiein, cookieinlen, cookieout, cookieoutlen,
flags, dname, bandwidth, true);
cleanup:
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 1c5ee67929..319b4d000a 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3891,7 +3891,6 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver,
size_t nmigrate_disks,
const char **migrate_disks,
int nbdPort,
- qemuMigrationCompressionPtr compression,
qemuMigrationParamsPtr migParams,
unsigned long long bandwidth,
bool useParams,
@@ -3976,8 +3975,8 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver,
nbdPort) < 0)
goto cleanup;
- if (qemuMigrationAnyCompressionDump(compression, ¶ms, &nparams,
- &maxparams, &flags) < 0)
+ if (qemuMigrationParamsDump(migParams, ¶ms, &nparams,
+ &maxparams, &flags) < 0)
goto cleanup;
}
@@ -4250,7 +4249,6 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriverPtr driver,
size_t nmigrate_disks,
const char **migrate_disks,
int nbdPort,
- qemuMigrationCompressionPtr compression,
qemuMigrationParamsPtr migParams,
unsigned long flags,
const char *dname,
@@ -4375,7 +4373,7 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriverPtr driver,
ret = qemuMigrationSrcPerformPeer2Peer3(driver, sconn, dconn, dconnuri, vm,
xmlin,
persist_xml, dname, uri, graphicsuri,
listenAddress, nmigrate_disks,
migrate_disks,
- nbdPort, compression, migParams,
resource,
+ nbdPort, migParams, resource,
useParams, flags);
} else {
ret = qemuMigrationSrcPerformPeer2Peer2(driver, sconn, dconn, vm,
@@ -4416,7 +4414,6 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver,
size_t nmigrate_disks,
const char **migrate_disks,
int nbdPort,
- qemuMigrationCompressionPtr compression,
qemuMigrationParamsPtr migParams,
const char *cookiein,
int cookieinlen,
@@ -4455,7 +4452,7 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver,
ret = qemuMigrationSrcPerformPeer2Peer(driver, conn, vm, xmlin, persist_xml,
dconnuri, uri, graphicsuri,
listenAddress,
nmigrate_disks, migrate_disks, nbdPort,
- compression, migParams, flags, dname,
resource,
+ migParams, flags, dname, resource,
&v3proto);
} else {
qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_PERFORM2);
@@ -4606,7 +4603,6 @@ qemuMigrationSrcPerform(virQEMUDriverPtr driver,
size_t nmigrate_disks,
const char **migrate_disks,
int nbdPort,
- qemuMigrationCompressionPtr compression,
qemuMigrationParamsPtr migParams,
const char *cookiein,
int cookieinlen,
@@ -4638,7 +4634,7 @@ qemuMigrationSrcPerform(virQEMUDriverPtr driver,
return qemuMigrationSrcPerformJob(driver, conn, vm, xmlin, persist_xml, dconnuri,
uri,
graphicsuri, listenAddress,
nmigrate_disks, migrate_disks, nbdPort,
- compression, migParams,
+ migParams,
cookiein, cookieinlen,
cookieout, cookieoutlen,
flags, dname, resource, v3proto);
@@ -4661,7 +4657,7 @@ qemuMigrationSrcPerform(virQEMUDriverPtr driver,
return qemuMigrationSrcPerformJob(driver, conn, vm, xmlin, persist_xml,
NULL,
uri, graphicsuri, listenAddress,
nmigrate_disks, migrate_disks, nbdPort,
- compression, migParams,
+ migParams,
cookiein, cookieinlen,
cookieout, cookieoutlen, flags,
dname, resource, v3proto);
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index b135f740c1..e12b6972db 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -163,7 +163,6 @@ qemuMigrationSrcPerform(virQEMUDriverPtr driver,
size_t nmigrate_disks,
const char **migrate_disks,
int nbdPort,
- qemuMigrationCompressionPtr compression,
qemuMigrationParamsPtr migParams,
const char *cookiein,
int cookieinlen,
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index 5808aa761d..33d91ccf38 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -39,6 +39,7 @@ VIR_LOG_INIT("qemu.qemu_migration_params");
#define QEMU_MIGRATION_TLS_ALIAS_BASE "libvirt_migrate"
struct _qemuMigrationParams {
+ unsigned long long compMethods; /* bit-wise OR of qemuMigrationCompressMethod */
virBitmapPtr caps;
qemuMonitorMigrationParams params;
};
@@ -149,6 +150,8 @@ qemuMigrationParamsSetCompression(qemuMigrationCompressionPtr
compression,
ignore_value(virBitmapSetBit(migParams->caps,
QEMU_MONITOR_MIGRATION_CAPS_COMPRESS));
+ migParams->compMethods = compression->methods;
+
migParams->params.compressLevel_set = compression->level_set;
migParams->params.compressLevel = compression->level;
@@ -301,51 +304,42 @@ qemuMigrationAnyCompressionParse(virTypedParameterPtr params,
}
int
-qemuMigrationAnyCompressionDump(qemuMigrationCompressionPtr compression,
- virTypedParameterPtr *params,
- int *nparams,
- int *maxparams,
- unsigned long *flags)
+qemuMigrationParamsDump(qemuMigrationParamsPtr migParams,
+ virTypedParameterPtr *params,
+ int *nparams,
+ int *maxparams,
+ unsigned long *flags)
{
size_t i;
- if (compression->methods == 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE
&&
- !compression->xbzrle_cache_set) {
+ if (migParams->compMethods == 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE
&&
+ !migParams->params.xbzrleCacheSize_set) {
*flags |= VIR_MIGRATE_COMPRESSED;
return 0;
}
for (i = 0; i < QEMU_MIGRATION_COMPRESS_LAST; ++i) {
- if ((compression->methods & (1ULL << i)) &&
+ if ((migParams->compMethods & (1ULL << i)) &&
virTypedParamsAddString(params, nparams, maxparams,
VIR_MIGRATE_PARAM_COMPRESSION,
qemuMigrationCompressMethodTypeToString(i)) < 0)
return -1;
}
- if (compression->level_set &&
- virTypedParamsAddInt(params, nparams, maxparams,
- VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL,
- compression->level) < 0)
- return -1;
+#define SET(API, PARAM, VAR) \
+ do { \
+ if (migParams->params.VAR ## _set && \
+ API(params, nparams, maxparams, VIR_MIGRATE_PARAM_ ## PARAM, \
+ migParams->params.VAR) < 0) \
+ return -1; \
+ } while (0)
- if (compression->threads_set &&
- virTypedParamsAddInt(params, nparams, maxparams,
- VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS,
- compression->threads) < 0)
- return -1;
+ SET(virTypedParamsAddInt, COMPRESSION_MT_LEVEL, compressLevel);
+ SET(virTypedParamsAddInt, COMPRESSION_MT_THREADS, compressThreads);
+ SET(virTypedParamsAddInt, COMPRESSION_MT_DTHREADS, decompressThreads);
+ SET(virTypedParamsAddULLong, COMPRESSION_XBZRLE_CACHE, xbzrleCacheSize);
- if (compression->dthreads_set &&
- virTypedParamsAddInt(params, nparams, maxparams,
- VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS,
- compression->dthreads) < 0)
- return -1;
-
- if (compression->xbzrle_cache_set &&
- virTypedParamsAddULLong(params, nparams, maxparams,
- VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE,
- compression->xbzrle_cache) < 0)
- return -1;
+#undef SET
return 0;
}
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
index 65bd3125dc..d778a8e339 100644
--- a/src/qemu/qemu_migration_params.h
+++ b/src/qemu/qemu_migration_params.h
@@ -68,11 +68,11 @@ qemuMigrationAnyCompressionParse(virTypedParameterPtr params,
int nparams,
unsigned long flags);
int
-qemuMigrationAnyCompressionDump(qemuMigrationCompressionPtr compression,
- virTypedParameterPtr *params,
- int *nparams,
- int *maxparams,
- unsigned long *flags);
+qemuMigrationParamsDump(qemuMigrationParamsPtr migParams,
+ virTypedParameterPtr *params,
+ int *nparams,
+ int *maxparams,
+ unsigned long *flags);
void
qemuMigrationParamsFree(qemuMigrationParamsPtr migParams);
--
2.17.0