conf: check for migration job during domain start

It's possible to hit the following situation during qemu p2p live
migration:

1. qemu has live migrated and exited (making virDomainObjIsActive()
   return false)

2. the live migration job is still in progress, waiting for a
   confirmation from the remote libvirt daemon. This may last for
   a while with a presence of networking issues (up to keepalive
   timeout).

Any attempt to start the domain again would fail with "domain is already
being started" message which is misleading in this situation as it
doesn't reflect what's really happening.

Add a check for the migration job and report a different error message
if the migration job is still running.

Signed-off-by: Sergey Dyasli <sergey.dyasli@nutanix.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Sergey Dyasli 2024-07-31 11:46:48 +00:00 committed by Martin Kletzander
parent cabb0dda0e
commit 87c3fa1cde

View File

@ -301,9 +301,15 @@ virDomainObjListAddLocked(virDomainObjList *doms,
goto error;
}
if (!vm->persistent) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("domain '%1$s' is already being started"),
vm->def->name);
if (vm->job->asyncJob == VIR_ASYNC_JOB_MIGRATION_OUT) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("domain '%1$s' is being migrated out"),
vm->def->name);
} else {
virReportError(VIR_ERR_OPERATION_INVALID,
_("domain '%1$s' is already being started"),
vm->def->name);
}
goto error;
}
}