diff --git a/builtin-run.c b/builtin-run.c index 01ff894..2b45d29 100644 --- a/builtin-run.c +++ b/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/builtin-stop.c b/builtin-stop.c index 7d29eac..6067630 100644 --- a/builtin-stop.c +++ b/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)