hv: vm_event: send event on triple fault handler

In the triple fault handler, post-launched VMs are instantly turned
off. Now a vm event is generated simultaneously. So that
developers can capture the event and decide what to do with it. (e.g.,
logging and populating diagnostics, or poweroff VM)

Tracked-On: #8547
Signed-off-by: Wu Zhou <wu.zhou@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Wu Zhou 2023-08-04 14:11:32 +08:00 committed by acrnsi-robot
parent 7eb44dbcd3
commit 29b3d03ac7

View File

@ -10,6 +10,7 @@
#include <logmsg.h>
#include <asm/per_cpu.h>
#include <asm/guest/vm_reset.h>
#include <vm_event.h>
/**
* @pre vm != NULL
@ -17,6 +18,7 @@
void triple_fault_shutdown_vm(struct acrn_vcpu *vcpu)
{
struct acrn_vm *vm = vcpu->vm;
struct vm_event trp_event;
if (is_postlaunched_vm(vm)) {
struct io_request *io_req = &vcpu->req;
@ -28,6 +30,10 @@ void triple_fault_shutdown_vm(struct acrn_vcpu *vcpu)
io_req->reqs.pio_request.size = 2UL;
io_req->reqs.pio_request.value = (VIRTUAL_PM1A_SLP_EN | (5U << 10U));
/* Send the tripple fault event to DM. */
trp_event.type = VM_EVENT_TRIPLE_FAULT;
(void)send_vm_event(vcpu->vm, &trp_event);
/* Inject pm1a S5 request to Service VM to shut down the guest */
(void)emulate_io(vcpu, io_req);
} else {