2 #include <kvm/kvm-cmd.h>
3 #include <kvm/builtin-list.h>
5 #include <kvm/parse-options.h>
12 #define PROCESS_NAME "kvm"
14 static const char * const list_usage
[] = {
19 static const struct option list_options
[] = {
23 void kvm_list_help(void)
25 usage_with_options(list_usage
, list_options
);
28 static int print_guest(const char *name
, int pid
)
30 char proc_name
[PATH_MAX
];
34 sprintf(proc_name
, "/proc/%d/stat", pid
);
35 fd
= fopen(proc_name
, "r");
38 if (fscanf(fd
, "%*u (%as)", &comm
) == 0)
40 if (strncmp(comm
, PROCESS_NAME
, strlen(PROCESS_NAME
)))
43 printf("%5d %s\n", pid
, name
);
57 kvm__remove_pidfile(name
);
61 int kvm_cmd_list(int argc
, const char **argv
, const char *prefix
)
63 printf(" PID GUEST\n");
65 return kvm__enumerate_instances(print_guest
);