diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-10-22 00:32:41 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2020-01-07 16:50:42 +0400 |
commit | 4cc017e505df7e5344e4dfe7fc17711117c5f11f (patch) | |
tree | 65b8366ac493b84dd8bddd1b6ceab3eba576acc4 /hw/char/serial.c | |
parent | 7781b88ee458ff933459503ade0b0a6ddaad08de (diff) |
serial: register vmsd with DeviceClass
Migration from old to new code works, however the other way fails for
devices that use serial_init/serial_mm_init with "base", used as
instance_id previously.
(with qdev_set_legacy_instance_id, the alias_id is only used in
savevm.c:find_se(), and thus can only be used to match against
"legacy" instance id values. On new code, instance_id is generated
incrementally from 0 with calculate_new_instance_id(), based on
"qdev-path/vmsd-name")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: xiaoqiang zhao <zxq_yx_007@163.com>
Diffstat (limited to 'hw/char/serial.c')
-rw-r--r-- | hw/char/serial.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/hw/char/serial.c b/hw/char/serial.c index 233a9e2076..e926845843 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -990,8 +990,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, s->baudbase = baudbase; qemu_chr_fe_init(&s->chr, chr, &error_abort); serial_realize_core(s, &error_fatal); - - vmstate_register(NULL, base, &vmstate_serial, s); + qdev_set_legacy_instance_id(dev, base, 2); qdev_init_nofail(dev); memory_region_init_io(&s->io, NULL, &serial_io_ops, s, "serial", 8); @@ -1006,6 +1005,7 @@ static void serial_class_init(ObjectClass *klass, void *data) /* internal device for serialio/serialmm, not user-creatable */ dc->user_creatable = false; + dc->vmsd = &vmstate_serial; } static const TypeInfo serial_info = { @@ -1069,7 +1069,7 @@ SerialState *serial_mm_init(MemoryRegion *address_space, qemu_chr_fe_init(&s->chr, chr, &error_abort); serial_realize_core(s, &error_fatal); - vmstate_register(NULL, base, &vmstate_serial, s); + qdev_set_legacy_instance_id(dev, base, 2); qdev_init_nofail(dev); memory_region_init_io(&s->io, NULL, &serial_mm_ops[end], s, |