mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
qemu: Cancel p2p migration when connection breaks
If a connection to destination host is lost during peer-to-peer migration (because keepalive protocol timed out), we won't be able to finish the migration and it doesn't make sense to wait for qemu to transmit all data. This patch automatically cancels such migration without waiting for virDomainAbortJob to be called.
This commit is contained in:
parent
1e62643719
commit
3a6a262428
@ -915,7 +915,8 @@ qemuMigrationUpdateJobStatus(struct qemud_driver *driver,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
qemuMigrationWaitForCompletion(struct qemud_driver *driver, virDomainObjPtr vm,
|
qemuMigrationWaitForCompletion(struct qemud_driver *driver, virDomainObjPtr vm,
|
||||||
enum qemuDomainAsyncJob asyncJob)
|
enum qemuDomainAsyncJob asyncJob,
|
||||||
|
virConnectPtr dconn)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
const char *job;
|
const char *job;
|
||||||
@ -943,6 +944,12 @@ qemuMigrationWaitForCompletion(struct qemud_driver *driver, virDomainObjPtr vm,
|
|||||||
if (qemuMigrationUpdateJobStatus(driver, vm, job, asyncJob) < 0)
|
if (qemuMigrationUpdateJobStatus(driver, vm, job, asyncJob) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (dconn && virConnectIsAlive(dconn) <= 0) {
|
||||||
|
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||||
|
_("Lost connection to destination host"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
virDomainObjUnlock(vm);
|
virDomainObjUnlock(vm);
|
||||||
qemuDriverUnlock(driver);
|
qemuDriverUnlock(driver);
|
||||||
|
|
||||||
@ -1521,7 +1528,8 @@ qemuMigrationRun(struct qemud_driver *driver,
|
|||||||
int *cookieoutlen,
|
int *cookieoutlen,
|
||||||
unsigned long flags,
|
unsigned long flags,
|
||||||
unsigned long resource,
|
unsigned long resource,
|
||||||
qemuMigrationSpecPtr spec)
|
qemuMigrationSpecPtr spec,
|
||||||
|
virConnectPtr dconn)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
unsigned int migrate_flags = QEMU_MONITOR_MIGRATE_BACKGROUND;
|
unsigned int migrate_flags = QEMU_MONITOR_MIGRATE_BACKGROUND;
|
||||||
@ -1640,7 +1648,8 @@ qemuMigrationRun(struct qemud_driver *driver,
|
|||||||
goto cancel;
|
goto cancel;
|
||||||
|
|
||||||
if (qemuMigrationWaitForCompletion(driver, vm,
|
if (qemuMigrationWaitForCompletion(driver, vm,
|
||||||
QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
|
QEMU_ASYNC_JOB_MIGRATION_OUT,
|
||||||
|
dconn) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* When migration completed, QEMU will have paused the
|
/* When migration completed, QEMU will have paused the
|
||||||
@ -1697,7 +1706,8 @@ static int doNativeMigrate(struct qemud_driver *driver,
|
|||||||
char **cookieout,
|
char **cookieout,
|
||||||
int *cookieoutlen,
|
int *cookieoutlen,
|
||||||
unsigned long flags,
|
unsigned long flags,
|
||||||
unsigned long resource)
|
unsigned long resource,
|
||||||
|
virConnectPtr dconn)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
xmlURIPtr uribits = NULL;
|
xmlURIPtr uribits = NULL;
|
||||||
@ -1755,7 +1765,7 @@ static int doNativeMigrate(struct qemud_driver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = qemuMigrationRun(driver, vm, cookiein, cookieinlen, cookieout,
|
ret = qemuMigrationRun(driver, vm, cookiein, cookieinlen, cookieout,
|
||||||
cookieoutlen, flags, resource, &spec);
|
cookieoutlen, flags, resource, &spec, dconn);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (spec.destType == MIGRATION_DEST_FD)
|
if (spec.destType == MIGRATION_DEST_FD)
|
||||||
@ -1776,7 +1786,8 @@ static int doTunnelMigrate(struct qemud_driver *driver,
|
|||||||
char **cookieout,
|
char **cookieout,
|
||||||
int *cookieoutlen,
|
int *cookieoutlen,
|
||||||
unsigned long flags,
|
unsigned long flags,
|
||||||
unsigned long resource)
|
unsigned long resource,
|
||||||
|
virConnectPtr dconn)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virNetSocketPtr sock = NULL;
|
virNetSocketPtr sock = NULL;
|
||||||
@ -1839,7 +1850,7 @@ static int doTunnelMigrate(struct qemud_driver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = qemuMigrationRun(driver, vm, cookiein, cookieinlen, cookieout,
|
ret = qemuMigrationRun(driver, vm, cookiein, cookieinlen, cookieout,
|
||||||
cookieoutlen, flags, resource, &spec);
|
cookieoutlen, flags, resource, &spec, dconn);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (spec.destType == MIGRATION_DEST_FD) {
|
if (spec.destType == MIGRATION_DEST_FD) {
|
||||||
@ -1942,12 +1953,12 @@ static int doPeer2PeerMigrate2(struct qemud_driver *driver,
|
|||||||
if (flags & VIR_MIGRATE_TUNNELLED)
|
if (flags & VIR_MIGRATE_TUNNELLED)
|
||||||
ret = doTunnelMigrate(driver, vm, st,
|
ret = doTunnelMigrate(driver, vm, st,
|
||||||
NULL, 0, NULL, NULL,
|
NULL, 0, NULL, NULL,
|
||||||
flags, resource);
|
flags, resource, dconn);
|
||||||
else
|
else
|
||||||
ret = doNativeMigrate(driver, vm, uri_out,
|
ret = doNativeMigrate(driver, vm, uri_out,
|
||||||
cookie, cookielen,
|
cookie, cookielen,
|
||||||
NULL, NULL, /* No out cookie with v2 migration */
|
NULL, NULL, /* No out cookie with v2 migration */
|
||||||
flags, resource);
|
flags, resource, dconn);
|
||||||
|
|
||||||
/* Perform failed. Make sure Finish doesn't overwrite the error */
|
/* Perform failed. Make sure Finish doesn't overwrite the error */
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -2088,12 +2099,12 @@ static int doPeer2PeerMigrate3(struct qemud_driver *driver,
|
|||||||
ret = doTunnelMigrate(driver, vm, st,
|
ret = doTunnelMigrate(driver, vm, st,
|
||||||
cookiein, cookieinlen,
|
cookiein, cookieinlen,
|
||||||
&cookieout, &cookieoutlen,
|
&cookieout, &cookieoutlen,
|
||||||
flags, resource);
|
flags, resource, dconn);
|
||||||
else
|
else
|
||||||
ret = doNativeMigrate(driver, vm, uri_out,
|
ret = doNativeMigrate(driver, vm, uri_out,
|
||||||
cookiein, cookieinlen,
|
cookiein, cookieinlen,
|
||||||
&cookieout, &cookieoutlen,
|
&cookieout, &cookieoutlen,
|
||||||
flags, resource);
|
flags, resource, dconn);
|
||||||
|
|
||||||
/* Perform failed. Make sure Finish doesn't overwrite the error */
|
/* Perform failed. Make sure Finish doesn't overwrite the error */
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -2325,7 +2336,7 @@ qemuMigrationPerformJob(struct qemud_driver *driver,
|
|||||||
qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_PERFORM2);
|
qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_PERFORM2);
|
||||||
ret = doNativeMigrate(driver, vm, uri, cookiein, cookieinlen,
|
ret = doNativeMigrate(driver, vm, uri, cookiein, cookieinlen,
|
||||||
cookieout, cookieoutlen,
|
cookieout, cookieoutlen,
|
||||||
flags, resource);
|
flags, resource, NULL);
|
||||||
}
|
}
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -2414,7 +2425,7 @@ qemuMigrationPerformPhase(struct qemud_driver *driver,
|
|||||||
resume = virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING;
|
resume = virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING;
|
||||||
ret = doNativeMigrate(driver, vm, uri, cookiein, cookieinlen,
|
ret = doNativeMigrate(driver, vm, uri, cookiein, cookieinlen,
|
||||||
cookieout, cookieoutlen,
|
cookieout, cookieoutlen,
|
||||||
flags, resource);
|
flags, resource, NULL);
|
||||||
|
|
||||||
if (ret < 0 && resume &&
|
if (ret < 0 && resume &&
|
||||||
virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
|
virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
|
||||||
@ -2924,7 +2935,7 @@ qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
|
|||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
rc = qemuMigrationWaitForCompletion(driver, vm, asyncJob);
|
rc = qemuMigrationWaitForCompletion(driver, vm, asyncJob, NULL);
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user