kvm: report available guest crash parameters
v2 cover kvm: report available guest crash parameters
Windows reports BSOD parameters through Hyper-V crash MSRs. This information is very useful for initial crash analysis and thus it would be nice to see it in the QEMU log file. There is suitable log mask for the purpose.
Linux guest does not provide this information, but still it would be nice to log that we have crashed.
Changes since v1:
- patches resplit
- created property to query crash parameters
- crash parameters added to panic event
Anton Nefedov (3):
i386/cpu: add crash-information QOM property report guest crash information in GUEST_PANICKED event
vl: log available guest crash information
hw/misc/pvpanic.c | 2 +- include/qom/cpu.h | 10 +++++++++ include/sysemu/kvm.h | 2 ++ include/sysemu/sysemu.h | 2 +- kvm-all.c | 3 ++- qapi-schema.json | 24 +++++++++++++++++++++ qapi/event.json | 6 ++++-- qom/cpu.c | 11 ++++++++++ stubs/Makefile.objs | 1 + stubs/kvm-crash.c | 8 +++++++ target/i386/cpu.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ target/i386/cpu.h | 3 +++ target/i386/kvm.c | 41 ++++++++++++++++++++++++++++++++++++ target/s390x/kvm.c | 4 ++-- vl.c | 23 ++++++++++++++++++--- 15 files changed, 185 insertions(+), 10 deletions(-) create mode 100644 stubs/kvm-crash.c
Signature · 1 line
2.7.4
PATCH v3 3/3 vl: log available guest crash information
From: Anton Nefedov <[email protected]>
There is a suitable log mask for the purpose.
--- vl.c | 9 +++++++++ 1 file changed, 9 insertions(+)
vl.c +9 -0
@@ -1709,6 +1709,8 @@ void qemu_system_reset(bool report)void qemu_system_guest_panicked (GuestPanicInformation *info) { +qemu_log_mask (LOG_GUEST_ERROR ,"Guest crashed\n" ); +if (current_cpu) { current_cpu->crash_occurred = true; }
@@ -1723,6 +1725,13 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)if (info) {if (info->type ==GUEST_PANIC_INFORMATION_KIND_HYPER_V ) { +qemu_log_mask (LOG_GUEST_ERROR ,"HV crash parameters: (%#" PRIx64 +" %#" PRIx64" %#" PRIx64" %#" PRIx64" %#" PRIx64")\n" , + info->u.hyper_v.data->arg1, + info->u.hyper_v.data->arg2, + info->u.hyper_v.data->arg3, + info->u.hyper_v.data->arg4, + info->u.hyper_v.data->arg5);g_free (info->u.hyper_v.data); }g_free (info);
Signature · 1 line
2.7.4
PATCH v2 1/3 i386/cpu: add crash-information QOM property
In reply to Denis V. LunevFrom: Anton Nefedov <[email protected]>
Windows reports BSOD parameters through Hyper-V crash MSRs. This information is very useful for initial crash analysis and thus it would be nice to have a way to fetch it.
--- include/sysemu/kvm.h | 2 ++ kvm-all.c | 1 + qapi-schema.json | 24 +++++++++++++++++++++++ stubs/Makefile.objs | 1 + stubs/kvm-crash.c | 8 ++++++++ target/i386/cpu.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ target/i386/cpu.h | 3 +++ target/i386/kvm.c | 41 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 134 insertions(+) create mode 100644 stubs/kvm-crash.c
include/sysemu/kvm.h +2 -0
@@ -527,4 +527,6 @@ int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source);*/ int kvm_get_one_reg (CPUState *cs,uint64_t id,void *target);int kvm_get_max_memslots (void ); + +void kvm_arch_save_crash_info (CPUState *cpu);#endif
kvm-all.c +1 -0
@@ -2000,6 +2000,7 @@ int kvm_cpu_exec(CPUState *cpu) ret =EXCP_INTERRUPT ;break ;case KVM_SYSTEM_EVENT_CRASH : +kvm_arch_save_crash_info (cpu);qemu_mutex_lock_iothread ();qemu_system_guest_panicked ();qemu_mutex_unlock_iothread ();
qapi-schema.json +24 -0
@@ -5846,6 +5846,30 @@ 'data': [ 'pause', 'poweroff' ] } ## +# @GuestPanicInformation: +# +# Information about a guest panic +# +# Since: 2.9 +## +{'union': 'GuestPanicInformation', + 'data': { 'hyper-v': 'GuestPanicInformationHyperV' } } + +## +# @GuestPanicInformationHyperV: +# +# Hyper-V specific guest panic information (HV crash MSRs) +# +# Since: 2.9 +## +{'struct': 'GuestPanicInformationHyperV', + 'data': { 'arg1': 'uint64', + 'arg2': 'uint64', + 'arg3': 'uint64', + 'arg4': 'uint64', + 'arg5': 'uint64' } } + +## # @rtc-reset-reinjection: # # This command will reset the RTC interrupt reinjection backlog.
stubs/Makefile.objs +1 -0
@@ -35,3 +35,4 @@ stub-obj-y += qmp_pc_dimm_device_list.o stub-obj-y += target-monitor-defs.o stub-obj-y += target-get-monitor-def.o stub-obj-y += pc_madt_cpu_entry.o +stub-obj-y += kvm-crash.o
stubs/kvm-crash.c new file +8 -0
@@ -0,0 +1,8 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "sysemu/kvm.h" + +void kvm_arch_save_crash_info (CPUState *cs) +{ +return ; +}
target/i386/cpu.c +54 -0
66 lines not on this page · raw message
target/i386/cpu.h +3 -0
@@ -1258,6 +1258,9 @@ struct X86CPU {/* Number of physical address bits supported */ uint32_t phys_bits; +/* Hyper-V crash MSRs */ +uint64_t hv_msr_crash_params[HV_X64_MSR_CRASH_PARAMS ]; +/* in order to simplify APIC support, we leave this pointer to the user */ struct DeviceState *apic_state;
target/i386/kvm.c +41 -0
53 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 2/3 report guest crash information in GUEST_PANICKED event
In reply to Denis V. LunevFrom: Anton Nefedov <[email protected]>
it's not very convenient to use the crash-information property interface, so provide a CPU class callback to get the guest crash information, and pass that information in the event
--- hw/misc/pvpanic.c | 2 +- include/qom/cpu.h | 10 ++++++++++ include/sysemu/sysemu.h | 2 +- kvm-all.c | 2 +- qapi/event.json | 6 ++++-- qom/cpu.c | 11 +++++++++++ target/i386/cpu.c | 1 + target/s390x/kvm.c | 4 ++-- vl.c | 14 +++++++++++--- 9 files changed, 42 insertions(+), 10 deletions(-)
hw/misc/pvpanic.c +1 -1
@@ -42,7 +42,7 @@ static void handle_event(int event) }if (event &PVPANIC_PANICKED ) { -qemu_system_guest_panicked (); +qemu_system_guest_panicked (NULL );return ; } }
include/qom/cpu.h +10 -0
@@ -156,6 +156,7 @@ typedef struct CPUClass { uint8_t *buf, int len, bool is_write);void (*dump_state)(CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); + GuestPanicInformation* (*get_crash_info)(CPUState *cpu);void (*dump_statistics)(CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags);int64_t (*get_arch_id)(CPUState *cpu);
@@ -469,6 +470,15 @@ int cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu, void *opaque);/** +* cpu_get_crash_info: +* @cpu: The CPU to get crash information for +* +* Gets the previously saved crash information. +* Caller is responsible for freeing the data. +*/ +GuestPanicInformation *cpu_get_crash_info (CPUState *cpu); + +/** * CPUDumpFlags: * @CPU_DUMP_CODE: * @CPU_DUMP_FPU: dump FPU register state, not just integer
include/sysemu/sysemu.h +1 -1
@@ -64,7 +64,7 @@ int qemu_shutdown_requested_get(void);int qemu_reset_requested_get (void );void qemu_system_killed (int signal,pid_t pid);void qemu_system_reset (bool report); -void qemu_system_guest_panicked (void ); +void qemu_system_guest_panicked (GuestPanicInformation *info);size_t qemu_target_page_bits (void );void qemu_add_exit_notifier (Notifier *notify);
kvm-all.c +1 -1
@@ -2002,7 +2002,7 @@ int kvm_cpu_exec(CPUState *cpu)case KVM_SYSTEM_EVENT_CRASH :kvm_arch_save_crash_info (cpu);qemu_mutex_lock_iothread (); -qemu_system_guest_panicked (); +qemu_system_guest_panicked (cpu_get_crash_info (cpu));qemu_mutex_unlock_iothread (); ret =0 ;break ;
qapi/event.json +4 -2
@@ -488,7 +488,9 @@ # # @action: action that has been taken, currently always "pause" # -# Since: 1.5 +# @info: optional information about a panic +# +# Since: 1.5 (@info since 2.9) # # Example: #
@@ -497,7 +499,7 @@ # ## { 'event': 'GUEST_PANICKED', - 'data': { 'action': 'GuestPanicAction' } } + 'data': { 'action': 'GuestPanicAction', '*info': 'GuestPanicInformation' } } ## # @QUORUM_FAILURE:
qom/cpu.c +11 -0
@@ -218,6 +218,17 @@ static bool cpu_common_exec_interrupt(CPUState *cpu, int int_req)return false; } +GuestPanicInformation *cpu_get_crash_info (CPUState *cpu) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); +GuestPanicInformation *res =NULL ; + +if (cc->get_crash_info) { + res = cc->get_crash_info (cpu); + } +return res; +} +void cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags) {
target/i386/cpu.c +1 -0
@@ -3738,6 +3738,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->do_interrupt = x86_cpu_do_interrupt; cc->cpu_exec_interrupt = x86_cpu_exec_interrupt; cc->dump_state = x86_cpu_dump_state; + cc->get_crash_info = x86_cpu_get_crash_info; cc->set_pc = x86_cpu_set_pc; cc->synchronize_from_tb = x86_cpu_synchronize_from_tb; cc->gdb_read_register = x86_cpu_gdb_read_register;
target/s390x/kvm.c +2 -2
@@ -1864,7 +1864,7 @@ static void unmanageable_intercept(S390CPU *cpu, const char *str, int pswoffset) str, cs->cpu_index,ldq_phys (cs->as, cpu->env.psa + pswoffset), ldq_phys(cs->as, cpu->env.psa + pswoffset + 8));s390_cpu_halt (cpu); -qemu_system_guest_panicked (); +qemu_system_guest_panicked (NULL ); }static int handle_intercept (S390CPU *cpu)
@@ -1897,7 +1897,7 @@ static int handle_intercept(S390CPU *cpu)if (is_special_wait_psw (cs)) {qemu_system_shutdown_request (); }else { -qemu_system_guest_panicked (); +qemu_system_guest_panicked (NULL ); } } r =EXCP_HALTED ;
vl.c +11 -3
@@ -1707,18 +1707,26 @@ void qemu_system_reset(bool report)cpu_synchronize_all_post_reset (); } -void qemu_system_guest_panicked (void ) +void qemu_system_guest_panicked (GuestPanicInformation *info) {if (current_cpu) { current_cpu->crash_occurred = true; } -qapi_event_send_guest_panicked (GUEST_PANIC_ACTION_PAUSE , &error_abort); +qapi_event_send_guest_panicked (GUEST_PANIC_ACTION_PAUSE , + !!info, info, &error_abort);vm_stop (RUN_STATE_GUEST_PANICKED );if (!no_shutdown) {qapi_event_send_guest_panicked (GUEST_PANIC_ACTION_POWEROFF , - &error_abort); + !!info, info, &error_abort);qemu_system_shutdown_request (); } + +if (info) { +if (info->type ==GUEST_PANIC_INFORMATION_KIND_HYPER_V ) { +g_free (info->u.hyper_v.data); + } +g_free (info); + } }void qemu_system_reset_request (void )
Signature · 1 line
2.7.4
Quoted 5 lines · Denis V. Lunev
Windows reports BSOD parameters through Hyper-V crash MSRs. This information is very useful for initial crash analysis and thus it would be nice to see it in the QEMU log file. There is suitable log mask for the purpose.
Quoted 7 lines
Linux guest does not provide this information, but still it would be nice to log that we have crashed.
Changes since v1:
- patches resplit
- created property to query crash parameters
- crash parameters added to panic event
This has a compiling error:
/var/tmp/patchew-tester-tmp-fmkso1x2/src/hw/ppc/spapr_rtas.c: In function ‘rtas_ibm_os_term’:/var/tmp/patchew-tester-tmp-fmkso1x2/src/hw/ppc/spapr_rtas.c:337:5: error: the address of ‘error_abort’ will always evaluate as ‘true’ [-Werror=address]
qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/var/tmp/patchew-tester-tmp-fmkso1x2/src/hw/ppc/spapr_rtas.c:337:5: error: too few arguments to function ‘qapi_event_send_guest_panicked’
In file included from /var/tmp/patchew-tester-tmp-fmkso1x2/src/hw/ppc/spapr_rtas.c:42:0:
../qapi-event.h:48:6: note: declared here
void qapi_event_send_guest_panicked(GuestPanicAction action, bool has_info, GuestPanicInformation *info, Error **errp);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cc1: all warnings being treated as errors /var/tmp/patchew-tester-tmp-fmkso1x2/src/rules.mak:69: recipe for target 'hw/ppc/spapr_rtas.o' failed make[1]: *** [hw/ppc/spapr_rtas.o] Error 1
Makefile:318: recipe for target 'subdir-ppc64-softmmu' failed
Quoted 24 lines · Fam Zheng
Quoted 5 lines · Denis V. Lunev
Windows reports BSOD parameters through Hyper-V crash MSRs. This information is very useful for initial crash analysis and thus it would be nice to see it in the QEMU log file. There is suitable log mask for the purpose.
Quoted 7 lines
Linux guest does not provide this information, but still it would be nice to log that we have crashed.
Changes since v1:
- patches resplit
- created property to query crash parameters
- crash parameters added to panic eventThis has a compiling error:
/var/tmp/patchew-tester-tmp-fmkso1x2/src/hw/ppc/spapr_rtas.c: In function ‘rtas_ibm_os_term’:/var/tmp/patchew-tester-tmp-fmkso1x2/src/hw/ppc/spapr_rtas.c:337:5: error: the address of ‘error_abort’ will always evaluate as ‘true’ [-Werror=address]qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /var/tmp/patchew-tester-tmp-fmkso1x2/src/hw/ppc/spapr_rtas.c:337:5: error: too few arguments to function ‘qapi_event_send_guest_panicked’ In file included from /var/tmp/patchew-tester-tmp-fmkso1x2/src/hw/ppc/spapr_rtas.c:42:0: ../qapi-event.h:48:6: note: declared here void qapi_event_send_guest_panicked(GuestPanicAction action, bool has_info, GuestPanicInformation *info, Error **errp); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 5 lines
cc1: all warnings being treated as errors
/var/tmp/patchew-tester-tmp-fmkso1x2/src/rules.mak:69: recipe for target 'hw/ppc/spapr_rtas.o' failed make[1]: *** [hw/ppc/spapr_rtas.o] Error 1
Makefile:318: recipe for target 'subdir-ppc64-softmmu' failed
oops. will check other arches and resubmit. My fault.
Den