conf: Add job parameter to virDomainObjIsFailedPostcopy

Unused for now, but this will change soon.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jiri Denemark 2022-12-13 16:43:53 +01:00
parent b92cba67c6
commit 49a5754063
5 changed files with 26 additions and 22 deletions

View File

@ -27921,7 +27921,8 @@ virDomainObjGetState(virDomainObj *dom, int *reason)
bool
virDomainObjIsFailedPostcopy(virDomainObj *dom)
virDomainObjIsFailedPostcopy(virDomainObj *dom,
virDomainJobObj *job G_GNUC_UNUSED)
{
return ((dom->state.state == VIR_DOMAIN_PAUSED &&
dom->state.reason == VIR_DOMAIN_PAUSED_POSTCOPY_FAILED) ||
@ -27931,9 +27932,10 @@ virDomainObjIsFailedPostcopy(virDomainObj *dom)
bool
virDomainObjIsPostcopy(virDomainObj *dom)
virDomainObjIsPostcopy(virDomainObj *dom,
virDomainJobObj *job)
{
if (virDomainObjIsFailedPostcopy(dom))
if (virDomainObjIsFailedPostcopy(dom, job))
return true;
return (dom->state.state == VIR_DOMAIN_PAUSED &&

View File

@ -3959,10 +3959,12 @@ virDomainObjGetState(virDomainObj *obj, int *reason)
ATTRIBUTE_NONNULL(1);
bool
virDomainObjIsFailedPostcopy(virDomainObj *obj)
virDomainObjIsFailedPostcopy(virDomainObj *obj,
virDomainJobObj *job)
ATTRIBUTE_NONNULL(1);
bool
virDomainObjIsPostcopy(virDomainObj *dom)
virDomainObjIsPostcopy(virDomainObj *dom,
virDomainJobObj *job)
ATTRIBUTE_NONNULL(1);
virSecurityLabelDef *

View File

@ -12609,7 +12609,7 @@ qemuDomainAbortJobFlags(virDomainPtr dom,
if (flags & VIR_DOMAIN_ABORT_JOB_POSTCOPY &&
(vm->job->asyncJob != VIR_ASYNC_JOB_MIGRATION_OUT ||
!virDomainObjIsPostcopy(vm))) {
!virDomainObjIsPostcopy(vm, vm->job))) {
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))
if (virDomainObjIsPostcopy(vm, vm->job))
ret = qemuDomainAbortJobPostcopy(vm, flags);
else
ret = qemuDomainAbortJobMigration(vm);

View File

@ -2292,7 +2292,7 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm,
break;
case QEMU_MIGRATION_PHASE_PERFORM3_DONE:
if (virDomainObjIsPostcopy(vm)) {
if (virDomainObjIsPostcopy(vm, vm->job)) {
VIR_DEBUG("Migration protocol interrupted in post-copy mode");
postcopy = true;
} else {
@ -2681,7 +2681,7 @@ qemuMigrationAnyCanResume(virDomainObj *vm,
return false;
}
if (!virDomainObjIsPostcopy(vm)) {
if (!virDomainObjIsPostcopy(vm, vm->job)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("migration of domain %s is not in post-copy phase"),
vm->def->name);
@ -2689,7 +2689,7 @@ qemuMigrationAnyCanResume(virDomainObj *vm,
}
if (vm->job->phase < QEMU_MIGRATION_PHASE_POSTCOPY_FAILED &&
!virDomainObjIsFailedPostcopy(vm)) {
!virDomainObjIsFailedPostcopy(vm, vm->job)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("post-copy migration of domain %s has not failed"),
vm->def->name);
@ -3902,7 +3902,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver,
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
if (retcode != 0 &&
virDomainObjIsPostcopy(vm) &&
virDomainObjIsPostcopy(vm, vm->job) &&
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;
@ -3910,7 +3910,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver,
if (flags & VIR_MIGRATE_POSTCOPY_RESUME) {
phase = QEMU_MIGRATION_PHASE_CONFIRM_RESUME;
} else if (virDomainObjIsFailedPostcopy(vm)) {
} else if (virDomainObjIsFailedPostcopy(vm, vm->job)) {
/* Keep the original migration phase in case post-copy failed as the
* job will stay active even though migration API finishes with an
* error.
@ -3970,7 +3970,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver,
if (virDomainObjGetState(vm, &reason) == VIR_DOMAIN_PAUSED &&
reason == VIR_DOMAIN_PAUSED_POSTCOPY) {
qemuMigrationSrcPostcopyFailed(vm);
} else if (!virDomainObjIsFailedPostcopy(vm)) {
} else if (!virDomainObjIsFailedPostcopy(vm, vm->job)) {
qemuMigrationSrcRestoreDomainState(driver, vm);
qemuMigrationParamsReset(vm, VIR_ASYNC_JOB_MIGRATION_OUT,
@ -4011,7 +4011,7 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver,
* job will stay active even though migration API finishes with an
* error.
*/
if (virDomainObjIsFailedPostcopy(vm))
if (virDomainObjIsFailedPostcopy(vm, vm->job))
phase = vm->job->phase;
else if (cancelled)
phase = QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED;
@ -4029,7 +4029,7 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver,
cookiein, cookieinlen,
flags, cancelled);
if (virDomainObjIsFailedPostcopy(vm)) {
if (virDomainObjIsFailedPostcopy(vm, vm->job)) {
ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POSTCOPY_FAILED));
qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob);
} else {
@ -6079,7 +6079,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver,
if (ret < 0)
virErrorPreserveLast(&orig_err);
if (virDomainObjIsFailedPostcopy(vm)) {
if (virDomainObjIsFailedPostcopy(vm, vm->job)) {
ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POSTCOPY_FAILED));
qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob);
} else {
@ -6167,7 +6167,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver,
ret = 0;
cleanup:
if (ret < 0 && !virDomainObjIsFailedPostcopy(vm)) {
if (ret < 0 && !virDomainObjIsFailedPostcopy(vm, vm->job)) {
qemuMigrationSrcRestoreDomainState(driver, vm);
qemuMigrationParamsReset(vm, VIR_ASYNC_JOB_MIGRATION_OUT,
jobPriv->migParams, vm->job->apiFlags);
@ -6708,7 +6708,7 @@ qemuMigrationDstFinishActive(virQEMUDriver *driver,
}
}
if (virDomainObjIsFailedPostcopy(vm)) {
if (virDomainObjIsFailedPostcopy(vm, vm->job)) {
ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POSTCOPY_FAILED));
virCloseCallbacksDomainRemove(vm, NULL, qemuProcessAutoDestroy);
*finishJob = false;

View File

@ -1473,7 +1473,7 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_GNUC_UNUSED,
break;
case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_RECOVER:
if (virDomainObjIsFailedPostcopy(vm)) {
if (virDomainObjIsFailedPostcopy(vm, vm->job)) {
int eventType = -1;
int eventDetail = -1;
@ -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) &&
if (virDomainObjIsPostcopy(vm, vm->job) &&
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))
if (virDomainObjIsPostcopy(vm, job))
return 1;
if (state != VIR_DOMAIN_RUNNING) {
@ -3511,7 +3511,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver,
int reason,
unsigned int *stopFlags)
{
bool postcopy = virDomainObjIsPostcopy(vm);
bool postcopy = virDomainObjIsPostcopy(vm, job);
bool resume = false;
VIR_DEBUG("Active outgoing migration in phase %s",