mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-05 19:47:48 +00:00
hv: Add stateful VM check before system shutdown
This patch introduces stateful VM which represents a VM that has its own internal state such as a file cache, and adds a check before system shutdown to make sure that stateless VM does not block system shutdown. Tracked-On: #6571 Signed-off-by: Wang Yu <yu1.wang@intel.com> Signed-off-by: Yifan Liu <yifan1.liu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
71da1bed9b
commit
0d59577fe4
@ -156,6 +156,22 @@ bool is_rt_vm(const struct acrn_vm *vm)
|
|||||||
return ((vm_config->guest_flags & GUEST_FLAG_RT) != 0U);
|
return ((vm_config->guest_flags & GUEST_FLAG_RT) != 0U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pre vm != NULL && vm_config != NULL && vm->vmid < CONFIG_MAX_VM_NUM
|
||||||
|
*
|
||||||
|
* Stateful VM refers to VM that has its own state (such as internal file cache),
|
||||||
|
* and will experience state loss (file system corruption) if force powered down.
|
||||||
|
*/
|
||||||
|
bool is_stateful_vm(const struct acrn_vm *vm)
|
||||||
|
{
|
||||||
|
struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
|
||||||
|
|
||||||
|
/* TEE VM doesn't has its own state. The TAs will do the content
|
||||||
|
* flush by themselves, HV and OS doesn't need to care about the state.
|
||||||
|
*/
|
||||||
|
return ((vm_config->guest_flags & GUEST_FLAG_TEE) == 0U);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @pre vm != NULL && vm_config != NULL && vm->vmid < CONFIG_MAX_VM_NUM
|
* @pre vm != NULL && vm_config != NULL && vm->vmid < CONFIG_MAX_VM_NUM
|
||||||
*/
|
*/
|
||||||
@ -751,7 +767,7 @@ static bool is_ready_for_system_shutdown(void)
|
|||||||
for (vm_id = 0U; vm_id < CONFIG_MAX_VM_NUM; vm_id++) {
|
for (vm_id = 0U; vm_id < CONFIG_MAX_VM_NUM; vm_id++) {
|
||||||
vm = get_vm_from_vmid(vm_id);
|
vm = get_vm_from_vmid(vm_id);
|
||||||
/* TODO: Update code to cover hybrid mode */
|
/* TODO: Update code to cover hybrid mode */
|
||||||
if (!is_poweroff_vm(vm)) {
|
if (!is_poweroff_vm(vm) && is_stateful_vm(vm)) {
|
||||||
ret = false;
|
ret = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -256,6 +256,7 @@ void vrtc_init(struct acrn_vm *vm);
|
|||||||
|
|
||||||
bool is_lapic_pt_configured(const struct acrn_vm *vm);
|
bool is_lapic_pt_configured(const struct acrn_vm *vm);
|
||||||
bool is_rt_vm(const struct acrn_vm *vm);
|
bool is_rt_vm(const struct acrn_vm *vm);
|
||||||
|
bool is_stateful_vm(const struct acrn_vm *vm);
|
||||||
bool is_nvmx_configured(const struct acrn_vm *vm);
|
bool is_nvmx_configured(const struct acrn_vm *vm);
|
||||||
bool is_vcat_configured(const struct acrn_vm *vm);
|
bool is_vcat_configured(const struct acrn_vm *vm);
|
||||||
bool is_static_configured_vm(const struct acrn_vm *vm);
|
bool is_static_configured_vm(const struct acrn_vm *vm);
|
||||||
|
Loading…
Reference in New Issue
Block a user