From patchwork Wed Sep 9 23:12:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 33234 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id F0017B7043 for ; Thu, 10 Sep 2009 09:13:44 +1000 (EST) Received: from localhost ([127.0.0.1]:60567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlWM8-00037b-HH for incoming@patchwork.ozlabs.org; Wed, 09 Sep 2009 19:13:40 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlWLZ-00036L-Dm for qemu-devel@nongnu.org; Wed, 09 Sep 2009 19:13:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlWLT-00035j-UN for qemu-devel@nongnu.org; Wed, 09 Sep 2009 19:13:04 -0400 Received: from [199.232.76.173] (port=42925 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlWLT-00035g-R8 for qemu-devel@nongnu.org; Wed, 09 Sep 2009 19:12:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23095) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlWLT-0007fV-At for qemu-devel@nongnu.org; Wed, 09 Sep 2009 19:12:59 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n89NCwbW002401 for ; Wed, 9 Sep 2009 19:12:58 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n89NCuwP022156; Wed, 9 Sep 2009 19:12:57 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2009 01:12:54 +0200 Message-Id: <1252537974-26209-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [RFC PATCH v2 1/4] mc145818rtc: fix saving of rtc-td hack properly upgrading the version number X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hi v2: Only call rtc_coalesced_timer_update() if rtc_td_hack is true. Patch was failing to load its own images. v1: There hasn't still released a version with the rtc_td hack. Do we want to release 0.11 with this hack or change to a more maintenable mode, i.e. just upgrade the version to 3 and save always the new values. We should also propably add rtd_hack to the state, and make sure that value is the same in origing and destination of th emigration. Another problem is what we do with kvm, they have already done releases with the "mc146818rtc-td" savevm section. Notice that rtc-td-hack should really, really be enabled by defaulet. It is needed to have windows guest running correctly under load. What do you think? What should we do? Later, Juan. PD. Once that I was looking here, this driver has several features that are not used anywhere else. - rtc_mm_init() is defined and exported but not used - rtc_init_sqw() is defined, but only called from rtc_init() with sqw_irq = NULL - sqw_irq is only assigned in rtc_init_sqw() and always to NULL value. Is there a reason why we have the functionality that is not used anywhere? Signed-off-by: Juan Quintela --- hw/mc146818rtc.c | 47 +++++++++++++---------------------------------- 1 files changed, 13 insertions(+), 34 deletions(-) diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index b7f09e5..db9f26f 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -75,11 +75,9 @@ struct RTCState { int64_t next_periodic_time; /* second update */ int64_t next_second_time; -#ifdef TARGET_I386 uint32_t irq_coalesced; uint32_t period; QEMUTimer *coalesced_timer; -#endif QEMUTimer *second_timer; QEMUTimer *second_timer2; }; @@ -522,13 +520,15 @@ static void rtc_save(QEMUFile *f, void *opaque) qemu_put_be64(f, s->next_second_time); qemu_put_timer(f, s->second_timer); qemu_put_timer(f, s->second_timer2); + qemu_put_be32(f, s->irq_coalesced); + qemu_put_be32(f, s->period); } static int rtc_load(QEMUFile *f, void *opaque, int version_id) { RTCState *s = opaque; - if (version_id != 1) + if (version_id < 1 || version_id > 2) return -EINVAL; qemu_get_buffer(f, s->cmos_data, 128); @@ -548,31 +548,18 @@ static int rtc_load(QEMUFile *f, void *opaque, int version_id) s->next_second_time=qemu_get_be64(f); qemu_get_timer(f, s->second_timer); qemu_get_timer(f, s->second_timer2); - return 0; -} + if (version_id >= 2) { + s->irq_coalesced = qemu_get_be32(f); + s->period = qemu_get_be32(f); #ifdef TARGET_I386 -static void rtc_save_td(QEMUFile *f, void *opaque) -{ - RTCState *s = opaque; - - qemu_put_be32(f, s->irq_coalesced); - qemu_put_be32(f, s->period); -} - -static int rtc_load_td(QEMUFile *f, void *opaque, int version_id) -{ - RTCState *s = opaque; - - if (version_id != 1) - return -EINVAL; - - s->irq_coalesced = qemu_get_be32(f); - s->period = qemu_get_be32(f); - rtc_coalesced_timer_update(s); + if (rtc_td_hack) { + rtc_coalesced_timer_update(s); + } +#endif + } return 0; } -#endif static void rtc_reset(void *opaque) { @@ -622,11 +609,7 @@ RTCState *rtc_init_sqw(int base, qemu_irq irq, qemu_irq sqw_irq, int base_year) register_ioport_write(base, 2, 1, cmos_ioport_write, s); register_ioport_read(base, 2, 1, cmos_ioport_read, s); - register_savevm("mc146818rtc", base, 1, rtc_save, rtc_load, s); -#ifdef TARGET_I386 - if (rtc_td_hack) - register_savevm("mc146818rtc-td", base, 1, rtc_save_td, rtc_load_td, s); -#endif + register_savevm("mc146818rtc", base, 2, rtc_save, rtc_load, s); qemu_register_reset(rtc_reset, s); return s; @@ -739,11 +722,7 @@ RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, io_memory = cpu_register_io_memory(rtc_mm_read, rtc_mm_write, s); cpu_register_physical_memory(base, 2 << it_shift, io_memory); - register_savevm("mc146818rtc", base, 1, rtc_save, rtc_load, s); -#ifdef TARGET_I386 - if (rtc_td_hack) - register_savevm("mc146818rtc-td", base, 1, rtc_save_td, rtc_load_td, s); -#endif + register_savevm("mc146818rtc", base, 2, rtc_save, rtc_load, s); qemu_register_reset(rtc_reset, s); return s; }