From patchwork Mon May 9 07:03:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Obergfell X-Patchwork-Id: 768392 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4973Rf0015808 for ; Mon, 9 May 2011 07:03:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752659Ab1EIHDY (ORCPT ); Mon, 9 May 2011 03:03:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12236 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752422Ab1EIHDY (ORCPT ); Mon, 9 May 2011 03:03:24 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4973C0O009059 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 9 May 2011 03:03:15 -0400 Received: from localhost.localdomain (vpn2-9-235.ams2.redhat.com [10.36.9.235]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p49732Hk030518; Mon, 9 May 2011 03:03:10 -0400 From: Ulrich Obergfell To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, uobergfe@redhat.com, gcosta@redhat.com, avi@redhat.com, mtosatti@redhat.com, aliguori@us.ibm.com, jan.kiszka@siemens.com Subject: [PATCH v4 3/5] hpet 'driftfix': add fields to HPETTimer and VMStateDescription Date: Mon, 9 May 2011 09:03:19 +0200 Message-Id: <1304924601-3848-4-git-send-email-uobergfe@redhat.com> In-Reply-To: <1304924601-3848-1-git-send-email-uobergfe@redhat.com> References: <1304924601-3848-1-git-send-email-uobergfe@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 09 May 2011 07:03:28 +0000 (UTC) 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 | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/hw/hpet.c b/hw/hpet.c index 7513065..7ab6e62 100644 --- a/hw/hpet.c +++ b/hw/hpet.c @@ -55,6 +55,10 @@ 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. */ + uint64_t prev_period; + uint64_t ticks_not_accounted; + uint32_t irq_rate; + uint32_t divisor; } HPETTimer; typedef struct HPETState { @@ -246,6 +250,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 +285,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 */ + } } };