Signed-off-by: Eli Qiao <liyong.qiao@xxxxxxxxx> Signed-off-by: ShaoHe Feng <shaohe.feng@xxxxxxxxx> --- include/libvirt/libvirt-domain.h | 1 + tools/virsh-domain.c | 52 ++++++++++++++++++++++++++++++++++++++++ tools/virsh.pod | 23 ++++++++++++------ 3 files changed, 69 insertions(+), 7 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 8d1d93e..d6fca47 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -659,6 +659,7 @@ typedef enum { VIR_MIGRATE_ABORT_ON_ERROR = (1 << 12), /* abort migration on I/O errors happened during migration */ VIR_MIGRATE_AUTO_CONVERGE = (1 << 13), /* force convergence */ VIR_MIGRATE_RDMA_PIN_ALL = (1 << 14), /* RDMA memory pinning */ + VIR_MIGRATE_MT_COMPRESSED = (1 << 15), /* multiple threads compression during migration */ } virDomainMigrateFlags; diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index ac04ded..98f3f76 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9787,6 +9787,10 @@ static const vshCmdOptDef opts_migrate[] = { .type = VSH_OT_BOOL, .help = N_("compress repeated pages during live migration") }, + {.name = "multi-thread-compress", + .type = VSH_OT_BOOL, + .help = N_("enable multi-thread compression during live migration") + }, {.name = "auto-converge", .type = VSH_OT_BOOL, .help = N_("force convergence during live migration") @@ -9826,6 +9830,20 @@ static const vshCmdOptDef opts_migrate[] = { {.name = "migrate-disks", .type = VSH_OT_STRING, .help = N_("comma separated list of disks to be migrated") + {.name = "compress-level", + .type = VSH_OT_INT, + .help = N_("compres level, from 0-9, 0 means use default level. " + "'--multi-thread-compress' option will set as true with this option.") + }, + {.name = "compress-threads", + .type = VSH_OT_INT, + .help = N_("compres thread count for multi-thread migration, from 0-255. " + "'--multi-thread-compress' option will set as true with this option.") + }, + {.name = "decompress-threads", + .type = VSH_OT_INT, + .help = N_("decompres thread count for multi-thread migration, from 0-255. " + "'--multi-thread-compress' option will set as true with this option.") }, {.name = NULL} }; @@ -9845,6 +9863,8 @@ doMigrate(void *opaque) virTypedParameterPtr params = NULL; int nparams = 0; int maxparams = 0; + int value = 0; + int rv; virConnectPtr dconn = data->dconn; sigemptyset(&sigmask); @@ -9903,6 +9923,35 @@ doMigrate(void *opaque) } VIR_FREE(val); + + if ((rv = vshCommandOptInt(cmd, "compress-level", &value)) < 0) { + goto save_error; + } else if (rv > 0) { + if (virTypedParamsAddInt(¶ms, &nparams, &maxparams, + VIR_DOMAIN_MIRGRATE_COMPRESSION_LEVEL, + value) < 0) + goto save_error; + flags |= VIR_MIGRATE_MT_COMPRESSED; + } + + if ((rv = vshCommandOptInt(cmd, "compress-threads", &value)) < 0) { + goto save_error; + } else if (rv > 0) { + if (virTypedParamsAddInt(¶ms, &nparams, &maxparams, + VIR_DOMAIN_MIRGRATE_COMPRESSION_THREADS, + value) < 0) + goto save_error; + flags |= VIR_MIGRATE_MT_COMPRESSED; + } + + if ((rv = vshCommandOptInt(cmd, "decompress-threads", &value)) < 0) { + goto save_error; + } else if (rv > 0) { + if (virTypedParamsAddInt(¶ms, &nparams, &maxparams, + VIR_DOMAIN_MIRGRATE_DECOMPRESSION_THREADS, + value) < 0) + goto save_error; + flags |= VIR_MIGRATE_MT_COMPRESSED; } if (vshCommandOptStringReq(ctl, cmd, "xml", &opt) < 0) @@ -9953,6 +10002,9 @@ doMigrate(void *opaque) if (vshCommandOptBool(cmd, "compressed")) flags |= VIR_MIGRATE_COMPRESSED; + if (vshCommandOptBool(cmd, "multi-thread-compress")) + flags |= VIR_MIGRATE_MT_COMPRESSED; + if (vshCommandOptBool(cmd, "auto-converge")) flags |= VIR_MIGRATE_AUTO_CONVERGE; diff --git a/tools/virsh.pod b/tools/virsh.pod index bcfa165..1ba2c43 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1518,10 +1518,11 @@ to the I<uri> namespace is displayed instead of being modified. =item B<migrate> [I<--live>] [I<--offline>] [I<--direct>] [I<--p2p> [I<--tunnelled>]] [I<--persistent>] [I<--undefinesource>] [I<--suspend>] [I<--copy-storage-all>] [I<--copy-storage-inc>] [I<--change-protection>] [I<--unsafe>] [I<--verbose>] -[I<--compressed>] [I<--abort-on-error>] [I<--auto-converge>] -I<domain> I<desturi> [I<migrateuri>] [I<graphicsuri>] [I<listen-address>] -[I<dname>] [I<--timeout> B<seconds>] [I<--xml> B<file>] -[I<--migrate-disks> B<disk-list>] +[I<--compressed>] [I<--multi-thread-compress>] [I<--abort-on-error>] +[I<--auto-converge>] I<domain> I<desturi> [I<migrateuri>] [I<graphicsuri>] +[I<listen-address>] [I<dname>] [I<--timeout> B<seconds>] [I<--xml> B<file>] +[I<--migrate-disks> B<disk-list>] [I<--compress-level> B<number>] +[I<--compress-threads> B<number>] [I<--decompress-threads> B<number>] 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> @@ -1545,9 +1546,10 @@ 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 hypervisor lacks change protection support. I<--verbose> displays the progress of migration. I<--compressed> activates compression of memory pages that have -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 -migration. I<--auto-converge> forces convergence during live migration. +to be transferred repeatedly during live migration. I<--multi-thread-compress> +activates multi-thread compression during live migration. I<--abort-on-error> +cancels the migration if a soft error (for example I/O error) happens during +the migration. I<--auto-converge> forces convergence during live migration. B<Note>: Individual hypervisors usually do not support all possible types of migration. For example, QEMU does not support direct migration. @@ -1567,6 +1569,13 @@ the destination to supply a larger set of changes to any host-specific portions of the domain XML, such as accounting for naming differences between source and destination in accessing underlying storage. +I<--compress-level> is interpreted as an unsigned int value from 0-9. O means +hypervisor choose an default value. Specifying a negative value results in an +essentially unlimited value being provided to the hypervisor. The hypervisor +can choose whether to reject the value or convert it to the maximum value +allowed. I<--compress-threads> is interpreted as an unsigned int value. +I<--decompress-threads> is interpreted as an unsigned int value. + I<--timeout> B<seconds> forces guest to suspend when live migration exceeds that many seconds, and then the migration will complete offline. It can only be used with I<--live>. -- 2.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list