]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: carefully send and handle stop ipc
authorLai Jiangshan <laijs@cn.fujitsu.com>
Tue, 20 Dec 2011 09:08:53 +0000 (17:08 +0800)
committerPekka Enberg <penberg@kernel.org>
Wed, 21 Dec 2011 20:28:09 +0000 (22:28 +0200)
Remove struct stop_cmd and use kvm_ipc__send().

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/builtin-run.c
tools/kvm/builtin-stop.c

index 01ff894ea0aaee95e7fa1eac91b61bafefa80837..2b45d29a6197746b69c5da097b07573906e74792 100644 (file)
@@ -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();
 }
 
index 7d29eacfe2bf6bc32f1d5887b6470bf65a47bcfb..6067630568dfcf98e13f32731d14c9396f60a14f 100644 (file)
@@ -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)