From patchwork Wed Sep 9 20:25:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 33228 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 55926B70BA for ; Thu, 10 Sep 2009 06:26:47 +1000 (EST) Received: from localhost ([127.0.0.1]:55365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlTka-0007ir-A9 for incoming@patchwork.ozlabs.org; Wed, 09 Sep 2009 16:26:44 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlTjz-0007gw-M9 for qemu-devel@nongnu.org; Wed, 09 Sep 2009 16:26:07 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlTjv-0007bS-5s for qemu-devel@nongnu.org; Wed, 09 Sep 2009 16:26:07 -0400 Received: from [199.232.76.173] (port=58851 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlTjv-0007b6-0z for qemu-devel@nongnu.org; Wed, 09 Sep 2009 16:26:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16258) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlTju-00075E-Ap for qemu-devel@nongnu.org; Wed, 09 Sep 2009 16:26:02 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n89KQ1Zs011787 for ; Wed, 9 Sep 2009 16:26:01 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n89KQ0ak018490; Wed, 9 Sep 2009 16:26:00 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 9 Sep 2009 22:25:57 +0200 Message-Id: <1252527957-5129-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [RFC PATCH] 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 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 | 45 +++++++++++---------------------------------- 1 files changed, 11 insertions(+), 34 deletions(-) diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index cd405e2..16a3ddd 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; }; @@ -521,13 +519,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); @@ -547,31 +547,16 @@ 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); + rtc_coalesced_timer_update(s); +#endif + } return 0; } -#endif static void rtc_reset(void *opaque) { @@ -621,11 +606,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; @@ -738,11 +719,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; }