Post memory failure event to uplayer to handle hardware memory corrupted event. Rather than simple QEMU log, QEMU could report more effective message to uplayer. For example, guest crashes by MCE, selecting another host server is a better choice.
Signed-off-by: zhenwei pi <pizhen...@bytedance.com> --- target/i386/helper.c | 5 +++++ target/i386/kvm.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/target/i386/helper.c b/target/i386/helper.c index 0c7fd32491..f7b2dbeec8 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -18,6 +18,7 @@ */ #include "qemu/osdep.h" +#include "qapi/qapi-events-run-state.h" #include "cpu.h" #include "exec/exec-all.h" #include "qemu/qemu-print.h" @@ -897,6 +898,8 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data) } if (cenv->mcg_status & MCG_STATUS_MCIP) { + qapi_event_send_memory_failure( + MEMORY_FAILURE_ACTION_GUEST_TRIPLE_FAULT); need_reset = true; snprintf(msg, sizeof(msg), "CPU %d: Previous MCE still in progress," " raising triple fault", cs->cpu_index); @@ -934,6 +937,8 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data) } else { banks[1] |= MCI_STATUS_OVER; } + + qapi_event_send_memory_failure(MEMORY_FAILURE_ACTION_GUEST_MCE); } void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int bank, diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 205b68bc0c..63a585cc64 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-events-run-state.h" #include <sys/ioctl.h> #include <sys/utsname.h> @@ -577,6 +578,7 @@ static void kvm_mce_inject(X86CPU *cpu, hwaddr paddr, int code) static void hardware_memory_error(void *host_addr) { + qapi_event_send_memory_failure(MEMORY_FAILURE_ACTION_HYPERVISOR_STOP); error_report("QEMU got Hardware memory error at addr %p", host_addr); exit(1); } @@ -631,7 +633,8 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr) hardware_memory_error(addr); } - /* Hope we are lucky for AO MCE */ + /* Hope we are lucky for AO MCE, just notify a event */ + qapi_event_send_memory_failure(MEMORY_FAILURE_ACTION_HYPERVISOR_IGNORE); } static void kvm_reset_exception(CPUX86State *env) -- 2.11.0