From patchwork Sun Feb 5 10:46:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 139623 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 204FDB7247 for ; Sun, 5 Feb 2012 21:47:41 +1100 (EST) Received: from localhost ([::1]:52783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rtzd9-0007bz-6K for incoming@patchwork.ozlabs.org; Sun, 05 Feb 2012 05:47:35 -0500 Received: from eggs.gnu.org ([140.186.70.92]:38048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rtzcs-0007Jo-AP for qemu-devel@nongnu.org; Sun, 05 Feb 2012 05:47:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rtzcd-0006Qh-EQ for qemu-devel@nongnu.org; Sun, 05 Feb 2012 05:47:18 -0500 Received: from fmmailgate01.web.de ([217.72.192.221]:42515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rtzcd-0006QQ-46 for qemu-devel@nongnu.org; Sun, 05 Feb 2012 05:47:03 -0500 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate01.web.de (Postfix) with ESMTP id 0A5901A9DE4FE for ; Sun, 5 Feb 2012 11:46:38 +0100 (CET) Received: from localhost.localdomain ([95.157.56.37]) by smtp.web.de (mrweb001) with ESMTPA (Nemesis) id 0MMFFF-1RvL3x1Yq5-007i7W; Sun, 05 Feb 2012 11:46:36 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Sun, 5 Feb 2012 11:46:28 +0100 Message-Id: <77a9fa5aa9aae73889803315c291418a4d99505a.1328438750.git.jan.kiszka@web.de> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-Provags-ID: V02:K0:fjEtNTj7lptQiDKF/CUJgE9DUHCkHTlqQzx8YxPd2wK y2SYCu2Ju+q5I77e1jEmQsJMvGBlMpdSxVavePcSp+30yLriTf 5bq+nidLMfpg5F5xoML07ezKnVkIAlwsWfPBfgfjyNZJBuIa5w JHjojLmpZtQI0NPLdevuSPx7+9uB1epAJ2f0RJto+nIxaM/XxT qMTNgkVDVKoIjjxdAflCQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.221 Cc: Anthony Liguori , qemu-devel , kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 2/4] i8254: Open-code timer restore 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 From: Jan Kiszka Same as for the APIC: To enable migration between accelerated and non-accelerated models, we need to arm the channel 0 timer only inside the emulated PIT model. The common code just saves/restores that timer to the the next_transition_time field. Signed-off-by: Jan Kiszka --- hw/i8254.c | 12 ++++++++++++ hw/i8254_common.c | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hw/i8254.c b/hw/i8254.c index f9f58e0..d41ee05 100644 --- a/hw/i8254.c +++ b/hw/i8254.c @@ -300,6 +300,17 @@ static const MemoryRegionOps pit_ioport_ops = { .old_portio = pit_portio }; +static void pit_post_load(PITCommonState *s) +{ + PITChannelState *sc = &s->channels[0]; + + if (sc->next_transition_time != -1) { + qemu_mod_timer(sc->irq_timer, sc->next_transition_time); + } else { + qemu_del_timer(sc->irq_timer); + } +} + static int pit_initfn(PITCommonState *pit) { PITChannelState *s; @@ -329,6 +340,7 @@ static void pit_class_initfn(ObjectClass *klass, void *data) k->init = pit_initfn; k->set_channel_gate = pit_set_channel_gate; k->get_channel_info = pit_get_channel_info_common; + k->post_load = pit_post_load; dc->reset = pit_reset; dc->props = pit_properties; } diff --git a/hw/i8254_common.c b/hw/i8254_common.c index 0601d88..b60fbda 100644 --- a/hw/i8254_common.c +++ b/hw/i8254_common.c @@ -234,9 +234,8 @@ static int pit_load_old(QEMUFile *f, void *opaque, int version_id) qemu_get_8s(f, &s->gate); s->count_load_time = qemu_get_be64(f); s->irq_disabled = 0; - if (s->irq_timer) { + if (i == 0) { s->next_transition_time = qemu_get_be64(f); - qemu_get_timer(f, s->irq_timer); } } return 0; @@ -275,7 +274,8 @@ static const VMStateDescription vmstate_pit_common = { VMSTATE_UINT32_V(channels[0].irq_disabled, PITCommonState, 3), VMSTATE_STRUCT_ARRAY(channels, PITCommonState, 3, 2, vmstate_pit_channel, PITChannelState), - VMSTATE_TIMER(channels[0].irq_timer, PITCommonState), + VMSTATE_INT64(channels[0].next_transition_time, + PITCommonState), /* formerly irq_timer */ VMSTATE_END_OF_LIST() } };