]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Improve "kvm setup" info and error messages
authorPekka Enberg <penberg@kernel.org>
Tue, 25 Oct 2011 11:59:55 +0000 (14:59 +0300)
committerPekka Enberg <penberg@kernel.org>
Tue, 25 Oct 2011 13:22:11 +0000 (16:22 +0300)
This patch improves the output of 'kvm setup' as follows:

  [penberg@tux kvm]$ ./kvm setup

  kvm setup creates a new rootfs under /home/penberg//.kvm-tools/.
  This can be used later by the '-d' parameter of 'kvm run'.

   usage: kvm setup [name]

  [penberg@tux kvm]$ ./kvm setup test-box
  A new rootfs 'test-box' has been created in '/home/penberg//.kvm-tools/test-box'.

  You can now start it by running the following command:

    kvm run -d test-box

  [penberg@tux kvm]$ ./kvm setup test-box
  Unable to create rootfs in /home/penberg//.kvm-tools/test-box: File exists

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>
tools/kvm/builtin-setup.c

index dce1748f2ef4169025237b1f879e4613817c332a..7deb0ed7c4ebbb1ab9098cfa697293357333b84c 100644 (file)
@@ -46,8 +46,9 @@ static void parse_setup_options(int argc, const char **argv)
 
 void kvm_setup_help(void)
 {
-       printf("\nkvm setup creates a new rootfs and stores it under ~/.kvm-tools/ .\n"
-               "This can be used later by the '-d' parameter of 'kvm run'.\n");
+       printf("\nkvm setup creates a new rootfs under %s.\n"
+               "This can be used later by the '-d' parameter of 'kvm run'.\n",
+               kvm__get_dir());
        usage_with_options(setup_usage, setup_options);
 }
 
@@ -215,11 +216,13 @@ int kvm_cmd_setup(int argc, const char **argv, const char *prefix)
 
        r = do_setup(instance_name);
        if (r == 0)
-               pr_info("Your new rootfs named %s has been created.\n"
-                       "You can now start it by running 'kvm run -d %s'\n",
-                       instance_name, instance_name);
+               printf("A new rootfs '%s' has been created in '%s%s'.\n\n"
+                       "You can now start it by running the following command:\n\n"
+                       "  kvm run -d %s\n",
+                       instance_name, kvm__get_dir(), instance_name, instance_name);
        else
-               perror("Error creating rootfs");
+               printf("Unable to create rootfs in %s%s: %s\n",
+                       kvm__get_dir(), instance_name, strerror(errno));
 
        return r;
 }