On Wed, Aug 10, 2011 at 08:02:01AM +0300, Pekka Enberg wrote: >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? Yes. Because I'm using ubuntu and if I don't use sudo to execute "kvm pause", pause command can't work and doesn't prompt anything. BTW, do you always login as "root" user? walimis > >> --- >> 爐ools/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" >> >> 爏truct cmd_struct kvm_commands[] = { >> ? ? ? 爗 "pause", ? ? 爇vm_cmd_pause, ? ? ? ? 燦ULL, ? ? ? ? 0 }, >> @@ -59,6 +60,7 @@ int handle_command(struct cmd_struct *command, int argc, const char **argv) >> 爗 >> ? ? ? 爏truct cmd_struct *p; >> ? ? ? 燾onst char *prefix = NULL; >> + ? ? ? int ret = 0; >> >> ? ? ? 爄f (!argv || !*argv) { >> ? ? ? ? ? ? ? 爌 = kvm_get_command(command, "help"); >> @@ -74,5 +76,12 @@ int handle_command(struct cmd_struct *command, int argc, const char **argv) >> ? ? ? ? ? ? ? 爎eturn 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 爃ttp://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