The new logic is compatible with old. So it should not block to migrate from old version. But new version cannot migrate to old. Signed-off-by: Yang Zhang <yang.z.zhang@xxxxxxxxx> --- hw/mc146818rtc.c | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 44 insertions(+), 4 deletions(-) diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index 384bdc1..02f7ea0 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -635,11 +635,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), @@ -777,7 +817,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", -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html