virsh: add compression options for migration

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
ShaoHe Feng 2016-04-14 13:33:52 +03:00 committed by Jiri Denemark
parent 061e24285f
commit 0d81f2318b
2 changed files with 91 additions and 3 deletions

View File

@ -9783,6 +9783,26 @@ static const vshCmdOptDef opts_migrate[] = {
.type = VSH_OT_BOOL, .type = VSH_OT_BOOL,
.help = N_("compress repeated pages during live migration") .help = N_("compress repeated pages during live migration")
}, },
{.name = "comp-methods",
.type = VSH_OT_STRING,
.help = N_("comma separated list of compression methods to be used")
},
{.name = "comp-mt-level",
.type = VSH_OT_INT,
.help = N_("compress level for multithread compression")
},
{.name = "comp-mt-threads",
.type = VSH_OT_INT,
.help = N_("number of compession threads for multithread compression")
},
{.name = "comp-mt-dthreads",
.type = VSH_OT_INT,
.help = N_("number of decompession threads for multithread compression")
},
{.name = "comp-xbzrle-cache",
.type = VSH_OT_INT,
.help = N_("page cache size for xbzrle compression")
},
{.name = "auto-converge", {.name = "auto-converge",
.type = VSH_OT_BOOL, .type = VSH_OT_BOOL,
.help = N_("force convergence during live migration") .help = N_("force convergence during live migration")
@ -9863,6 +9883,9 @@ doMigrate(void *opaque)
virTypedParameterPtr params = NULL; virTypedParameterPtr params = NULL;
int nparams = 0; int nparams = 0;
int maxparams = 0; int maxparams = 0;
int intOpt = 0;
unsigned long long ullOpt = 0;
int rv;
virConnectPtr dconn = data->dconn; virConnectPtr dconn = data->dconn;
sigemptyset(&sigmask); sigemptyset(&sigmask);
@ -9930,6 +9953,59 @@ doMigrate(void *opaque)
VIR_FREE(val); VIR_FREE(val);
} }
if (vshCommandOptStringReq(ctl, cmd, "comp-methods", &opt) < 0)
goto out;
if (opt) {
char **val = virStringSplit(opt, ",", 0);
if (virTypedParamsAddStringList(&params,
&nparams,
&maxparams,
VIR_MIGRATE_PARAM_COMPRESSION,
(const char **)val) < 0) {
VIR_FREE(val);
goto save_error;
}
VIR_FREE(val);
}
if ((rv = vshCommandOptInt(ctl, cmd, "comp-mt-level", &intOpt)) < 0) {
goto out;
} else if (rv > 0) {
if (virTypedParamsAddInt(&params, &nparams, &maxparams,
VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL,
intOpt) < 0)
goto save_error;
}
if ((rv = vshCommandOptInt(ctl, cmd, "comp-mt-threads", &intOpt)) < 0) {
goto out;
} else if (rv > 0) {
if (virTypedParamsAddInt(&params, &nparams, &maxparams,
VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS,
intOpt) < 0)
goto save_error;
}
if ((rv = vshCommandOptInt(ctl, cmd, "comp-mt-dthreads", &intOpt)) < 0) {
goto out;
} else if (rv > 0) {
if (virTypedParamsAddInt(&params, &nparams, &maxparams,
VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS,
intOpt) < 0)
goto save_error;
}
if ((rv = vshCommandOptULongLong(ctl, cmd, "comp-xbzrle-cache", &ullOpt)) < 0) {
goto out;
} else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE,
ullOpt) < 0)
goto save_error;
}
if (vshCommandOptStringReq(ctl, cmd, "xml", &opt) < 0) if (vshCommandOptStringReq(ctl, cmd, "xml", &opt) < 0)
goto out; goto out;
if (opt) { if (opt) {

View File

@ -1537,11 +1537,14 @@ to the I<uri> namespace is displayed instead of being modified.
=item B<migrate> [I<--live>] [I<--offline>] [I<--direct>] [I<--p2p> [I<--tunnelled>]] =item B<migrate> [I<--live>] [I<--offline>] [I<--direct>] [I<--p2p> [I<--tunnelled>]]
[I<--persistent>] [I<--undefinesource>] [I<--suspend>] [I<--copy-storage-all>] [I<--persistent>] [I<--undefinesource>] [I<--suspend>] [I<--copy-storage-all>]
[I<--copy-storage-inc>] [I<--change-protection>] [I<--unsafe>] [I<--verbose>] [I<--copy-storage-inc>] [I<--change-protection>] [I<--unsafe>] [I<--verbose>]
[I<--compressed>] [I<--abort-on-error>] [I<--auto-converge>] [I<--postcopy>] [I<--abort-on-error>] [I<--auto-converge>] [I<--postcopy>]
[I<--postcopy-after-precopy>] I<domain> I<desturi> [I<migrateuri>] [I<--postcopy-after-precopy>] I<domain> I<desturi> [I<migrateuri>]
[I<graphicsuri>] [I<listen-address>] [I<dname>] [I<graphicsuri>] [I<listen-address>] [I<dname>]
[I<--timeout> B<seconds> [I<--timeout-suspend> | I<--timeout-postcopy>]] [I<--timeout> B<seconds> [I<--timeout-suspend> | I<--timeout-postcopy>]]
[I<--xml> B<file>] [I<--migrate-disks> B<disk-list>] [I<--disks-port> B<port>] [I<--xml> B<file>] [I<--migrate-disks> B<disk-list>] [I<--disks-port> B<port>]
[I<--compressed>] [I<--comp-methods> B<method-list>]
[I<--comp-mt-level>] [I<--comp-mt-threads>] [I<--comp-mt-dthreads>]
[I<--comp-xbzrle-cache>]
Migrate domain to another host. Add I<--live> for live migration; <--p2p> Migrate domain to another host. Add I<--live> for live migration; <--p2p>
for peer-2-peer migration; I<--direct> for direct migration; or I<--tunnelled> for peer-2-peer migration; I<--direct> for direct migration; or I<--tunnelled>
@ -1564,8 +1567,7 @@ enforces that no incompatible configuration changes will be made to the domain
while the migration is underway; this flag is implicitly enabled when supported while the migration is underway; this flag is implicitly enabled when supported
by the hypervisor, but can be explicitly used to reject the migration if the by the hypervisor, but can be explicitly used to reject the migration if the
hypervisor lacks change protection support. I<--verbose> displays the progress hypervisor lacks change protection support. I<--verbose> displays the progress
of migration. I<--compressed> activates compression of memory pages that have of migration. I<--abort-on-error> cancels
to be transferred repeatedly during live migration. I<--abort-on-error> cancels
the migration if a soft error (for example I/O error) happens during the the migration if a soft error (for example I/O error) happens during the
migration. I<--auto-converge> forces convergence during live migration. migration. I<--auto-converge> forces convergence during live migration.
I<--postcopy> enables post-copy logic in migration, but does not I<--postcopy> enables post-copy logic in migration, but does not
@ -1602,6 +1604,16 @@ I<--timeout-postcopy> is used, virsh will switch migration from pre-copy
to post-copy upon timeout; migration has to be started with I<--postcopy> to post-copy upon timeout; migration has to be started with I<--postcopy>
option for this to work. option for this to work.
I<--compressed> activates compression, the compression method is chosen
with I<--comp-methods>. Supported methods are "mt" and "xbzrle" and
can be used in any combination. When no methods are specified, a hypervisor
default methods will be used. QEMU defaults to "xbzrle". Compression methods
can be tuned further. I<--comp-mt-level> sets compression level.
Values are in range from 0 to 9, where 1 is maximum speed and 9 is maximum
compression. I<--comp-mt-threads> and I<--comp-mt-dthreads> set the number
of compress threads on source and the number of decompress threads on target
respectively. I<--comp-xbzrle-cache> sets size of page cache in bytes.
Running migration can be canceled by interrupting virsh (usually using Running migration can be canceled by interrupting virsh (usually using
C<Ctrl-C>) or by B<domjobabort> command sent from another virsh instance. C<Ctrl-C>) or by B<domjobabort> command sent from another virsh instance.