kvm tools: Improve "kvm list" default output

This patch changes 'kvm list' default output to look as follows:

  [penberg@tux kvm]$ ./kvm list
    PID GUEST
   8156 guest-8156
        default (not running)
        test-box (not running)

Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Acked-by: Sasha Levin <levinsasha928@gmail.com>
Cc: Asias He <asias.hejun@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
Pekka Enberg
2011-10-25 15:20:09 +03:00
committed by Will Deacon
parent f9ea40eaee
commit 84e1040433
+4 -6
View File
@@ -91,8 +91,6 @@ cleanup:
static int kvm_list_running_instances(void)
{
printf(" PID GUEST\n");
return kvm__enumerate_instances(print_guest);
}
@@ -107,13 +105,11 @@ static int kvm_list_rootfs(void)
if (dir == NULL)
return -1;
printf(" ROOTFS\n");
while ((dirent = readdir(dir))) {
if (dirent->d_type == DT_DIR &&
strcmp(dirent->d_name, ".") &&
strcmp(dirent->d_name, ".."))
printf("%s\n", dirent->d_name);
printf(" %s (not running)\n", dirent->d_name);
}
return 0;
@@ -136,7 +132,9 @@ int kvm_cmd_list(int argc, const char **argv, const char *prefix)
parse_setup_options(argc, argv);
if (!run && !rootfs)
kvm_list_help();
run = rootfs = true;
printf(" PID GUEST\n");
if (run) {
r = kvm_list_running_instances();