From 170fc0b51be8e428500ca692311d747ac693a5ff Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Tue, 20 Dec 2011 17:08:53 +0800 Subject: [PATCH] kvm tools: carefully send and handle stop ipc Remove struct stop_cmd and use kvm_ipc__send(). Signed-off-by: Lai Jiangshan Signed-off-by: Pekka Enberg --- 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 01ff894ea0aa..2b45d29a6197 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 7d29eacfe2bf..6067630568df 100644 --- a/tools/kvm/builtin-stop.c +++ b/tools/kvm/builtin-stop.c @@ -9,11 +9,6 @@ #include #include -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) -- 2.39.5