[tip:tools/kvm] kvm tools: carefully send and handle stop ipc

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

 



Commit-ID:  170fc0b51be8e428500ca692311d747ac693a5ff
Gitweb:     http://git.kernel.org/tip/170fc0b51be8e428500ca692311d747ac693a5ff
Author:     Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
AuthorDate: Tue, 20 Dec 2011 17:08:53 +0800
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Wed, 21 Dec 2011 22:28:09 +0200

kvm tools: carefully send and handle stop ipc

Remove struct stop_cmd and use kvm_ipc__send().

Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/builtin-run.c  |    3 +++
 tools/kvm/builtin-stop.c |   14 +-------------
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 01ff894..2b45d29 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -567,6 +567,9 @@ static void handle_sigalrm(int sig)
 
 static void handle_stop(int fd, u32 type, u32 len, u8 *msg)
 {
+	if (WARN_ON(type != KVM_IPC_STOP || len))
+		return;
+
 	kvm_cpu__reboot();
 }
 
diff --git a/tools/kvm/builtin-stop.c b/tools/kvm/builtin-stop.c
index 7d29eac..6067630 100644
--- a/tools/kvm/builtin-stop.c
+++ b/tools/kvm/builtin-stop.c
@@ -9,11 +9,6 @@
 #include <string.h>
 #include <signal.h>
 
-struct stop_cmd {
-	u32 type;
-	u32 len;
-};
-
 static bool all;
 static const char *instance_name;
 
@@ -46,14 +41,7 @@ void kvm_stop_help(void)
 
 static int do_stop(const char *name, int sock)
 {
-	struct stop_cmd cmd = {KVM_IPC_STOP, 0};
-	int r;
-
-	r = write(sock, &cmd, sizeof(cmd));
-	if (r < 0)
-		return r;
-
-	return 0;
+	return kvm_ipc__send(sock, KVM_IPC_STOP);
 }
 
 int kvm_cmd_stop(int argc, const char **argv, const char *prefix)
--
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