From patchwork Mon Mar 19 06:14:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yang Z" X-Patchwork-Id: 147528 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8C5D7B6ED0 for ; Tue, 20 Mar 2012 00:51:52 +1100 (EST) Received: from localhost ([::1]:54578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9d02-000740-Gu for incoming@patchwork.ozlabs.org; Mon, 19 Mar 2012 09:51:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9Vri-0005Nn-9N for qemu-devel@nongnu.org; Mon, 19 Mar 2012 02:14:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S9Vrg-0001Yl-Bu for qemu-devel@nongnu.org; Mon, 19 Mar 2012 02:14:45 -0400 Received: from mga14.intel.com ([143.182.124.37]:2564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9Vrg-0001XS-5N for qemu-devel@nongnu.org; Mon, 19 Mar 2012 02:14:44 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 18 Mar 2012 23:14:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="120496887" Received: from azsmsx603.amr.corp.intel.com ([10.2.161.23]) by azsmga001.ch.intel.com with ESMTP; 18 Mar 2012 23:14:43 -0700 Received: from azsmsx602.amr.corp.intel.com (10.2.121.201) by azsmsx603.amr.corp.intel.com (10.2.161.23) with Microsoft SMTP Server (TLS) id 8.2.255.0; Sun, 18 Mar 2012 23:14:42 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by azsmsx602.amr.corp.intel.com (10.2.121.201) with Microsoft SMTP Server (TLS) id 8.2.255.0; Sun, 18 Mar 2012 23:14:42 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.142]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.91]) with mapi id 14.01.0355.002; Mon, 19 Mar 2012 14:14:40 +0800 From: "Zhang, Yang Z" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v4 7/7] RTC:Allow to migrate from old version Thread-Index: Ac0Fl4+5AevArCpyQHmW1z7qZh6oMA== Date: Mon, 19 Mar 2012 06:14:39 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 143.182.124.37 X-Mailman-Approved-At: Mon, 19 Mar 2012 09:50:26 -0400 Cc: Paolo Bonzini , "aliguori@us.ibm.com" , "kvm@vger.kernel.org" Subject: [Qemu-devel] [PATCH v4 7/7] RTC:Allow to migrate from old version 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 The new logic is compatible with old. So it should not block migrate from old version. But new version cannot migrate to old. Signed-off-by: Yang Zhang --- hw/mc146818rtc.c | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 44 insertions(+), 4 deletions(-) -- 1.7.1 diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index c03606f..61ac3c3 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -827,11 +827,51 @@ static int rtc_post_load(void *opaque, int version_id) return 0; } +static int rtc_load_old(QEMUFile *f, void *opaque, int version_id) +{ + RTCState *s = opaque; + + if (version_id > 2) { + return -EINVAL; + } + + qemu_get_buffer(f, s->cmos_data, sizeof(s->cmos_data)); + /* dummy load for compatibility */ + qemu_get_byte(f); /* cmos_index */ + qemu_get_be32(f); /* tm_sec */ + qemu_get_be32(f); /* tm_min */ + qemu_get_be32(f); /* tm_hour */ + qemu_get_be32(f); /* tm_wday */ + qemu_get_be32(f); /* tm_mday */ + qemu_get_be32(f); /* tm_mon */ + qemu_get_be32(f); /* tm_year */ + qemu_get_be64(f); /* periodic_timer */ + qemu_get_be64(f); /* next_periodic_time */ + qemu_get_be64(f); /* next_second_time */ + qemu_get_be64(f); /* second_timer */ + qemu_get_be64(f); /* second_timer2 */ + qemu_get_be32(f); /* irq_coalesced */ + qemu_get_be32(f); /* period */ + + + rtc_set_date_from_host(&s->dev); + periodic_timer_update(s, qemu_get_clock_ns(rtc_clock)); + check_update_timer(s); + +#ifdef TARGET_I386 + if (s->lost_tick_policy == LOST_TICK_SLEW) { + rtc_coalesced_timer_update(s); + } +#endif + return 0; +} + static const VMStateDescription vmstate_rtc = { .name = "mc146818rtc", - .version_id = 2, - .minimum_version_id = 1, - .minimum_version_id_old = 1, + .version_id = 3, + .minimum_version_id = 3, + .minimum_version_id_old = 2, + .load_state_old = rtc_load_old, .post_load = rtc_post_load, .fields = (VMStateField []) { VMSTATE_BUFFER(cmos_data, RTCState), @@ -969,7 +1009,7 @@ static int rtc_initfn(ISADevice *dev) memory_region_init_io(&s->io, &cmos_ops, s, "rtc", 2); isa_register_ioport(dev, &s->io, base); - qdev_set_legacy_instance_id(&dev->qdev, base, 2); + qdev_set_legacy_instance_id(&dev->qdev, base, 3); qemu_register_reset(rtc_reset, s); object_property_add(OBJECT(s), "date", "struct tm",