From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFS9K-0004Vj-4q for qemu-devel@nongnu.org; Thu, 28 Apr 2011 10:24:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QFS9J-0006vk-8x for qemu-devel@nongnu.org; Thu, 28 Apr 2011 10:24:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26385) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFS9I-0006vd-T4 for qemu-devel@nongnu.org; Thu, 28 Apr 2011 10:24:57 -0400 From: Ulrich Obergfell Date: Thu, 28 Apr 2011 16:24:58 +0200 Message-Id: <1304000700-3640-4-git-send-email-uobergfe@redhat.com> In-Reply-To: <1304000700-3640-1-git-send-email-uobergfe@redhat.com> References: <1304000700-3640-1-git-send-email-uobergfe@redhat.com> Subject: [Qemu-devel] [PATCH v3 3/5] hpet 'driftfix': add fields to HPETTimer and VMStateDescription List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, kvm@vger.kernel.org, jan.kiszka@siemens.com, uobergfe@redhat.com, gcosta@redhat.com, avi@redhat.com 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 */ + } } }; -- 1.6.2.5