[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 02/13] vfio/migration: move migration struct allocation out o
From: |
Lei Rao |
Subject: |
[RFC PATCH 02/13] vfio/migration: move migration struct allocation out of vfio_migration_init |
Date: |
Tue, 24 May 2022 14:18:37 +0800 |
Migration struct is a common data structure. Memory allocation of migration
struct is not unique to In-Band approach. So, move it from vfio_migration_init()
to vfio_migration_probe().
Signed-off-by: Lei Rao <lei.rao@intel.com>
---
hw/vfio/migration.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 770f535e81..11ce87bb1a 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -807,17 +807,15 @@ static int vfio_migration_init(VFIODevice *vbasedev,
{
int ret;
Object *obj;
- VFIOMigration *migration;
char id[256] = "";
g_autofree char *path = NULL, *oid = NULL;
+ VFIOMigration *migration = vbasedev->migration;
obj = vbasedev->ops->vfio_get_object(vbasedev);
if (!obj) {
return -EINVAL;
}
- vbasedev->migration = g_new0(VFIOMigration, 1);
-
ret = vfio_region_setup(obj, vbasedev, &vbasedev->migration->region,
info->index, "migration");
if (ret) {
@@ -833,9 +831,6 @@ static int vfio_migration_init(VFIODevice *vbasedev,
goto err;
}
- migration = vbasedev->migration;
- migration->vbasedev = vbasedev;
-
oid = vmstate_if_get_id(VMSTATE_IF(DEVICE(obj)));
if (oid) {
path = g_strdup_printf("%s/vfio", oid);
@@ -876,6 +871,9 @@ int vfio_migration_probe(VFIODevice *vbasedev, Error **errp)
goto add_blocker;
}
+ vbasedev->migration = g_new0(VFIOMigration, 1);
+ vbasedev->migration->vbasedev = vbasedev;
+
ret = vfio_get_dev_region_info(vbasedev,
VFIO_REGION_TYPE_MIGRATION_DEPRECATED,
VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATED,
@@ -903,6 +901,8 @@ add_blocker:
error_free(vbasedev->migration_blocker);
vbasedev->migration_blocker = NULL;
}
+ g_free(vbasedev->migration);
+ vbasedev->migration = NULL;
return ret;
}
--
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 <=
- [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, 2022/05/24
- [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