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 void kvm_debug_help(void) 21 { 22 usage_with_options(debug_usage, debug_options); 23 } 24 25 static int do_debug(const char *name, int pid) 26 { 27 return kill(pid, SIGQUIT); 28 } 29 30 int kvm_cmd_debug(int argc, const char **argv, const char *prefix) 31 { 32 int pid; 33 34 if (argc != 1) 35 kvm_debug_help(); 36 37 if (strcmp(argv[0], "all") == 0) { 38 return kvm__enumerate_instances(do_debug); 39 } 40 41 pid = kvm__get_pid_by_instance(argv[0]); 42 if (pid < 0) 43 die("Failed locating instance name"); 44 45 return kill(pid, SIGQUIT); 46 } 47