From patchwork Thu Dec 5 00:51:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liguang X-Patchwork-Id: 296679 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 433B32C00A4 for ; Thu, 5 Dec 2013 11:55:20 +1100 (EST) Received: from localhost ([::1]:51120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoNDp-0002Iy-Sp for incoming@patchwork.ozlabs.org; Wed, 04 Dec 2013 19:55:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoND9-0002HM-Af for qemu-devel@nongnu.org; Wed, 04 Dec 2013 19:54:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VoND4-0002cO-Nw for qemu-devel@nongnu.org; Wed, 04 Dec 2013 19:54:35 -0500 Received: from [222.73.24.84] (port=12459 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoND4-0002cC-BL for qemu-devel@nongnu.org; Wed, 04 Dec 2013 19:54:30 -0500 X-IronPort-AV: E=Sophos;i="4.93,829,1378828800"; d="scan'208";a="9193619" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 05 Dec 2013 08:50:57 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id rB50sOAT020160; Thu, 5 Dec 2013 08:54:25 +0800 Received: from liguang.fnst.cn.fujitsu.com ([10.167.226.141]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013120508541643-147123 ; Thu, 5 Dec 2013 08:54:16 +0800 From: liguang To: qemu-devel@nongnu.org Date: Thu, 5 Dec 2013 08:51:35 +0800 Message-Id: <1386204699-15162-2-git-send-email-lig.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1386204699-15162-1-git-send-email-lig.fnst@cn.fujitsu.com> References: <1386204699-15162-1-git-send-email-lig.fnst@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/12/05 08:54:16, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/12/05 08:54:18, Serialize complete at 2013/12/05 08:54:18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: Peter Maydell , Peter Crosthwaite , =?UTF-8?q?Andreas=20F=C3=A4rber?= , liguang Subject: [Qemu-devel] [PATCH v9 1/5] vmstate: add VMSTATE_PTIMER_ARRAY 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 Signed-off-by: liguang --- include/migration/vmstate.h | 4 ++++ savevm.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 0 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 9d09e60..977cf52 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -165,6 +165,7 @@ extern const VMStateInfo vmstate_info_timer; extern const VMStateInfo vmstate_info_buffer; extern const VMStateInfo vmstate_info_unused_buffer; extern const VMStateInfo vmstate_info_bitmap; +extern const VMStateInfo vmstate_info_ptimer; #define type_check_2darray(t1,t2,n,m) ((t1(*)[n][m])0 - (t2*)0) #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0) @@ -613,6 +614,9 @@ extern const VMStateInfo vmstate_info_bitmap; #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \ VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *) +#define VMSTATE_PTIMER_ARRAY(_f, _s, _n) \ + VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_ptimer, ptimer_state *) + #define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool) diff --git a/savevm.c b/savevm.c index 2f631d4..54dbb33 100644 --- a/savevm.c +++ b/savevm.c @@ -30,6 +30,7 @@ #include "monitor/monitor.h" #include "sysemu/sysemu.h" #include "qemu/timer.h" +#include "hw/ptimer.h" #include "audio/audio.h" #include "migration/migration.h" #include "qemu/sockets.h" @@ -1362,6 +1363,36 @@ const VMStateInfo vmstate_info_timer = { .put = put_timer, }; +static int get_ptimer(QEMUFile *f, void *pv, size_t size) +{ + ptimer_state *v = pv; + uint64_t count; + + count = qemu_get_be64(f); + if (count != -1) { + ptimer_set_count(v, count); + } else { + ptimer_stop(v); + } + + return 0; +} + +static void put_ptimer(QEMUFile *f, void *pv, size_t size) +{ + ptimer_state *v = pv; + uint64_t count; + + count = ptimer_get_count(v); + qemu_put_be64(f, count); +} + +const VMStateInfo vmstate_info_ptimer = { + .name = "ptimer", + .get = get_ptimer, + .put = put_ptimer, +}; + /* uint8_t buffers */ static int get_buffer(QEMUFile *f, void *pv, size_t size)