From: Pekka Enberg <penberg@kernel.org>
To: kvm@vger.kernel.org
Cc: Pekka Enberg <penberg@kernel.org>,
Asias He <asias.hejun@gmail.com>, Avi Kivity <avi@redhat.com>,
Cyrill Gorcunov <gorcunov@gmail.com>, Ingo Molnar <mingo@elte.hu>,
Prasad Joshi <prasadjoshi124@gmail.com>,
Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH] kvm tools: Fix 'kill -3' hangs
Date: Sun, 8 May 2011 13:01:42 +0300 [thread overview]
Message-ID: <1304848902-11327-1-git-send-email-penberg@kernel.org> (raw)
Ingo Molnar reported that 'kill -3' didn't work on his machine:
* Ingo Molnar <mingo@elte.hu> 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@elte.hu>
Cc: Asias He <asias.hejun@gmail.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
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
next reply other threads:[~2011-05-08 10:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-08 10:01 Pekka Enberg [this message]
2011-05-09 7:27 ` [PATCH] kvm tools: Fix and improve the CPU register dump debug output code Ingo Molnar
2011-05-09 7:45 ` [PATCH] kvm tools: Dump vCPUs in order Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1304848902-11327-1-git-send-email-penberg@kernel.org \
--to=penberg@kernel.org \
--cc=asias.hejun@gmail.com \
--cc=avi@redhat.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=mingo@elte.hu \
--cc=prasadjoshi124@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox