]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Add 'kvm pause' command
authorSasha Levin <levinsasha928@gmail.com>
Fri, 3 Jun 2011 14:22:29 +0000 (17:22 +0300)
committerPekka Enberg <penberg@kernel.org>
Wed, 15 Jun 2011 13:59:37 +0000 (16:59 +0300)
This patch adds a 'kvm debug' command that's currently an alias for

  kill -USR2 `pidof kvm`

Which pauses a guest (freezes all VCPU threads) or resumes a paused
guest.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/Documentation/kvm-pause.txt [new file with mode: 0644]
tools/kvm/Makefile
tools/kvm/command-list.txt
tools/kvm/include/kvm/kvm-pause.h [new file with mode: 0644]
tools/kvm/kvm-cmd.c
tools/kvm/kvm-pause.c [new file with mode: 0644]

diff --git a/tools/kvm/Documentation/kvm-pause.txt b/tools/kvm/Documentation/kvm-pause.txt
new file mode 100644 (file)
index 0000000..ddf3d8f
--- /dev/null
@@ -0,0 +1,15 @@
+kvm-pause(1)
+================
+
+NAME
+----
+kvm-pause - Pause/resume the virtual machine
+
+SYNOPSIS
+--------
+[verse]
+'kvm pause'
+
+DESCRIPTION
+-----------
+The command pauses and resumes a virtual machine.
index 97dce8698e2f7beca0dde4ae3ae95ce254db8b90..d368c2216b0afb3f50739c989bfb975b781088c7 100644 (file)
@@ -48,6 +48,7 @@ OBJS  += irq.o
 OBJS   += kvm-cmd.o
 OBJS   += kvm-debug.o
 OBJS   += kvm-help.o
+OBJS    += kvm-pause.o
 OBJS   += kvm-run.o
 OBJS   += mptable.o
 OBJS   += rbtree.o
index 4eaf3996afd7da1b6f1a973d15409dbc88f2f913..36dcd67bdb7b391bef3e591282d52ae0c3ecd155 100644 (file)
@@ -3,3 +3,4 @@
 # command name                 category [deprecated] [common]
 #
 kvm-run                                mainporcelain common
+kvm-pause                      common
diff --git a/tools/kvm/include/kvm/kvm-pause.h b/tools/kvm/include/kvm/kvm-pause.h
new file mode 100644 (file)
index 0000000..0f8e96b
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef KVM__PAUSE_H
+#define KVM__PAUSE_H
+
+int kvm_cmd_pause(int argc, const char **argv, const char *prefix);
+
+#endif
index 2ea51a57ca5fc6a8db93bae1f52b4db067c8e417..ffbc4ff0dc4f18d20ed5de5d4d017a2b50dc0a62 100644 (file)
@@ -6,11 +6,13 @@
 
 /* user defined header files */
 #include "kvm/kvm-debug.h"
+#include "kvm/kvm-pause.h"
 #include "kvm/kvm-help.h"
 #include "kvm/kvm-cmd.h"
 #include "kvm/kvm-run.h"
 
 struct cmd_struct kvm_commands[] = {
+       { "pause", kvm_cmd_pause, NULL,         0 },
        { "debug", kvm_cmd_debug, NULL,         0 },
        { "help",  kvm_cmd_help,  NULL,         0 },
        { "run",   kvm_cmd_run,   kvm_run_help, 0 },
diff --git a/tools/kvm/kvm-pause.c b/tools/kvm/kvm-pause.c
new file mode 100644 (file)
index 0000000..fdf8714
--- /dev/null
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+
+#include <kvm/util.h>
+#include <kvm/kvm-cmd.h>
+#include <kvm/kvm-pause.h>
+
+int kvm_cmd_pause(int argc, const char **argv, const char *prefix)
+{
+       signal(SIGUSR2, SIG_IGN);
+       return system("kill -USR2 $(pidof kvm)");
+}