diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index bbf41b8c879956d813285da63a56d38f56ffb9f8..6ff455328a552dedb9430ea1f23b5bfcecf15a52 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9639,6 +9639,10 @@ static const vshCmdOptDef opts_migrate[] = { .type = VSH_OT_BOOL, .help = N_("abort on soft errors during migration") }, + {.name = "postcopy", + .type = VSH_OT_BOOL, + .help = N_("enable post-copy migration; switch to it using migrate-postcopy command") + }, {.name = "migrateuri", .type = VSH_OT_STRING, .help = N_("migration URI, usually can be omitted") @@ -9817,6 +9821,9 @@ doMigrate(void *opaque) if (vshCommandOptBool(cmd, "abort-on-error")) flags |= VIR_MIGRATE_ABORT_ON_ERROR; + if (vshCommandOptBool(cmd, "postcopy")) + flags |= VIR_MIGRATE_POSTCOPY; + if (flags & VIR_MIGRATE_PEER2PEER || vshCommandOptBool(cmd, "direct")) { if (virDomainMigrateToURI3(dom, desturi, params, nparams, flags) == 0) ret = '0'; @@ -10121,6 +10128,48 @@ cmdMigrateGetMaxSpeed(vshControl *ctl, const vshCmd *cmd) return ret; } +/* + * "migrate-postcopy" command + */ +static const vshCmdInfo info_migrate_postcopy[] = { + {.name = "help", + .data = N_("Switch running migration from pre-copy to post-copy") + }, + {.name = "desc", + .data = N_("Switch running migration from pre-copy to post-copy. " + "The migration must have been started with --postcopy option.") + }, + {.name = NULL} +}; + +static const vshCmdOptDef opts_migrate_postcopy[] = { + {.name = "domain", + .type = VSH_OT_DATA, + .flags = VSH_OFLAG_REQ, + .help = N_("domain name, id or uuid") + }, + {.name = NULL} +}; + +static bool +cmdMigratePostCopy(vshControl *ctl, const vshCmd *cmd) +{ + virDomainPtr dom; + bool ret = false; + + if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (virDomainMigrateStartPostCopy(dom, 0) < 0) + goto cleanup; + + ret = true; + + cleanup: + virDomainFree(dom); + return ret; +} + /* * "domdisplay" command */ @@ -12976,6 +13025,12 @@ const vshCmdDef domManagementCmds[] = { .info = info_migrate_getspeed, .flags = 0 }, + {.name = "migrate-postcopy", + .handler = cmdMigratePostCopy, + .opts = opts_migrate_postcopy, + .info = info_migrate_postcopy, + .flags = 0 + }, {.name = "numatune", .handler = cmdNumatune, .opts = opts_numatune, diff --git a/tools/virsh.pod b/tools/virsh.pod index 1e2c6a68371734bcc8fe8dfdfd582008c0a3f00d..63c2a44a699b5f6aa3858c4df4a54c66d1ccf6da 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1529,7 +1529,7 @@ to the I namespace is displayed instead of being modified. =item B [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<--compressed>] [I<--abort-on-error>] [I<--auto-converge>] [I<--postcopy>] I I [I] [I] [I] [I] [I<--timeout> B] [I<--xml> B] [I<--migrate-disks> B] [I<--disks-port> B] @@ -1559,6 +1559,10 @@ 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. +I<--postcopy> enables post-copy logic in migration, but does not +actually start post-copy, i.e., migration is started in pre-copy mode. +Once migration is running, the user may switch to post-copy using the +B command sent from another virsh instance. B: Individual hypervisors usually do not support all possible types of migration. For example, QEMU does not support direct migration. @@ -1692,6 +1696,11 @@ reject the value or convert it to the maximum value allowed. Get the maximum migration bandwidth (in MiB/s) for a domain. +=item B I + +Switch the current migration from pre-copy to post-copy. This is only +supported for a migration started with I<--postcopy> option. + =item B I [I<--mode> B] [I<--nodeset> B] [[I<--config>] [I<--live>] | [I<--current>]]