Ingo Molnar reported that 'kill -3' didn't work on his machine: * Ingo Molnar <mingo@xxxxxxx> wrote: > This is really cumbersome to debug - is there some good way to get to the RIP > that the guest is hanging in? If kvm would print that out to the host console > (even if it's just the raw RIP initially) on a kill -3 that would help > enormously. Looks like the code should be doing that already - but the ioctl(KVM_GET_SREGS) hangs: [pid 748] ioctl(6, KVM_GET_SREGS Avi Kivity pointed out that it's not safe to call KVM_GET_SREGS (or other vcpu related ioctls) from other threads: > is it not OK to call KVM_GET_SREGS from other threads than the one > that's doing KVM_RUN? From Documentation/kvm/api.txt: - vcpu ioctls: These query and set attributes that control the operation of a single virtual cpu. Only run vcpu ioctls from the same thread that was used to create the vcpu. Fix that up by using pthread_kill() to force the threads that are doing KVM_RUN to do the register dumps. Reported: Ingo Molnar <mingo@xxxxxxx> Cc: Asias He <asias.hejun@xxxxxxxxx> Cc: Avi Kivity <avi@xxxxxxxxxx> Cc: Cyrill Gorcunov <gorcunov@xxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxx> Cc: Prasad Joshi <prasadjoshi124@xxxxxxxxx> Cc: Sasha Levin <levinsasha928@xxxxxxxxx> Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx> --- tools/kvm/kvm-run.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c index eb50b6a..58e2977 100644 --- a/tools/kvm/kvm-run.c +++ b/tools/kvm/kvm-run.c @@ -127,6 +127,18 @@ static const struct option options[] = { OPT_END() }; +static void handle_sigusr1(int sig) +{ + struct kvm_cpu *cpu = current_kvm_cpu; + + if (!cpu) + return; + + kvm_cpu__show_registers(cpu); + kvm_cpu__show_code(cpu); + kvm_cpu__show_page_tables(cpu); +} + static void handle_sigquit(int sig) { int i; @@ -134,9 +146,10 @@ static void handle_sigquit(int sig) for (i = 0; i < nrcpus; i++) { struct kvm_cpu *cpu = kvm_cpus[i]; - kvm_cpu__show_registers(cpu); - kvm_cpu__show_code(cpu); - kvm_cpu__show_page_tables(cpu); + if (!cpu) + continue; + + pthread_kill(cpu->thread, SIGUSR1); } serial8250__inject_sysrq(kvm); @@ -332,6 +345,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) signal(SIGALRM, handle_sigalrm); signal(SIGQUIT, handle_sigquit); + signal(SIGUSR1, handle_sigusr1); while (argc != 0) { argc = parse_options(argc, argv, options, run_usage, -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html