mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemu: Don't wait for migration job when migration is running
Migration is a job which takes some time and if it succeeds, there's nothing to call another migration on. If a migration fails, it might make sense to rerun it with different arguments, but this would only be done once the first migration fails rather than while it is still running. If this was not enough, the migration job now stays active even if post-copy migration fails and anyone possibly retrying the migration would be waiting for the job timeout just to get a suboptimal error message. So let's special case getting a migration job when another one is already active. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
96db9dcfe9
commit
918c14ee06
@ -82,6 +82,23 @@ VIR_ENUM_IMPL(qemuMigrationJobPhase,
|
||||
);
|
||||
|
||||
|
||||
static bool ATTRIBUTE_NONNULL(1)
|
||||
qemuMigrationJobIsAllowed(virDomainObj *vm)
|
||||
{
|
||||
qemuDomainObjPrivate *priv = vm->privateData;
|
||||
|
||||
if (priv->job.asyncJob == VIR_ASYNC_JOB_MIGRATION_IN ||
|
||||
priv->job.asyncJob == VIR_ASYNC_JOB_MIGRATION_OUT) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("another migration job is already running for domain '%s'"),
|
||||
vm->def->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT
|
||||
qemuMigrationJobStart(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
@ -92,6 +109,9 @@ qemuMigrationJobStart(virQEMUDriver *driver,
|
||||
virDomainJobOperation op;
|
||||
unsigned long long mask;
|
||||
|
||||
if (!qemuMigrationJobIsAllowed(vm))
|
||||
return -1;
|
||||
|
||||
if (job == VIR_ASYNC_JOB_MIGRATION_IN) {
|
||||
op = VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN;
|
||||
mask = VIR_JOB_NONE;
|
||||
@ -2602,6 +2622,9 @@ qemuMigrationSrcBegin(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
asyncJob = VIR_ASYNC_JOB_MIGRATION_OUT;
|
||||
} else {
|
||||
if (!qemuMigrationJobIsAllowed(vm))
|
||||
goto cleanup;
|
||||
|
||||
if (qemuDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
asyncJob = VIR_ASYNC_JOB_NONE;
|
||||
|
Loading…
Reference in New Issue
Block a user