2 #include <kvm/kvm-cmd.h>
3 #include <kvm/builtin-resume.h>
4 #include <kvm/builtin-list.h>
6 #include <kvm/parse-options.h>
7 #include <kvm/kvm-ipc.h>
14 static const char *instance_name;
16 static const char * const resume_usage[] = {
17 "lkvm resume [--all] [-n name]",
21 static const struct option resume_options[] = {
22 OPT_GROUP("General options:"),
23 OPT_BOOLEAN('a', "all", &all, "Resume all instances"),
24 OPT_STRING('n', "name", &instance_name, "name", "Instance name"),
28 static void parse_resume_options(int argc, const char **argv)
31 argc = parse_options(argc, argv, resume_options, resume_usage,
32 PARSE_OPT_STOP_AT_NON_OPTION);
38 void kvm_resume_help(void)
40 usage_with_options(resume_usage, resume_options);
43 static int do_resume(const char *name, int sock)
48 vmstate = get_vmstate(sock);
51 if (vmstate == KVM_VMSTATE_RUNNING) {
52 printf("Guest %s is still running.\n", name);
56 r = kvm_ipc__send(sock, KVM_IPC_RESUME);
60 printf("Guest %s resumed\n", name);
65 int kvm_cmd_resume(int argc, const char **argv, const char *prefix)
70 parse_resume_options(argc, argv);
73 return kvm__enumerate_instances(do_resume);
75 if (instance_name == NULL)
78 instance = kvm__get_sock_by_instance(instance_name);
81 die("Failed locating instance");
83 r = do_resume(instance_name, instance);