mirror of https://gitee.com/openkylin/libvirt.git
qemu: migration: support setting compession parameters
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
parent
f9433ea019
commit
061e24285f
|
@ -797,6 +797,39 @@ typedef enum {
|
||||||
*/
|
*/
|
||||||
# define VIR_MIGRATE_PARAM_COMPRESSION "compression"
|
# define VIR_MIGRATE_PARAM_COMPRESSION "compression"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL:
|
||||||
|
*
|
||||||
|
* virDomainMigrate* params field: the level of compression for multithread
|
||||||
|
* compression as VIR_TYPED_PARAM_INT. Accepted values are in range 0-9.
|
||||||
|
* 0 is no compression, 1 is maximum speed and 9 is maximum compression.
|
||||||
|
*/
|
||||||
|
# define VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL "compression.mt.level"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS:
|
||||||
|
*
|
||||||
|
* virDomainMigrate* params field: the number of compression threads for
|
||||||
|
* multithread compression as VIR_TYPED_PARAM_INT.
|
||||||
|
*/
|
||||||
|
# define VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS "compression.mt.threads"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS:
|
||||||
|
*
|
||||||
|
* virDomainMigrate* params field: the number of decompression threads for
|
||||||
|
* multithread compression as VIR_TYPED_PARAM_INT.
|
||||||
|
*/
|
||||||
|
# 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. */
|
/* Domain migration. */
|
||||||
virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn,
|
virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn,
|
||||||
unsigned long flags, const char *dname,
|
unsigned long flags, const char *dname,
|
||||||
|
|
|
@ -3424,6 +3424,10 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver,
|
||||||
qemuDomainAsyncJob job,
|
qemuDomainAsyncJob job,
|
||||||
qemuMigrationCompressionPtr compression)
|
qemuMigrationCompressionPtr compression)
|
||||||
{
|
{
|
||||||
|
int ret = -1;
|
||||||
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
qemuMonitorMigrationCompressionPtr params = &compression->params;
|
||||||
|
|
||||||
if (qemuMigrationSetOption(driver, vm,
|
if (qemuMigrationSetOption(driver, vm,
|
||||||
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE,
|
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE,
|
||||||
compression->methods &
|
compression->methods &
|
||||||
|
@ -3438,7 +3442,25 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver,
|
||||||
job) < 0)
|
job) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if ((params->level_set || params->threads_set || params->dthreads_set) &&
|
||||||
|
qemuMonitorSetMigrationCompression(priv->mon, params) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (compression->xbzrle_cache_set &&
|
||||||
|
qemuMonitorSetMigrationCacheSize(priv->mon,
|
||||||
|
compression->xbzrle_cache) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
|
ret = -1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -6621,6 +6643,7 @@ qemuMigrationCompressionParse(virTypedParameterPtr params,
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
qemuMigrationCompressionPtr compression = NULL;
|
qemuMigrationCompressionPtr compression = NULL;
|
||||||
|
qemuMonitorMigrationCompressionPtr cparams;
|
||||||
|
|
||||||
if (VIR_ALLOC(compression) < 0)
|
if (VIR_ALLOC(compression) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -6649,6 +6672,47 @@ qemuMigrationCompressionParse(virTypedParameterPtr params,
|
||||||
compression->methods |= 1ULL << method;
|
compression->methods |= 1ULL << method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define GET_PARAM(PARAM, TYPE, PARENT, VALUE) \
|
||||||
|
do { \
|
||||||
|
int rc; \
|
||||||
|
\
|
||||||
|
if ((rc = virTypedParamsGet ## TYPE(params, nparams, \
|
||||||
|
PARAM, &PARENT->VALUE)) < 0) \
|
||||||
|
goto error; \
|
||||||
|
\
|
||||||
|
if (rc == 1) \
|
||||||
|
PARENT->VALUE ## _set = true; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
cparams = &compression->params;
|
||||||
|
|
||||||
|
if (params) {
|
||||||
|
GET_PARAM(VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL, Int,
|
||||||
|
cparams, level);
|
||||||
|
GET_PARAM(VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS, Int,
|
||||||
|
cparams, threads);
|
||||||
|
GET_PARAM(VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS, Int,
|
||||||
|
cparams, dthreads);
|
||||||
|
GET_PARAM(VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE, ULLong,
|
||||||
|
compression, xbzrle_cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef GET_PARAM
|
||||||
|
|
||||||
|
if ((cparams->level_set || cparams->threads_set || cparams->dthreads_set) &&
|
||||||
|
!(compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_MT))) {
|
||||||
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
|
_("Turn multithread compression on to tune it"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compression->xbzrle_cache_set &&
|
||||||
|
!(compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE))) {
|
||||||
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
|
_("Turn xbzrle compression on to tune it"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (!compression->methods && (flags & VIR_MIGRATE_COMPRESSED))
|
if (!compression->methods && (flags & VIR_MIGRATE_COMPRESSED))
|
||||||
compression->methods = 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE;
|
compression->methods = 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE;
|
||||||
|
|
||||||
|
@ -6667,8 +6731,10 @@ qemuMigrationCompressionDump(qemuMigrationCompressionPtr compression,
|
||||||
unsigned long *flags)
|
unsigned long *flags)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
qemuMonitorMigrationCompressionPtr cparams = &compression->params;
|
||||||
|
|
||||||
if (compression->methods == 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE) {
|
if (compression->methods == 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE &&
|
||||||
|
!compression->xbzrle_cache_set) {
|
||||||
*flags |= VIR_MIGRATE_COMPRESSED;
|
*flags |= VIR_MIGRATE_COMPRESSED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -6681,5 +6747,29 @@ qemuMigrationCompressionDump(qemuMigrationCompressionPtr compression,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cparams->level_set &&
|
||||||
|
virTypedParamsAddInt(params, nparams, maxparams,
|
||||||
|
VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL,
|
||||||
|
cparams->level) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (cparams->threads_set &&
|
||||||
|
virTypedParamsAddInt(params, nparams, maxparams,
|
||||||
|
VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS,
|
||||||
|
cparams->threads) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (cparams->dthreads_set &&
|
||||||
|
virTypedParamsAddInt(params, nparams, maxparams,
|
||||||
|
VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS,
|
||||||
|
cparams->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;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,10 @@ typedef qemuMigrationCompression *qemuMigrationCompressionPtr;
|
||||||
VIR_MIGRATE_PARAM_DISKS_PORT, VIR_TYPED_PARAM_INT, \
|
VIR_MIGRATE_PARAM_DISKS_PORT, VIR_TYPED_PARAM_INT, \
|
||||||
VIR_MIGRATE_PARAM_COMPRESSION, VIR_TYPED_PARAM_STRING | \
|
VIR_MIGRATE_PARAM_COMPRESSION, VIR_TYPED_PARAM_STRING | \
|
||||||
VIR_TYPED_PARAM_MULTIPLE, \
|
VIR_TYPED_PARAM_MULTIPLE, \
|
||||||
|
VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL, VIR_TYPED_PARAM_INT, \
|
||||||
|
VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS, VIR_TYPED_PARAM_INT, \
|
||||||
|
VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS, VIR_TYPED_PARAM_INT, \
|
||||||
|
VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE, VIR_TYPED_PARAM_ULLONG, \
|
||||||
NULL
|
NULL
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,6 +93,11 @@ VIR_ENUM_DECL(qemuMigrationCompressMethod)
|
||||||
|
|
||||||
struct _qemuMigrationCompression {
|
struct _qemuMigrationCompression {
|
||||||
unsigned long long methods;
|
unsigned long long methods;
|
||||||
|
|
||||||
|
qemuMonitorMigrationCompression params;
|
||||||
|
|
||||||
|
bool xbzrle_cache_set;
|
||||||
|
unsigned long long xbzrle_cache;
|
||||||
};
|
};
|
||||||
|
|
||||||
qemuMigrationCompressionPtr
|
qemuMigrationCompressionPtr
|
||||||
|
|
Loading…
Reference in New Issue