xref: /kvmtool/builtin-pause.c (revision 24e7dbbaf22da7de18276423e09a077bdf3a299d)
1 #include <stdio.h>
2 #include <string.h>
3 #include <signal.h>
4 
5 #include <kvm/util.h>
6 #include <kvm/kvm-cmd.h>
7 #include <kvm/kvm-pause.h>
8 #include <kvm/kvm.h>
9 
10 static void do_pause(const char *name, int pid)
11 {
12 	kill(pid, SIGUSR2);
13 }
14 
15 int kvm_cmd_pause(int argc, const char **argv, const char *prefix)
16 {
17 	int pid;
18 
19 	if (argc != 1)
20 		die("Usage: kvm debug [instance name]\n");
21 
22 	if (strcmp(argv[0], "all") == 0) {
23 		kvm__enumerate_instances(do_pause);
24 		return 0;
25 	}
26 
27 	pid = kvm__get_pid_by_instance(argv[0]);
28 	if (pid < 0)
29 		die("Failed locating instance name");
30 
31 	return kill(pid, SIGUSR2);
32 }
33