@@ -593,12 +593,6 @@ static const RunStateTransition runstate_transitions_def[] = {
{ RUN_STATE_INMIGRATE, RUN_STATE_RUNNING },
{ RUN_STATE_INMIGRATE, RUN_STATE_PAUSED },
- { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED },
- { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE },
-
- { RUN_STATE_IO_ERROR, RUN_STATE_RUNNING },
- { RUN_STATE_IO_ERROR, RUN_STATE_FINISH_MIGRATE },
-
{ RUN_STATE_PAUSED, RUN_STATE_RUNNING },
{ RUN_STATE_PAUSED, RUN_STATE_FINISH_MIGRATE },
@@ -635,16 +629,17 @@ static const RunStateTransition runstate_transitions_def[] = {
{ RUN_STATE_SUSPENDED, RUN_STATE_RUNNING },
{ RUN_STATE_SUSPENDED, RUN_STATE_FINISH_MIGRATE },
- { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING },
- { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE },
-
- { RUN_STATE_GUEST_PANICKED, RUN_STATE_PAUSED },
- { RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE },
- { RUN_STATE_GUEST_PANICKED, RUN_STATE_DEBUG },
-
{ RUN_STATE_MAX, RUN_STATE_MAX },
};
+static const RunState runstate_paused[] = {
+ { RUN_STATE_GUEST_PANICKED},
+ { RUN_STATE_IO_ERROR},
+ { RUN_STATE_INTERNAL_ERROR},
+ { RUN_STATE_WATCHDOG},
+ { RUN_STATE_MAX },
+};
+
static bool runstate_valid_transitions[RUN_STATE_MAX][RUN_STATE_MAX];
bool runstate_check(RunState state)
@@ -655,12 +650,21 @@ bool runstate_check(RunState state)
static void runstate_init(void)
{
const RunStateTransition *p;
+ const RunState *i;
memset(&runstate_valid_transitions, 0, sizeof(runstate_valid_transitions));
for (p = &runstate_transitions_def[0]; p->from != RUN_STATE_MAX; p++) {
runstate_valid_transitions[p->from][p->to] = true;
}
+ /* Allow two-way transitions between identical states */
+ for (i = &runstate_paused[0]; *p != RUN_STATE_MAX; p++) {
+ runstate_valid_transitions[*i][RUN_STATE_PAUSED] = true;
+ runstate_valid_transitions[RUN_STATE_PAUSED][*i] = true;
+ memcpy(&runstate_valid_transitions[*i],
+ &runstate_valid_transitions[RUN_STATE_PAUSED],
+ sizeof(runstate_valid_transitions[RUN_STATE_PAUSED]));
+ }
}
/* This function will abort() on invalid state transitions */
@@ -686,8 +690,6 @@ int runstate_is_running(void)
bool runstate_needs_reset(void)
{
- return runstate_check(RUN_STATE_INTERNAL_ERROR) ||
- runstate_check(RUN_STATE_SHUTDOWN) ||
- runstate_check(RUN_STATE_GUEST_PANICKED);
+ return runstate_check(RUN_STATE_SHUTDOWN);
}
StatusInfo *qmp_query_status(Error **errp)