From patchwork Thu May 17 02:29:15 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: 159805 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 5D7EBB6FBA for ; Thu, 17 May 2012 12:57:29 +1000 (EST) Received: from localhost ([::1]:48639 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUqTj-0006T2-I1 for incoming@patchwork.ozlabs.org; Wed, 16 May 2012 22:30:11 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUqSw-0004jf-7d for qemu-devel@nongnu.org; Wed, 16 May 2012 22:29:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SUqSu-0007kF-B2 for qemu-devel@nongnu.org; Wed, 16 May 2012 22:29:21 -0400 Received: from mga14.intel.com ([143.182.124.37]:30993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUqSu-0007jZ-50 for qemu-devel@nongnu.org; Wed, 16 May 2012 22:29:20 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 16 May 2012 19:29:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="144183603" Received: from azsmsx601.amr.corp.intel.com ([10.2.121.193]) by azsmga001.ch.intel.com with ESMTP; 16 May 2012 19:29:17 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by azsmsx601.amr.corp.intel.com (10.2.121.193) with Microsoft SMTP Server (TLS) id 8.2.255.0; Wed, 16 May 2012 19:29:17 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.6]) by SHSMSX102.ccr.corp.intel.com ([169.254.2.133]) with mapi id 14.01.0355.002; Thu, 17 May 2012 10:29:15 +0800 From: "Zhang, Yang Z" To: "'qemu-devel@nongnu.org'" Thread-Topic: [PATCH v6 7/7] RTC:Allow to migrate from old QEMU Thread-Index: Ac0z1NodHT6ynCVYROaR1Zlj/Mo/8A== Date: Thu, 17 May 2012 02:29:15 +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 Cc: 'Paolo Bonzini' , "'aliguori@us.ibm.com'" , "'qemu-devel@nongnu.org'" Subject: [Qemu-devel] [PATCH v6 7/7] RTC:Allow to migrate from old QEMU 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 should not block to migrate from old QEMU. But new version cannot migrate to old. Signed-off-by: Yang Zhang --- hw/mc146818rtc.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 40 insertions(+), 3 deletions(-) -- 1.7.1 diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index 956f10b..3c31c0b 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -808,11 +808,48 @@ 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; + uint8_t buf[77]; + + if (version_id > 2) { + return -EINVAL; + } + + qemu_get_buffer(f, s->cmos_data, sizeof(s->cmos_data)); + qemu_get_8s(f, &s->cmos_index); + + /* Skip loading of s->current_tm, we already have the + * information in cmos_data. + */ + qemu_get_buffer(f, buf, 7*4); + + qemu_get_timer(f, s->periodic_timer); + s->next_periodic_time = qemu_get_be64(f); + + /* Skip loading of next_second_time, second_timer, second_timer2. */ + qemu_get_buffer(f, buf, 3*8); + + rtc_set_time(s); + s->offset = 0; + s->old_guest_usec = 0; + check_update_timer(s); + + if (version_id >= 2) { + s->irq_coalesced = qemu_get_be32(f); + s->period = qemu_get_be32(f); + } + + return rtc_post_load(opaque, version_id); +} + static const VMStateDescription vmstate_rtc = { .name = "mc146818rtc", - .version_id = 2, - .minimum_version_id = 1, + .version_id = 3, + .minimum_version_id = 3, .minimum_version_id_old = 1, + .load_state_old = rtc_load_old, .post_load = rtc_post_load, .fields = (VMStateField []) { VMSTATE_BUFFER(cmos_data, RTCState), @@ -952,7 +989,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",