init vfio migration in vfio_realize() and register migraton blocker if failure met. finalize all migration resources when vfio_instance_finalize(). Signed-off-by: Yan Zhao <yan.y.zhao@xxxxxxxxx> Signed-off-by: Yulei Zhang <yulei.zhang@xxxxxxxxx> --- hw/vfio/pci.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index b8e006b..8bf625e 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3068,6 +3068,8 @@ static void vfio_realize(PCIDevice *pdev, Error **errp) goto out_teardown; } + vfio_migration_init(vdev, errp); + vfio_register_err_notifier(vdev); vfio_register_req_notifier(vdev); vfio_setup_resetfn_quirk(vdev); @@ -3089,6 +3091,7 @@ static void vfio_instance_finalize(Object *obj) vfio_display_finalize(vdev); vfio_bars_finalize(vdev); + vfio_migration_finalize(vdev); g_free(vdev->emulated_config_bits); g_free(vdev->rom); /* @@ -3221,11 +3224,6 @@ static Property vfio_pci_dev_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -static const VMStateDescription vfio_pci_vmstate = { - .name = "vfio-pci", - .unmigratable = 1, -}; - static void vfio_pci_dev_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -3233,7 +3231,6 @@ static void vfio_pci_dev_class_init(ObjectClass *klass, void *data) dc->reset = vfio_pci_reset; dc->props = vfio_pci_dev_properties; - dc->vmsd = &vfio_pci_vmstate; dc->desc = "VFIO-based PCI device assignment"; set_bit(DEVICE_CATEGORY_MISC, dc->categories); pdc->realize = vfio_realize; -- 2.7.4