On Thu, 22 Oct 2020 16:41:54 +0530 Kirti Wankhede <[email protected]> wrote:
> Whether the VFIO device supports migration or not is decided based of > migration region query. If migration region query is successful and migration > region initialization is successful then migration is supported else > migration is blocked. > > Signed-off-by: Kirti Wankhede <[email protected]> > Reviewed-by: Neo Jia <[email protected]> > Acked-by: Dr. David Alan Gilbert <[email protected]> > --- > hw/vfio/meson.build | 1 + > hw/vfio/migration.c | 129 > ++++++++++++++++++++++++++++++++++++++++++ > hw/vfio/trace-events | 3 + > include/hw/vfio/vfio-common.h | 9 +++ > 4 files changed, 142 insertions(+) > create mode 100644 hw/vfio/migration.c (...) > +static int vfio_migration_init(VFIODevice *vbasedev, > + struct vfio_region_info *info) > +{ > + int ret; > + Object *obj; > + VFIOMigration *migration; > + > + if (!vbasedev->ops->vfio_get_object) { > + return -EINVAL; > + } > + > + obj = vbasedev->ops->vfio_get_object(vbasedev); > + if (!obj) { > + return -EINVAL; > + } > + > + migration = g_new0(VFIOMigration, 1); > + > + ret = vfio_region_setup(obj, vbasedev, &migration->region, > + info->index, "migration"); > + if (ret) { > + error_report("%s: Failed to setup VFIO migration region %d: %s", > + vbasedev->name, info->index, strerror(-ret)); > + goto err; > + } > + > + if (!migration->region.size) { > + error_report("%s: Invalid zero-sized of VFIO migration region %d", s/of // > + vbasedev->name, info->index); > + ret = -EINVAL; > + goto err; > + } > + > + vbasedev->migration = migration; > + return 0; > + > +err: > + vfio_migration_region_exit(vbasedev); > + g_free(migration); > + return ret; > +} (...)
