mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
conf: Drop virDomainJobOperation parameter from virDomainObjIsPostcopy
The parameter was only used to select which states correspond to an active or failed post-copy migration. But these states are either applicable to both operations or the check would just paper over a code bug in case of an impossible combination of state and operation. By dropping the check we can make the code simpler and also reuse existing virDomainObjIsFailedPostcopy function and only check for active post-copy states. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
608c4b249e
commit
b92cba67c6
@ -27931,24 +27931,15 @@ virDomainObjIsFailedPostcopy(virDomainObj *dom)
|
||||
|
||||
|
||||
bool
|
||||
virDomainObjIsPostcopy(virDomainObj *dom,
|
||||
virDomainJobOperation op)
|
||||
virDomainObjIsPostcopy(virDomainObj *dom)
|
||||
{
|
||||
if (op != VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN &&
|
||||
op != VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT)
|
||||
return false;
|
||||
if (virDomainObjIsFailedPostcopy(dom))
|
||||
return true;
|
||||
|
||||
if (op == VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN) {
|
||||
return (dom->state.state == VIR_DOMAIN_PAUSED &&
|
||||
dom->state.reason == VIR_DOMAIN_PAUSED_POSTCOPY_FAILED) ||
|
||||
(dom->state.state == VIR_DOMAIN_RUNNING &&
|
||||
(dom->state.reason == VIR_DOMAIN_RUNNING_POSTCOPY ||
|
||||
dom->state.reason == VIR_DOMAIN_RUNNING_POSTCOPY_FAILED));
|
||||
}
|
||||
|
||||
return dom->state.state == VIR_DOMAIN_PAUSED &&
|
||||
(dom->state.reason == VIR_DOMAIN_PAUSED_POSTCOPY ||
|
||||
dom->state.reason == VIR_DOMAIN_PAUSED_POSTCOPY_FAILED);
|
||||
return (dom->state.state == VIR_DOMAIN_PAUSED &&
|
||||
dom->state.reason == VIR_DOMAIN_PAUSED_POSTCOPY) ||
|
||||
(dom->state.state == VIR_DOMAIN_RUNNING &&
|
||||
dom->state.reason == VIR_DOMAIN_RUNNING_POSTCOPY);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3962,8 +3962,7 @@ bool
|
||||
virDomainObjIsFailedPostcopy(virDomainObj *obj)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
bool
|
||||
virDomainObjIsPostcopy(virDomainObj *dom,
|
||||
virDomainJobOperation op)
|
||||
virDomainObjIsPostcopy(virDomainObj *dom)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
|
||||
virSecurityLabelDef *
|
||||
|
@ -12609,7 +12609,7 @@ qemuDomainAbortJobFlags(virDomainPtr dom,
|
||||
|
||||
if (flags & VIR_DOMAIN_ABORT_JOB_POSTCOPY &&
|
||||
(vm->job->asyncJob != VIR_ASYNC_JOB_MIGRATION_OUT ||
|
||||
!virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT))) {
|
||||
!virDomainObjIsPostcopy(vm))) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("current job is not outgoing migration in post-copy mode"));
|
||||
goto endjob;
|
||||
@ -12634,7 +12634,7 @@ qemuDomainAbortJobFlags(virDomainPtr dom,
|
||||
break;
|
||||
|
||||
case VIR_ASYNC_JOB_MIGRATION_OUT:
|
||||
if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT))
|
||||
if (virDomainObjIsPostcopy(vm))
|
||||
ret = qemuDomainAbortJobPostcopy(vm, flags);
|
||||
else
|
||||
ret = qemuDomainAbortJobMigration(vm);
|
||||
|
@ -2292,7 +2292,7 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm,
|
||||
break;
|
||||
|
||||
case QEMU_MIGRATION_PHASE_PERFORM3_DONE:
|
||||
if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT)) {
|
||||
if (virDomainObjIsPostcopy(vm)) {
|
||||
VIR_DEBUG("Migration protocol interrupted in post-copy mode");
|
||||
postcopy = true;
|
||||
} else {
|
||||
@ -2681,7 +2681,7 @@ qemuMigrationAnyCanResume(virDomainObj *vm,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!virDomainObjIsPostcopy(vm, vm->job->current->operation)) {
|
||||
if (!virDomainObjIsPostcopy(vm)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("migration of domain %s is not in post-copy phase"),
|
||||
vm->def->name);
|
||||
@ -3902,7 +3902,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver,
|
||||
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
|
||||
|
||||
if (retcode != 0 &&
|
||||
virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT) &&
|
||||
virDomainObjIsPostcopy(vm) &&
|
||||
currentData->stats.mig.status == QEMU_MONITOR_MIGRATION_STATUS_COMPLETED) {
|
||||
VIR_DEBUG("Finish phase failed, but QEMU reports post-copy migration is completed; forcing success");
|
||||
retcode = 0;
|
||||
|
@ -1503,7 +1503,7 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_GNUC_UNUSED,
|
||||
* watching it in any thread. Let's make sure the migration is properly
|
||||
* finished in case we get a "completed" event.
|
||||
*/
|
||||
if (virDomainObjIsPostcopy(vm, vm->job->current->operation) &&
|
||||
if (virDomainObjIsPostcopy(vm) &&
|
||||
vm->job->phase == QEMU_MIGRATION_PHASE_POSTCOPY_FAILED &&
|
||||
vm->job->asyncOwner == 0) {
|
||||
qemuProcessEventSubmit(vm, QEMU_PROCESS_EVENT_UNATTENDED_MIGRATION,
|
||||
@ -3476,7 +3476,7 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver,
|
||||
/* migration finished, we started resuming the domain but didn't
|
||||
* confirm success or failure yet; killing it seems safest unless
|
||||
* we already started guest CPUs or we were in post-copy mode */
|
||||
if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN))
|
||||
if (virDomainObjIsPostcopy(vm))
|
||||
return 1;
|
||||
|
||||
if (state != VIR_DOMAIN_RUNNING) {
|
||||
@ -3511,7 +3511,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver,
|
||||
int reason,
|
||||
unsigned int *stopFlags)
|
||||
{
|
||||
bool postcopy = virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT);
|
||||
bool postcopy = virDomainObjIsPostcopy(vm);
|
||||
bool resume = false;
|
||||
|
||||
VIR_DEBUG("Active outgoing migration in phase %s",
|
||||
|
Loading…
Reference in New Issue
Block a user