From: Sasha Levin <levinsasha928@gmail.com>
To: penberg@kernel.org
Cc: mingo@elte.hu, gorcunov@gmail.com, asias.hejun@gmail.com,
kvm@vger.kernel.org, Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH 2/2] kvm tools: Add ability to assert/deassert IRQs using 'kvm debug'
Date: Mon, 12 Dec 2011 11:19:50 +0200 [thread overview]
Message-ID: <1323681590-9812-2-git-send-email-levinsasha928@gmail.com> (raw)
In-Reply-To: <1323681590-9812-1-git-send-email-levinsasha928@gmail.com>
Add options to assert and deassert IRQs using 'kvm debug'. For example, to
assert IRQ4 in guest 'my_instance':
vm debug -n my_instance --assert_irq 4
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
tools/kvm/builtin-debug.c | 19 +++++++++++++++++++
tools/kvm/builtin-run.c | 12 ++++++++++++
tools/kvm/include/kvm/builtin-debug.h | 5 +++++
3 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/tools/kvm/builtin-debug.c b/tools/kvm/builtin-debug.c
index 292172a..37aed61 100644
--- a/tools/kvm/builtin-debug.c
+++ b/tools/kvm/builtin-debug.c
@@ -15,6 +15,7 @@
static bool all;
static int instance;
static int nmi = -1;
+static int assert_irq = -1, deassert_irq = -1, trigger_irq = -1, rtrigger_irq = -1;
static bool dump;
static const char *instance_name;
@@ -27,6 +28,10 @@ static const struct option debug_options[] = {
OPT_GROUP("General options:"),
OPT_BOOLEAN('d', "dump", &dump, "Generate a debug dump from guest"),
OPT_INTEGER('m', "nmi", &nmi, "Generate NMI on VCPU"),
+ OPT_INTEGER('\0', "assert_irq", &assert_irq, "Assert an IRQ"),
+ OPT_INTEGER('\0', "deassert_irq", &deassert_irq, "Deassert an IRQ"),
+ OPT_INTEGER('\0', "trigger_irq", &trigger_irq, "Trigger an IRQ"),
+ OPT_INTEGER('\0', "rtrigger_irq", &rtrigger_irq, "Reverse trigger an IRQ"),
OPT_GROUP("Instance options:"),
OPT_BOOLEAN('a', "all", &all, "Debug all instances"),
OPT_STRING('n', "name", &instance_name, "name", "Instance name"),
@@ -62,6 +67,20 @@ static int do_debug(const char *name, int sock)
cmd.params.cpu = nmi;
}
+ if (assert_irq != -1) {
+ cmd.params.dbg_type |= KVM_DEBUG_CMD_TYPE_ASRT;
+ cmd.params.irq = assert_irq;
+ } else if (deassert_irq != -1) {
+ cmd.params.dbg_type |= KVM_DEBUG_CMD_TYPE_DSRT;
+ cmd.params.irq = deassert_irq;
+ } else if (trigger_irq != -1) {
+ cmd.params.dbg_type |= KVM_DEBUG_CMD_TYPE_TRG;
+ cmd.params.irq = trigger_irq;
+ } else if (rtrigger_irq != -1) {
+ cmd.params.dbg_type |= KVM_DEBUG_CMD_TYPE_RTRG;
+ cmd.params.irq = rtrigger_irq;
+ }
+
r = xwrite(sock, &cmd, sizeof(cmd));
if (r < 0)
return r;
diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 5045278..21af78a 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -513,6 +513,7 @@ static void handle_debug(int fd, u32 type, u32 len, u8 *msg)
struct debug_cmd_params *params = (void *)msg;
u32 dbg_type = params->dbg_type;
u32 vcpu = params->cpu;
+ u32 irq = params->irq;
if (dbg_type & KVM_DEBUG_CMD_TYPE_NMI) {
if ((int)vcpu >= kvm->nrcpus)
@@ -522,6 +523,17 @@ static void handle_debug(int fd, u32 type, u32 len, u8 *msg)
pthread_kill(kvm_cpus[vcpu]->thread, SIGUSR1);
}
+ if (dbg_type & KVM_DEBUG_CMD_TYPE_ASRT)
+ kvm__irq_line(kvm, irq, 1);
+ else if (dbg_type & KVM_DEBUG_CMD_TYPE_DSRT)
+ kvm__irq_line(kvm, irq, 0);
+ else if (dbg_type & KVM_DEBUG_CMD_TYPE_TRG)
+ kvm__irq_trigger(kvm, irq);
+ else {
+ kvm__irq_line(kvm, irq, 1);
+ kvm__irq_line(kvm, irq, 0);
+ }
+
if (!(dbg_type & KVM_DEBUG_CMD_TYPE_DUMP))
return;
diff --git a/tools/kvm/include/kvm/builtin-debug.h b/tools/kvm/include/kvm/builtin-debug.h
index 0aafef9..86dc5df 100644
--- a/tools/kvm/include/kvm/builtin-debug.h
+++ b/tools/kvm/include/kvm/builtin-debug.h
@@ -5,10 +5,15 @@
#define KVM_DEBUG_CMD_TYPE_DUMP (1 << 0)
#define KVM_DEBUG_CMD_TYPE_NMI (1 << 1)
+#define KVM_DEBUG_CMD_TYPE_ASRT (1 << 2)
+#define KVM_DEBUG_CMD_TYPE_DSRT (1 << 3)
+#define KVM_DEBUG_CMD_TYPE_TRG (1 << 4)
+#define KVM_DEBUG_CMD_TYPE_RTRG (1 << 5)
struct debug_cmd_params {
u32 dbg_type;
u32 cpu;
+ u32 irq;
};
struct debug_cmd {
--
1.7.8
next prev parent reply other threads:[~2011-12-12 9:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-12 9:19 [PATCH 1/2] kvm tools: Clean up 'kvm debug' Sasha Levin
2011-12-12 9:19 ` Sasha Levin [this message]
2011-12-12 21:33 ` [PATCH 2/2] kvm tools: Add ability to assert/deassert IRQs using " Pekka Enberg
2011-12-13 5:37 ` Sasha Levin
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=1323681590-9812-2-git-send-email-levinsasha928@gmail.com \
--to=levinsasha928@gmail.com \
--cc=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=penberg@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).