From b4261733cb3ac9747b2839aa6cacd6e572be0842 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Fri, 3 Jun 2011 17:22:29 +0300 Subject: [PATCH] kvm tools: Add 'kvm pause' command 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 Signed-off-by: Pekka Enberg --- tools/kvm/Documentation/kvm-pause.txt | 15 +++++++++++++++ tools/kvm/Makefile | 1 + tools/kvm/command-list.txt | 1 + tools/kvm/include/kvm/kvm-pause.h | 6 ++++++ tools/kvm/kvm-cmd.c | 2 ++ tools/kvm/kvm-pause.c | 13 +++++++++++++ 6 files changed, 38 insertions(+) create mode 100644 tools/kvm/Documentation/kvm-pause.txt create mode 100644 tools/kvm/include/kvm/kvm-pause.h create mode 100644 tools/kvm/kvm-pause.c diff --git a/tools/kvm/Documentation/kvm-pause.txt b/tools/kvm/Documentation/kvm-pause.txt new file mode 100644 index 000000000000..ddf3d8ffec93 --- /dev/null +++ b/tools/kvm/Documentation/kvm-pause.txt @@ -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. diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index 97dce8698e2f..d368c2216b0a 100644 --- a/tools/kvm/Makefile +++ b/tools/kvm/Makefile @@ -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 diff --git a/tools/kvm/command-list.txt b/tools/kvm/command-list.txt index 4eaf3996afd7..36dcd67bdb7b 100644 --- a/tools/kvm/command-list.txt +++ b/tools/kvm/command-list.txt @@ -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 index 000000000000..0f8e96b9e115 --- /dev/null +++ b/tools/kvm/include/kvm/kvm-pause.h @@ -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 diff --git a/tools/kvm/kvm-cmd.c b/tools/kvm/kvm-cmd.c index 2ea51a57ca5f..ffbc4ff0dc4f 100644 --- a/tools/kvm/kvm-cmd.c +++ b/tools/kvm/kvm-cmd.c @@ -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 index 000000000000..fdf871408386 --- /dev/null +++ b/tools/kvm/kvm-pause.c @@ -0,0 +1,13 @@ +#include +#include +#include + +#include +#include +#include + +int kvm_cmd_pause(int argc, const char **argv, const char *prefix) +{ + signal(SIGUSR2, SIG_IGN); + return system("kill -USR2 $(pidof kvm)"); +} -- 2.39.5