From: Lai Jiangshan Date: Tue, 20 Dec 2011 09:08:53 +0000 (+0800) Subject: kvm tools: carefully send and handle stop ipc X-Git-Tag: next-20120402~5^2~87 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=170fc0b51be8e428500ca692311d747ac693a5ff;p=karo-tx-linux.git 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 --- 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)