From patchwork Fri May 20 07:13:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Obergfell X-Patchwork-Id: 96550 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 07A2AB71D1 for ; Fri, 20 May 2011 17:15:03 +1000 (EST) Received: from localhost ([::1]:58538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNJvI-000503-31 for incoming@patchwork.ozlabs.org; Fri, 20 May 2011 03:15:00 -0400 Received: from eggs.gnu.org ([140.186.70.92]:59026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNJtZ-0001tt-4n for qemu-devel@nongnu.org; Fri, 20 May 2011 03:13:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QNJtY-0005Ql-9G for qemu-devel@nongnu.org; Fri, 20 May 2011 03:13:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18593) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNJtY-0005Qh-1K for qemu-devel@nongnu.org; Fri, 20 May 2011 03:13:12 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4K7DB9C021202 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 20 May 2011 03:13:11 -0400 Received: from localhost.localdomain (vpn1-7-144.ams2.redhat.com [10.36.7.144]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4K7Cxq4003713; Fri, 20 May 2011 03:13:09 -0400 From: Ulrich Obergfell To: qemu-devel@nongnu.org Date: Fri, 20 May 2011 09:13:21 +0200 Message-Id: <1305875603-3104-4-git-send-email-uobergfe@redhat.com> In-Reply-To: <1305875603-3104-1-git-send-email-uobergfe@redhat.com> References: <1305875603-3104-1-git-send-email-uobergfe@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com, mtosatti@redhat.com, kvm@vger.kernel.org, jan.kiszka@siemens.com, zamsden@redhat.com, uobergfe@redhat.com, gcosta@redhat.com, avi@redhat.com Subject: [Qemu-devel] [PATCH v5 3/5] hpet 'driftfix': add fields to HPETTimer and VMStateDescription 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 The new fields in HPETTimer are covered by a separate VMStateDescription which is a subsection of 'vmstate_hpet_timer'. They are only migrated if -global hpet.driftfix=on Signed-off-by: Ulrich Obergfell --- hw/hpet.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 42 insertions(+), 0 deletions(-) diff --git a/hw/hpet.c b/hw/hpet.c index 7513065..dba9370 100644 --- a/hw/hpet.c +++ b/hw/hpet.c @@ -55,6 +55,19 @@ typedef struct HPETTimer { /* timers */ uint8_t wrap_flag; /* timer pop will indicate wrap for one-shot 32-bit * mode. Next pop will be actual timer expiration. */ + /* driftfix state */ + uint64_t prev_period; /* needed when the guest o/s changes the + * comparator value */ + uint64_t ticks_not_accounted; /* ticks for which no interrupts have been + * delivered to the guest o/s yet */ + uint32_t irq_rate; /* rate at which interrupts are delivered + * to the guest o/s during one period + * interval; if rate is greater than 1, + * additional interrupts are delivered + * to compensate missed interrupts */ + uint32_t divisor; /* needed to determine when the next + * timer callback should occur while + * rate is greater than 1 */ } HPETTimer; typedef struct HPETState { @@ -246,6 +259,27 @@ static int hpet_post_load(void *opaque, int version_id) return 0; } +static bool hpet_timer_driftfix_vmstate_needed(void *opaque) +{ + HPETTimer *t = opaque; + + return (t->state->driftfix != 0); +} + +static const VMStateDescription vmstate_hpet_timer_driftfix = { + .name = "hpet_timer_driftfix", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField []) { + VMSTATE_UINT64(prev_period, HPETTimer), + VMSTATE_UINT64(ticks_not_accounted, HPETTimer), + VMSTATE_UINT32(irq_rate, HPETTimer), + VMSTATE_UINT32(divisor, HPETTimer), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_hpet_timer = { .name = "hpet_timer", .version_id = 1, @@ -260,6 +294,14 @@ static const VMStateDescription vmstate_hpet_timer = { VMSTATE_UINT8(wrap_flag, HPETTimer), VMSTATE_TIMER(qemu_timer, HPETTimer), VMSTATE_END_OF_LIST() + }, + .subsections = (VMStateSubsection []) { + { + .vmsd = &vmstate_hpet_timer_driftfix, + .needed = hpet_timer_driftfix_vmstate_needed, + }, { + /* empty */ + } } };