hv: pm: avoid duplicate shutdowns on RTVM

It is possible for more than one vCPUs to trigger shutdown on an RTVM.
We need to avoid entering VM_READY_TO_POWEROFF state again after the
RTVM has been paused or shut down.

Also, make sure an RTVM enters VM_READY_TO_POWEROFF state before it can
be paused.

v1 -> v2:
- rename to poweroff_if_rt_vm for better clarity

Tracked-On: #5411
Signed-off-by: Peter Fang <peter.fang@intel.com>
This commit is contained in:
Peter Fang
2020-11-05 17:40:54 -08:00
committed by wenlingz
parent e6ca39406a
commit 68dc8d9f8f
4 changed files with 18 additions and 10 deletions

View File

@@ -722,6 +722,16 @@ int32_t reset_vm(struct acrn_vm *vm)
return ret;
}
/**
* @pre vm != NULL
*/
void poweroff_if_rt_vm(struct acrn_vm *vm)
{
if (is_rt_vm(vm) && !is_paused_vm(vm) && !is_poweroff_vm(vm)) {
vm->state = VM_READY_TO_POWEROFF;
}
}
/**
* @pre vm != NULL
*/