@@ -3,7 +3,7 @@ kvm-pause(1)
NAME
----
-kvm-pause - Pause/resume the virtual machine
+kvm-pause - Pause the virtual machine
SYNOPSIS
--------
@@ -12,5 +12,5 @@ SYNOPSIS
DESCRIPTION
-----------
-The command pauses and resumes a virtual machine.
+The command pauses a virtual machine.
For a list of running instances see 'kvm list'.
new file mode 100644
@@ -0,0 +1,16 @@
+kvm-resume(1)
+================
+
+NAME
+----
+kvm-resume - Resume the virtual machine
+
+SYNOPSIS
+--------
+[verse]
+'kvm resume [instance]'
+
+DESCRIPTION
+-----------
+The command resumes a virtual machine.
+For a list of running instances see 'kvm list'.
@@ -25,6 +25,7 @@ OBJS += builtin-debug.o
OBJS += builtin-help.o
OBJS += builtin-list.o
OBJS += builtin-pause.o
+OBJS += builtin-resume.o
OBJS += builtin-run.o
OBJS += builtin-version.o
OBJS += cpuid.o
@@ -17,7 +17,7 @@ int kvm_cmd_pause(int argc, const char **argv, const char *prefix)
int pid;
if (argc != 1)
- die("Usage: kvm debug [instance name]\n");
+ die("Usage: kvm pause [instance name]\n");
if (strcmp(argv[0], "all") == 0) {
kvm__enumerate_instances(do_pause);
new file mode 100644
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+
+#include <kvm/util.h>
+#include <kvm/kvm-cmd.h>
+#include <kvm/builtin-resume.h>
+#include <kvm/kvm.h>
+
+static void do_resume(const char *name, int pid)
+{
+ kill(pid, SIGKVMRESUME);
+}
+
+int kvm_cmd_resume(int argc, const char **argv, const char *prefix)
+{
+ int pid;
+
+ if (argc != 1)
+ die("Usage: kvm resume [instance name]\n");
+
+ if (strcmp(argv[0], "all") == 0) {
+ kvm__enumerate_instances(do_resume);
+ return 0;
+ }
+
+ pid = kvm__get_pid_by_instance(argv[0]);
+ if (pid < 0)
+ die("Failed locating instance name");
+
+ return kill(pid, SIGKVMRESUME);
+}
@@ -222,10 +222,12 @@ static int is_paused;
static void handle_sigusr2(int sig)
{
- if (is_paused)
+ if (sig == SIGKVMRESUME && is_paused)
kvm__continue();
- else
+ else if (sig == SIGUSR2 && !is_paused)
kvm__pause();
+ else
+ return;
is_paused = !is_paused;
pr_info("Guest %s\n", is_paused ? "paused" : "resumed");
@@ -489,6 +491,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
signal(SIGQUIT, handle_sigquit);
signal(SIGUSR1, handle_sigusr1);
signal(SIGUSR2, handle_sigusr2);
+ signal(SIGKVMRESUME, handle_sigusr2);
nr_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
@@ -4,6 +4,7 @@
#
kvm-run mainporcelain common
kvm-pause common
+kvm-resume common
kvm-version common
kvm-list common
kvm-debug common
new file mode 100644
@@ -0,0 +1,6 @@
+#ifndef KVM__RESUME_H
+#define KVM__RESUME_H
+
+int kvm_cmd_resume(int argc, const char **argv, const char *prefix);
+
+#endif
@@ -20,6 +20,7 @@
#define SIGKVMPAUSE (SIGRTMIN + 1)
#define SIGKVMADDMEM (SIGRTMIN + 2)
#define SIGKVMDELMEM (SIGRTMIN + 3)
+#define SIGKVMRESUME (SIGRTMIN + 5)
struct kvm {
int sys_fd; /* For system ioctls(), i.e. /dev/kvm */
@@ -7,6 +7,7 @@
/* user defined header files */
#include "kvm/builtin-debug.h"
#include "kvm/builtin-pause.h"
+#include "kvm/builtin-resume.h"
#include "kvm/builtin-balloon.h"
#include "kvm/builtin-list.h"
#include "kvm/builtin-version.h"
@@ -16,6 +17,7 @@
struct cmd_struct kvm_commands[] = {
{ "pause", kvm_cmd_pause, NULL, 0 },
+ { "resume", kvm_cmd_resume, NULL, 0 },
{ "debug", kvm_cmd_debug, NULL, 0 },
{ "balloon", kvm_cmd_balloon, NULL, 0 },
{ "list", kvm_cmd_list, NULL, 0 },
This patch seperates 'kvm pause' into 'kvm pause' and 'kvm resume', 'kvm pause' no longer acts as a switch between running and paused state but instead just switches the instance into paused and reume is handled by the new 'kvm resume'. Signed-off-by: Sasha Levin <levinsasha928@gmail.com> --- tools/kvm/Documentation/kvm-pause.txt | 4 ++-- tools/kvm/Documentation/kvm-resume.txt | 16 ++++++++++++++++ tools/kvm/Makefile | 1 + tools/kvm/builtin-pause.c | 2 +- tools/kvm/builtin-resume.c | 32 ++++++++++++++++++++++++++++++++ tools/kvm/builtin-run.c | 7 +++++-- tools/kvm/command-list.txt | 1 + tools/kvm/include/kvm/builtin-resume.h | 6 ++++++ tools/kvm/include/kvm/kvm.h | 1 + tools/kvm/kvm-cmd.c | 2 ++ 10 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 tools/kvm/Documentation/kvm-resume.txt create mode 100644 tools/kvm/builtin-resume.c create mode 100644 tools/kvm/include/kvm/builtin-resume.h