Re: [PATCH 2/2] kvm tools: handle failure of command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 10, 2011 at 5:44 AM, Liming Wang <walimisdev@xxxxxxxxx> wrote:
> handle failure of calling command function, especially, only handle
> EPERM error now.
>
> Signed-off-by: Liming Wang <walimisdev@xxxxxxxxx>

I applied the patch because I absolutely loved the error handling
cleanups from the previous patch. However, out of curiosity, are you
seeing EPERM with some command in particular?

> ---
>  tools/kvm/kvm-cmd.c |   11 ++++++++++-
>  1 files changed, 10 insertions(+), 1 deletions(-)
>
> diff --git a/tools/kvm/kvm-cmd.c b/tools/kvm/kvm-cmd.c
> index 63a2dbf..6cd4270 100644
> --- a/tools/kvm/kvm-cmd.c
> +++ b/tools/kvm/kvm-cmd.c
> @@ -15,6 +15,7 @@
>  #include "kvm/builtin-help.h"
>  #include "kvm/kvm-cmd.h"
>  #include "kvm/builtin-run.h"
> +#include "kvm/util.h"
>
>  struct cmd_struct kvm_commands[] = {
>        { "pause",      kvm_cmd_pause,          NULL,         0 },
> @@ -59,6 +60,7 @@ int handle_command(struct cmd_struct *command, int argc, const char **argv)
>  {
>        struct cmd_struct *p;
>        const char *prefix = NULL;
> +       int ret = 0;
>
>        if (!argv || !*argv) {
>                p = kvm_get_command(command, "help");
> @@ -74,5 +76,12 @@ int handle_command(struct cmd_struct *command, int argc, const char **argv)
>                return EINVAL;
>        }
>
> -       return p->fn(argc - 1, &argv[1], prefix);
> +       ret = p->fn(argc - 1, &argv[1], prefix);
> +       if (ret < 0)
> +       {
> +               if (errno == EPERM)
> +                       die("Permission error - are you root?");
> +       }
> +
> +       return ret;
>  }
> --
> 1.7.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux