The discovered bit in PGCCSR register indicates if the device has been
[linux-2.6/next.git] / tools / kvm / builtin-resume.c
blob70de0fc26e1c4c4e8bd47fec71e2e480eebcd7d5
1 #include <kvm/util.h>
2 #include <kvm/kvm-cmd.h>
3 #include <kvm/builtin-resume.h>
4 #include <kvm/kvm.h>
5 #include <kvm/parse-options.h>
7 #include <stdio.h>
8 #include <string.h>
9 #include <signal.h>
11 static bool all;
12 static pid_t instance_pid;
13 static const char *instance_name;
15 static const char * const resume_usage[] = {
16 "kvm resume [--all] [-n name] [-p pid]",
17 NULL
20 static const struct option resume_options[] = {
21 OPT_GROUP("General options:"),
22 OPT_BOOLEAN('a', "all", &all, "Resume all instances"),
23 OPT_STRING('n', "name", &instance_name, "name", "Instance name"),
24 OPT_INTEGER('p', "pid", &instance_pid, "Instance pid"),
25 OPT_END()
28 static void parse_resume_options(int argc, const char **argv)
30 while (argc != 0) {
31 argc = parse_options(argc, argv, resume_options, resume_usage,
32 PARSE_OPT_STOP_AT_NON_OPTION);
33 if (argc != 0)
34 kvm_resume_help();
38 void kvm_resume_help(void)
40 usage_with_options(resume_usage, resume_options);
43 static int do_resume(const char *name, int pid)
45 return kill(pid, SIGKVMRESUME);
48 int kvm_cmd_resume(int argc, const char **argv, const char *prefix)
50 parse_resume_options(argc, argv);
52 if (all)
53 return kvm__enumerate_instances(do_resume);
55 if (instance_name == NULL &&
56 instance_pid == 0)
57 kvm_resume_help();
59 if (instance_name)
60 instance_pid = kvm__get_pid_by_instance(instance_name);
62 if (instance_pid <= 0)
63 die("Failed locating instance");
65 return kill(instance_pid, SIGKVMRESUME);