From: Sasha Levin <levinsasha928@gmail.com>
To: penberg@kernel.org
Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com,
gorcunov@gmail.com, prasadjoshi124@gmail.com,
Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH] kvm tools: Implement keyboard reset method
Date: Fri, 17 Jun 2011 09:13:29 -0400 [thread overview]
Message-ID: <1308316409-9825-1-git-send-email-levinsasha928@gmail.com> (raw)
Implement the keyboard reset method which allows guest kernel
to reboot the guest using the keyboard controller.
This will allow guest kernel to reboot the guest when it needs to,
for example - kernel panic (when passing "panic=1" as kernel parameter).
Based on Pekka Enberg's patch.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
tools/kvm/hw/i8042.c | 8 ++++++--
tools/kvm/include/kvm/kvm.h | 2 ++
tools/kvm/kvm-cpu.c | 2 +-
tools/kvm/kvm-run.c | 4 ++--
4 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/tools/kvm/hw/i8042.c b/tools/kvm/hw/i8042.c
index 21a779e..0bcf7e6 100644
--- a/tools/kvm/hw/i8042.c
+++ b/tools/kvm/hw/i8042.c
@@ -30,6 +30,7 @@
#define I8042_CMD_AUX_TEST 0xA9
#define I8042_CMD_AUX_DISABLE 0xA7
#define I8042_CMD_AUX_ENABLE 0xA8
+#define I8042_CMD_SYSTEM_RESET 0xFE
#define RESPONSE_ACK 0xFA
@@ -138,7 +139,7 @@ void kbd_queue(u8 c)
kbd_update_irq();
}
-static void kbd_write_command(u8 val)
+static void kbd_write_command(struct kvm *kvm, u8 val)
{
switch (val) {
case I8042_CMD_CTL_RCTR:
@@ -159,6 +160,9 @@ static void kbd_write_command(u8 val)
case I8042_CMD_AUX_ENABLE:
state.mode &= ~MODE_DISABLE_AUX;
break;
+ case I8042_CMD_SYSTEM_RESET:
+ kvm->stopped = true;
+ break;
default:
break;
}
@@ -314,7 +318,7 @@ static bool kbd_out(struct ioport *ioport, struct kvm *kvm, u16 port, void *data
switch (port) {
case I8042_COMMAND_REG: {
u8 value = ioport__read8(data);
- kbd_write_command(value);
+ kbd_write_command(kvm, value);
break;
}
case I8042_DATA_REG: {
diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h
index 7d90d35..d647ecf 100644
--- a/tools/kvm/include/kvm/kvm.h
+++ b/tools/kvm/include/kvm/kvm.h
@@ -41,6 +41,8 @@ struct kvm {
const char *vmlinux;
struct disk_image **disks;
int nr_disks;
+
+ bool stopped;
};
struct kvm *kvm__init(const char *kvm_dev, u64 ram_size);
diff --git a/tools/kvm/kvm-cpu.c b/tools/kvm/kvm-cpu.c
index 1fb1c74..35b3bd7 100644
--- a/tools/kvm/kvm-cpu.c
+++ b/tools/kvm/kvm-cpu.c
@@ -433,7 +433,7 @@ int kvm_cpu__start(struct kvm_cpu *cpu)
kvm_cpu__setup_cpuid(cpu);
kvm_cpu__reset_vcpu(cpu);
- for (;;) {
+ while (!cpu->kvm->stopped) {
if (cpu->paused) {
kvm__notify_paused();
cpu->paused = 0;
diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c
index 6ad55aa..1310e39 100644
--- a/tools/kvm/kvm-run.c
+++ b/tools/kvm/kvm-run.c
@@ -648,17 +648,17 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
kvm__init_ram(kvm);
+ kbd__init(kvm);
+
if (vnc || sdl)
fb = vesa__init(kvm);
if (vnc) {
- kbd__init(kvm);
if (fb)
vnc__init(fb);
}
if (sdl) {
- kbd__init(kvm);
if (fb)
sdl__init(fb);
}
--
1.7.5.3
next reply other threads:[~2011-06-17 13:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-17 13:13 Sasha Levin [this message]
2011-06-17 13:50 ` [PATCH] kvm tools: Implement keyboard reset method Pekka Enberg
2011-06-17 14:17 ` Sasha Levin
2011-06-17 19:16 ` Pekka Enberg
2011-06-17 19:26 ` Pekka Enberg
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=1308316409-9825-1-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 \
--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