[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 01/13] vfio/migration: put together checks of migration initi
From: |
Lei Rao |
Subject: |
[RFC PATCH 01/13] vfio/migration: put together checks of migration initialization conditions |
Date: |
Tue, 24 May 2022 14:18:36 +0800 |
Current VFIO live migration initialization code is tightly coupled with
local migration region handling. It is necessary to decouple it to
facilitate the introduction of a generic VFIO live migration framework so
that other approaches can be possible besides the In-Band approach.
This patch puts various checks of migration initialization conditions into
one function vfio_migration_check().
Signed-off-by: Lei Rao <lei.rao@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
---
hw/vfio/migration.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index a6ad1f8945..770f535e81 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -787,6 +787,21 @@ static void vfio_migration_exit(VFIODevice *vbasedev)
vbasedev->migration = NULL;
}
+static int vfio_migration_check(VFIODevice *vbasedev)
+{
+ VFIOContainer *container = vbasedev->group->container;
+
+ if (!vbasedev->enable_migration || !container->dirty_pages_supported) {
+ return -EINVAL;
+ }
+
+ if (!vbasedev->ops->vfio_get_object) {
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int vfio_migration_init(VFIODevice *vbasedev,
struct vfio_region_info *info)
{
@@ -796,10 +811,6 @@ static int vfio_migration_init(VFIODevice *vbasedev,
char id[256] = "";
g_autofree char *path = NULL, *oid = NULL;
- if (!vbasedev->ops->vfio_get_object) {
- return -EINVAL;
- }
-
obj = vbasedev->ops->vfio_get_object(vbasedev);
if (!obj) {
return -EINVAL;
@@ -857,11 +868,11 @@ int64_t vfio_mig_bytes_transferred(void)
int vfio_migration_probe(VFIODevice *vbasedev, Error **errp)
{
- VFIOContainer *container = vbasedev->group->container;
struct vfio_region_info *info = NULL;
int ret = -ENOTSUP;
- if (!vbasedev->enable_migration || !container->dirty_pages_supported) {
+ ret = vfio_migration_check(vbasedev);
+ if (ret) {
goto add_blocker;
}
--
2.32.0
- [RFC PATCH 00/13] Add a plugin to support out-of-band live migration for VFIO pass-through device, Lei Rao, 2022/05/24
- [RFC PATCH 03/13] vfio/migration: move vfio_get_dev_region_info out of vfio_migration_probe, Lei Rao, 2022/05/24
- [RFC PATCH 02/13] vfio/migration: move migration struct allocation out of vfio_migration_init, Lei Rao, 2022/05/24
- [RFC PATCH 04/13] vfio/migration: Separated functions that relate to the In-Band approach, Lei Rao, 2022/05/24
- [RFC PATCH 01/13] vfio/migration: put together checks of migration initialization conditions,
Lei Rao <=
- [RFC PATCH 05/13] vfio/migration: rename functions that relate to the In-Band approach, Lei Rao, 2022/05/24
- [RFC PATCH 06/13] vfio/migration: introduce VFIOMigrationOps layer in VFIO live migration framework, Lei Rao, 2022/05/24
- [RFC PATCH 07/13] vfio/migration: move the statistics of bytes_transferred to generic VFIO migration layer, Lei Rao, 2022/05/24
- [RFC PATCH 08/13] vfio/migration: split migration handler registering from vfio_migration_init, Lei Rao, 2022/05/24
- [RFC PATCH 09/13] vfio/migration: move the functions of In-Band approach to a new file, Lei Rao, 2022/05/24
- [RFC PATCH 12/13] vfio/migration: add some trace-events for vfio migration plugin, Lei Rao, 2022/05/24
- [RFC PATCH 11/13] vfio/migration: add a plugin layer to support out-of-band live migration, Lei Rao, 2022/05/24
- [RFC PATCH 10/13] vfio/pci: introduce command-line parameters to specify migration method, Lei Rao, 2022/05/24
- [RFC PATCH 13/13] vfio/migration: make the region and plugin member of struct VFIOMigration to be a union, Lei Rao, 2022/05/24
- Re: [RFC PATCH 00/13] Add a plugin to support out-of-band live migration for VFIO pass-through device, Alex Williamson, 2022/05/26