From patchwork Wed Jul 1 08:51:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 489959 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 05A231402CC for ; Wed, 1 Jul 2015 18:52:21 +1000 (AEST) Received: from localhost ([::1]:50324 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZADkh-0008IP-8M for incoming@patchwork.ozlabs.org; Wed, 01 Jul 2015 04:52:19 -0400 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) Received: from trasno.mitica (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t618pYWA016344; Wed, 1 Jul 2015 04:51:36 -0400 From: Juan Quintela To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: amit.shah@redhat.com, dgilbert@redhat.com Subject: [Qemu-devel] [PATCH 01/12] runstate: Add runstate store X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;