qemu: Refuse to abort migration in post-copy mode

In post-copy mode none of the hosts has a complete guest state and
rolling back migration is impossible. Thus aborting it would be
equivalent to destroying the domain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2016-01-15 00:10:37 +01:00
parent 630517d860
commit d64adcdb96

View File

@ -13087,6 +13087,7 @@ static int qemuDomainAbortJob(virDomainPtr dom)
virDomainObjPtr vm; virDomainObjPtr vm;
int ret = -1; int ret = -1;
qemuDomainObjPrivatePtr priv; qemuDomainObjPrivatePtr priv;
int reason;
if (!(vm = qemuDomObjFromDomain(dom))) if (!(vm = qemuDomObjFromDomain(dom)))
goto cleanup; goto cleanup;
@ -13109,13 +13110,24 @@ static int qemuDomainAbortJob(virDomainPtr dom)
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("no job is active on the domain")); "%s", _("no job is active on the domain"));
goto endjob; goto endjob;
} else if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN) { }
if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot abort incoming migration;" _("cannot abort incoming migration;"
" use virDomainDestroy instead")); " use virDomainDestroy instead"));
goto endjob; goto endjob;
} }
if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT &&
(priv->job.current->stats.status == QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY ||
(virDomainObjGetState(vm, &reason) == VIR_DOMAIN_PAUSED &&
reason == VIR_DOMAIN_PAUSED_POSTCOPY))) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot abort migration in post-copy mode"));
goto endjob;
}
VIR_DEBUG("Cancelling job at client request"); VIR_DEBUG("Cancelling job at client request");
qemuDomainObjAbortAsyncJob(vm); qemuDomainObjAbortAsyncJob(vm);
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);