From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZADk4-0007Hi-Gi for qemu-devel@nongnu.org; Wed, 01 Jul 2015 04:51:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZADk2-0007ow-Ip for qemu-devel@nongnu.org; Wed, 01 Jul 2015 04:51:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47748) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZADk2-0007oj-Eq for qemu-devel@nongnu.org; Wed, 01 Jul 2015 04:51:38 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 10D2F359970 for ; Wed, 1 Jul 2015 08:51:38 +0000 (UTC) From: Juan Quintela Date: Wed, 1 Jul 2015 10:51:22 +0200 Message-Id: <1435740693-10839-2-git-send-email-quintela@redhat.com> In-Reply-To: <1435740693-10839-1-git-send-email-quintela@redhat.com> References: <1435740693-10839-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PATCH 01/12] runstate: Add runstate store List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, dgilbert@redhat.com This allows us to store the current state to send it through migration. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- include/sysemu/sysemu.h | 1 + vl.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index df80951..44570d1 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -28,6 +28,7 @@ bool runstate_check(RunState state); void runstate_set(RunState new_state); int runstate_is_running(void); bool runstate_needs_reset(void); +bool runstate_store(char *str, size_t size); typedef struct vm_change_state_entry VMChangeStateEntry; typedef void VMChangeStateHandler(void *opaque, int running, RunState state); diff --git a/vl.c b/vl.c index 69ad90c..fec7e93 100644 --- a/vl.c +++ b/vl.c @@ -634,6 +634,18 @@ bool runstate_check(RunState state) return current_run_state == state; } +bool runstate_store(char *str, size_t size) +{ + const char *state = RunState_lookup[current_run_state]; + size_t len = strlen(state) + 1; + + if (len > size) { + return false; + } + memcpy(str, state, len); + return true; +} + static void runstate_init(void) { const RunStateTransition *p; -- 2.4.3