mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh: Configurable migrate --timeout action
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
179d97283f
commit
257060349e
@ -9661,7 +9661,16 @@ static const vshCmdOptDef opts_migrate[] = {
|
|||||||
},
|
},
|
||||||
{.name = "timeout",
|
{.name = "timeout",
|
||||||
.type = VSH_OT_INT,
|
.type = VSH_OT_INT,
|
||||||
.help = N_("force guest to suspend if live migration exceeds timeout (in seconds)")
|
.help = N_("run action specified by --timeout-* option (suspend by "
|
||||||
|
"default) if live migration exceeds timeout (in seconds)")
|
||||||
|
},
|
||||||
|
{.name = "timeout-suspend",
|
||||||
|
.type = VSH_OT_BOOL,
|
||||||
|
.help = N_("suspend the guest after timeout")
|
||||||
|
},
|
||||||
|
{.name = "timeout-postcopy",
|
||||||
|
.type = VSH_OT_BOOL,
|
||||||
|
.help = N_("switch to post-copy after timeout")
|
||||||
},
|
},
|
||||||
{.name = "xml",
|
{.name = "xml",
|
||||||
.type = VSH_OT_STRING,
|
.type = VSH_OT_STRING,
|
||||||
@ -9851,14 +9860,35 @@ doMigrate(void *opaque)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VIRSH_MIGRATE_TIMEOUT_DEFAULT,
|
||||||
|
VIRSH_MIGRATE_TIMEOUT_SUSPEND,
|
||||||
|
VIRSH_MIGRATE_TIMEOUT_POSTCOPY,
|
||||||
|
} virshMigrateTimeoutAction;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virshMigrationTimeout(vshControl *ctl,
|
virshMigrateTimeout(vshControl *ctl,
|
||||||
virDomainPtr dom,
|
virDomainPtr dom,
|
||||||
void *opaque ATTRIBUTE_UNUSED)
|
void *opaque)
|
||||||
{
|
{
|
||||||
vshDebug(ctl, VSH_ERR_DEBUG, "suspending the domain, "
|
virshMigrateTimeoutAction action = *(virshMigrateTimeoutAction *) opaque;
|
||||||
"since migration timed out\n");
|
|
||||||
virDomainSuspend(dom);
|
switch (action) {
|
||||||
|
case VIRSH_MIGRATE_TIMEOUT_DEFAULT: /* unreachable */
|
||||||
|
case VIRSH_MIGRATE_TIMEOUT_SUSPEND:
|
||||||
|
vshDebug(ctl, VSH_ERR_DEBUG,
|
||||||
|
"migration timed out; suspending domain\n");
|
||||||
|
if (virDomainSuspend(dom) < 0)
|
||||||
|
vshDebug(ctl, VSH_ERR_INFO, "suspending domain failed\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIRSH_MIGRATE_TIMEOUT_POSTCOPY:
|
||||||
|
vshDebug(ctl, VSH_ERR_DEBUG,
|
||||||
|
"migration timed out; switching to post-copy\n");
|
||||||
|
if (virDomainMigrateStartPostCopy(dom, 0) < 0)
|
||||||
|
vshDebug(ctl, VSH_ERR_INFO, "switching to post-copy failed\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -9870,10 +9900,12 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
|
|||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
bool functionReturn = false;
|
bool functionReturn = false;
|
||||||
int timeout = 0;
|
int timeout = 0;
|
||||||
|
virshMigrateTimeoutAction timeoutAction = VIRSH_MIGRATE_TIMEOUT_DEFAULT;
|
||||||
bool live_flag = false;
|
bool live_flag = false;
|
||||||
virshCtrlData data = { .dconn = NULL };
|
virshCtrlData data = { .dconn = NULL };
|
||||||
|
|
||||||
VSH_EXCLUSIVE_OPTIONS("live", "offline");
|
VSH_EXCLUSIVE_OPTIONS("live", "offline");
|
||||||
|
VSH_EXCLUSIVE_OPTIONS("timeout-suspend", "timeout-postcopy");
|
||||||
|
|
||||||
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
@ -9891,6 +9923,19 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vshCommandOptBool(cmd, "timeout-suspend"))
|
||||||
|
timeoutAction = VIRSH_MIGRATE_TIMEOUT_SUSPEND;
|
||||||
|
if (vshCommandOptBool(cmd, "timeout-postcopy"))
|
||||||
|
timeoutAction = VIRSH_MIGRATE_TIMEOUT_POSTCOPY;
|
||||||
|
if (timeout > 0) {
|
||||||
|
if (timeoutAction == VIRSH_MIGRATE_TIMEOUT_DEFAULT)
|
||||||
|
timeoutAction = VIRSH_MIGRATE_TIMEOUT_SUSPEND;
|
||||||
|
} else if (timeoutAction) {
|
||||||
|
vshError(ctl, "%s",
|
||||||
|
_("migrate: Unexpected --timeout-* option without --timeout"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (pipe(p) < 0)
|
if (pipe(p) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -9921,7 +9966,8 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
|
|||||||
&data) < 0)
|
&data) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
functionReturn = virshWatchJob(ctl, dom, verbose, p[0], timeout,
|
functionReturn = virshWatchJob(ctl, dom, verbose, p[0], timeout,
|
||||||
virshMigrationTimeout, NULL, _("Migration"));
|
virshMigrateTimeout,
|
||||||
|
&timeoutAction, _("Migration"));
|
||||||
|
|
||||||
virThreadJoin(&workerThread);
|
virThreadJoin(&workerThread);
|
||||||
|
|
||||||
|
@ -1531,8 +1531,8 @@ to the I<uri> namespace is displayed instead of being modified.
|
|||||||
[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<--compressed>] [I<--abort-on-error>] [I<--auto-converge>] [I<--postcopy>]
|
||||||
I<domain> I<desturi> [I<migrateuri>] [I<graphicsuri>] [I<listen-address>]
|
I<domain> I<desturi> [I<migrateuri>] [I<graphicsuri>] [I<listen-address>]
|
||||||
[I<dname>] [I<--timeout> B<seconds>] [I<--xml> B<file>]
|
[I<dname>] [I<--timeout> B<seconds> [I<--timeout-suspend> | I<--timeout-postcopy>]]
|
||||||
[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>]
|
||||||
|
|
||||||
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>
|
||||||
@ -1582,9 +1582,14 @@ the destination to supply a larger set of changes to any host-specific
|
|||||||
portions of the domain XML, such as accounting for naming differences
|
portions of the domain XML, such as accounting for naming differences
|
||||||
between source and destination in accessing underlying storage.
|
between source and destination in accessing underlying storage.
|
||||||
|
|
||||||
I<--timeout> B<seconds> forces guest to suspend when live migration exceeds
|
I<--timeout> B<seconds> tells virsh to run a specified action when live
|
||||||
that many seconds, and
|
migration exceeds that many seconds. It can only be used with I<--live>.
|
||||||
then the migration will complete offline. It can only be used with I<--live>.
|
If I<--timeout-suspend> is specified, the domain will be suspended after
|
||||||
|
the timeout and the migration will complete offline; this is the default
|
||||||
|
if no I<--timeout-*> option is specified on the command line. When
|
||||||
|
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>
|
||||||
|
option for this to work.
|
||||||
|
|
||||||
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user