Skip to contentSkip to conversation

runstate: don't move to prelaunch on reset if postmigrate

PATCH In review Vladimir Sementsov-Ogievskiy 2 participants 2 messages Jun 27 – Jun 29

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 runstate: don't move to prelaunch on reset if postmigrate

As comment says, runstate can change in parallel. We check for FINISH_MIGRATE, but actually migration may proceed up to POSTMIGRATE.

We should check for POSTMIGRATE as well, otherwise there is a race, if reset is in progress, and source may finish migration in PRELAUNCH state, which is unexpected for user.

Seems correct to handle POSTMIGRATE the same way as FINISH_MIGRATE in this logic, as POSTMIGRATE is continuation for FINISH_MIGRATE.

---
 system/runstate.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
system/runstate.c +2 -1
index 18e585be47..cee1aeae05 100644
@@ -921,7 +921,8 @@ static bool main_loop_should_exit(int *status)
          */
         if (!runstate_check(RUN_STATE_RUNNING) &&
                 !runstate_check(RUN_STATE_INMIGRATE) &&
-                !runstate_check(RUN_STATE_FINISH_MIGRATE)) {
+                !runstate_check(RUN_STATE_FINISH_MIGRATE) &&
+                !runstate_check(RUN_STATE_POSTMIGRATE)) {
             runstate_set(RUN_STATE_PRELAUNCH);
         }
     }
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Vladimir Sementsov-Ogievskiy

As comment says, runstate can change in parallel. We check for FINISH_MIGRATE, but actually migration may proceed up to POSTMIGRATE.

Quoted 8 lines

We should check for POSTMIGRATE as well, otherwise there is a race, if reset is in progress, and source may finish migration in PRELAUNCH state, which is unexpected for user.

Seems correct to handle POSTMIGRATE the same way as FINISH_MIGRATE in this logic, as POSTMIGRATE is continuation for FINISH_MIGRATE.

Signature · 1 line
Peter Xu