[tip:tools/kvm] kvm tools: handle failure of command

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

 



Commit-ID:  4df0a81d8a36ce16de79c29512f544b8743ab6a6
Gitweb:     http://git.kernel.org/tip/4df0a81d8a36ce16de79c29512f544b8743ab6a6
Author:     Liming Wang <walimisdev@xxxxxxxxx>
AuthorDate: Wed, 10 Aug 2011 10:44:09 +0800
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Wed, 10 Aug 2011 07:58:31 +0300

kvm tools: handle failure of command

handle failure of calling command function, especially, only handle
EPERM error now.

Signed-off-by: Liming Wang <walimisdev@xxxxxxxxx>
[ penberg@xxxxxxxxxx: fix minor coding style issue ]
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/kvm-cmd.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/tools/kvm/kvm-cmd.c b/tools/kvm/kvm-cmd.c
index 63a2dbf..e85f22f 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,11 @@ 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;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux