]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Drop virDomainJobOperation parameter from virDomainObjIsPostcopy
authorJiri Denemark <jdenemar@redhat.com>
Wed, 7 Dec 2022 13:46:25 +0000 (14:46 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 6 Jan 2023 15:17:38 +0000 (16:17 +0100)
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>
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_driver.c
src/qemu/qemu_migration.c
src/qemu/qemu_process.c

index 66189277fd3d8fc48d53037e38c93bce207657ad..b43b8faef78183c0fcb310af811538d2c827b2c6 100644 (file)
@@ -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 (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));
-    }
+    if (virDomainObjIsFailedPostcopy(dom))
+        return true;
 
-    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);
 }
 
 
index 33c4ff69ddbdd082196e199719ca400edb6685da..d59d6a6fa10c665f7903dea632b67a2b310ee24a 100644 (file)
@@ -3962,8 +3962,7 @@ bool
 virDomainObjIsFailedPostcopy(virDomainObj *obj)
         ATTRIBUTE_NONNULL(1);
 bool
-virDomainObjIsPostcopy(virDomainObj *dom,
-                       virDomainJobOperation op)
+virDomainObjIsPostcopy(virDomainObj *dom)
         ATTRIBUTE_NONNULL(1);
 
 virSecurityLabelDef *
index 65b20e204c4086b93ed3f078b1a4e83052236c6f..f03764e69dc3ed844fb58d67a7d0f34bd2ee8554 100644 (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, 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);
index 54626bd8515d9451d3a52c44f7ecec5bd76deeca..65565fcb5981aa8a14ab159dd226d15cd7e9078e 100644 (file)
@@ -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;
index 644fa9724ade4a1cf31c179e8ed3dabe814d393b..0de6acebd145d501a5ef56abb09e143cefc8ac33 100644 (file)
@@ -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",