1 #include <kvm/util.h> 2 #include <kvm/kvm-cmd.h> 3 #include <kvm/builtin-debug.h> 4 #include <kvm/kvm.h> 5 #include <kvm/parse-options.h> 6 7 #include <stdio.h> 8 #include <string.h> 9 #include <signal.h> 10 11 static const char * const debug_usage[] = { 12 "kvm debug <instance name>", 13 NULL 14 }; 15 16 static const struct option debug_options[] = { 17 OPT_END() 18 }; 19 20 static int do_debug(const char *name, int pid) 21 { 22 return kill(pid, SIGQUIT); 23 } 24 25 int kvm_cmd_debug(int argc, const char **argv, const char *prefix) 26 { 27 int pid; 28 29 if (argc != 1) 30 usage_with_options(debug_usage, debug_options); 31 32 if (strcmp(argv[0], "all") == 0) { 33 return kvm__enumerate_instances(do_debug); 34 } 35 36 pid = kvm__get_pid_by_instance(argv[0]); 37 if (pid < 0) 38 die("Failed locating instance name"); 39 40 return kill(pid, SIGQUIT); 41 } 42