Skip to contentSkip to conversation

kvm tools: Add 'kvm pause' command

PATCH New Sasha Levin 1 participant 1 message Jun 3, 2011 KVM

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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.

---
 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(+), 0 deletions(-)
 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
tools/kvm/Documentation/kvm-pause.txt new file +15 -0
new file mode 100644
index 0000000..ddf3d8f
@@ -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.
tools/kvm/Makefile +1 -0
index a05a6b1..ed82cdf 100644
@@ -42,6 +42,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
tools/kvm/command-list.txt +1 -0
index 4eaf399..36dcd67b 100644
@@ -3,3 +3,4 @@
 # command name			category [deprecated] [common]
 #
 kvm-run				mainporcelain common
+kvm-pause			common
tools/kvm/include/kvm/kvm-pause.h new file +6 -0
new file mode 100644
index 0000000..0f8e96b
@@ -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
tools/kvm/kvm-cmd.c +2 -0
index 2ea51a5..ffbc4ff 100644
@@ -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 },
tools/kvm/kvm-pause.c new file +13 -0
new file mode 100644
index 0000000..fdf8714
@@ -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)");
+}
Signature · 1 line
1.7.5.3