[RFC PATCH 12/13] vfio/migration: add some trace-events for vfio migration plugin

2022-05-23 Thread Lei Rao
Add some trace-events including trace_vfio_migration_plugin_probe trace_vfio_plugin_save_buffer, trace_vfio_plugin_load_state_device_data trace_vfio_update_pending, and trace_vfio_migration_set_state to make debugging easier. Signed-off-by: Lei Rao Reviewed-by: Eddie Dong --- hw/vfio/migration

[RFC PATCH 10/13] vfio/pci: introduce command-line parameters to specify migration method

2022-05-23 Thread Lei Rao
running on IPU/DPU backend SOC through network, the argument should be the IP and Port of agent. The usage as follows: -device vfio-pci,id=$ID,host=$bdf,x-enable-migration,\ x-plugin-path=$plugin_path,x-plugin-arg= Signed-off-by: Lei Rao Reviewed-by: Eddie Dong --- hw/vfio/pci.c | 2

[RFC PATCH 07/13] vfio/migration: move the statistics of bytes_transferred to generic VFIO migration layer

2022-05-23 Thread Lei Rao
The statistics of bytes transferred conceptually belong to The VFIO live migration framework, and should not belong to any specific implementation such In-Band approach, so move it out from vfio_migration_region_save_buffer(), which makes it easier to add other implementations. Signed-off-by: Lei

[RFC PATCH 09/13] vfio/migration: move the functions of In-Band approach to a new file

2022-05-23 Thread Lei Rao
Moving the functions of In-Band approach into a new file to match with the new abstraction layer of migration ops. Signed-off-by: Lei Rao Reviewed-by: Eddie Dong --- hw/vfio/meson.build | 1 + hw/vfio/migration-local.c | 453 ++ hw/vfio

[RFC PATCH 11/13] vfio/migration: add a plugin layer to support out-of-band live migration

2022-05-23 Thread Lei Rao
_plugin_version" to check the interface version that plugin supports. And then find and invoke function symbol named "vfio_lm_get_plugin_ops" to get vendor device specific VFIOMigrationPluginOps which will be used for saving/restoring device states during live migration. Signed-

[RFC PATCH 13/13] vfio/migration: make the region and plugin member of struct VFIOMigration to be a union

2022-05-23 Thread Lei Rao
Since a VFIO device either uses In-Band or Out-of-Band live migration. So, the region and plugin in VFIOMigration can be put into a union. Signed-off-by: Lei Rao Reviewed-by: Eddie Dong --- hw/vfio/migration-local.c | 33 ++--- include/hw/vfio/vfio-common.h | 6

[RFC PATCH 06/13] vfio/migration: introduce VFIOMigrationOps layer in VFIO live migration framework

2022-05-23 Thread Lei Rao
Add an abstraction layer, VFIOMigrationOps, to the VFIO live migration framework. Also adapt the In-Band approach to this abstraction layer by defining its own VFIOMigrationOps callbacks. Signed-off-by: Lei Rao Reviewed-by: Eddie Dong --- hw/vfio/migration.c | 203

[RFC PATCH 05/13] vfio/migration: rename functions that relate to the In-Band approach

2022-05-23 Thread Lei Rao
, vfio_update_pending to vfio_migration_update_pending_local, vfio_migration_init to vfio_migration_probe_local, vfio_migration_exit to vfio_migration_exit_local. Signed-off-by: Lei Rao Reviewed-by: Eddie Dong --- hw/vfio/migration.c | 74 +++- hw/vfio

[RFC PATCH 08/13] vfio/migration: split migration handler registering from vfio_migration_init

2022-05-23 Thread Lei Rao
vfio_migration_init() is mainly related to initialization of In-Band approach. Migration handler registering may also be used by other approaches. so split it from vfio_migration_init() and move it to vfio_migration_probe(). Signed-off-by: Lei Rao Reviewed-by: Eddie Dong --- hw/vfio

[RFC PATCH 04/13] vfio/migration: Separated functions that relate to the In-Band approach

2022-05-23 Thread Lei Rao
Split functions of In-Band approach from common function, to prepare for the introduction of generic VFIO live migration layer and another Sub-Ops. Signed-off-by: Lei Rao Reviewed-by: Eddie Dong --- hw/vfio/migration.c | 64 ++--- 1 file changed, 49

[RFC PATCH 01/13] vfio/migration: put together checks of migration initialization conditions

2022-05-23 Thread Lei Rao
various checks of migration initialization conditions into one function vfio_migration_check(). Signed-off-by: Lei Rao Reviewed-by: Eddie Dong --- hw/vfio/migration.c | 23 +-- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio

[RFC PATCH 02/13] vfio/migration: move migration struct allocation out of vfio_migration_init

2022-05-23 Thread Lei Rao
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 --- hw/vfio/migration.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions

[RFC PATCH 00/13] Add a plugin to support out-of-band live migration for VFIO pass-through device

2022-05-23 Thread Lei Rao
-intel/vfio-lm-plugin-example.git Lei Rao (13): vfio/migration: put together checks of migration initialization conditions vfio/migration: move migration struct allocation out of vfio_migration_init vfio/migration: move vfio_get_dev_region_info out of vfio_migration_probe vfio/mi

[RFC PATCH 03/13] vfio/migration: move vfio_get_dev_region_info out of vfio_migration_probe

2022-05-23 Thread Lei Rao
d-off-by: Lei Rao --- hw/vfio/migration.c | 30 +++--- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 11ce87bb1a..e61c19171a 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -802,12 +802,12 @@ s

[PATCH 6/7] Changed the last-mode to none of first start COLO

2021-06-16 Thread Lei Rao
st-mode is unreasonable. After the patch, will be changed to the following: { "execute": "query-colo-status" } {"return": {"last-mode": "none", "mode": "primary", "reason": "none"}} Signed-off-by: Lei Rao --

[PATCH 3/7] Fixed SVM hang when do failover before PVM crash

2021-06-16 Thread Lei Rao
dlock. So, we should release the qemu_global_mutex before waiting colo thread ends. Signed-off-by: Lei Rao --- migration/migration.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index c2c84c7..6debb8b 100644 --- a/migration/migrat

[PATCH 4/7] colo: fixed 'Segmentation fault' when the simplex mode PVM poweroff

2021-06-16 Thread Lei Rao
imary_vm_do_failover() would call "qemu_file_shutdown (s->rp_state.from_dst_file);" and later the migration_shutdown() would do it again. So, we should set the s->rp_state.from_dst_file to NULL. Signed-off-by: Like Xu Signed-off-by: Lei Rao --- migration/colo.c | 5 +++-- 1 file c

[PATCH 7/7] Optimized the function of fill_connection_key.

2021-06-16 Thread Lei Rao
From: "Rao, Lei" Remove some unnecessary code to improve the performance of the filter-rewriter module. Signed-off-by: Lei Rao --- net/colo-compare.c| 2 +- net/colo.c| 31 --- net/colo.h| 6 +++--- net/filter-rewri

[PATCH 2/7] Fixed qemu crash when guest power off in COLO mode

2021-06-16 Thread Lei Rao
d7e9609 in start_thread (arg=) at pthread_create.c:477 9 0x7faa3d710293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Signed-off-by: Lei Rao --- migration/migration.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c in

[PATCH 5/7] Removed the qemu_fclose() in colo_process_incoming_thread

2021-06-16 Thread Lei Rao
From: "Rao, Lei" After the live migration, the related fd will be cleanup in migration_incoming_state_destroy(). So, the qemu_close() in colo_process_incoming_thread is not necessary. Signed-off-by: Lei Rao --- migration/colo.c | 5 - 1 file changed, 5 deletions(-) diff --git a

[PATCH 0/7] Fixed some bugs and optimized some codes for COLO

2021-06-16 Thread Lei Rao
From: Rao, Lei The series of patches include: Fixed some bugs of qemu crash and segment fault. Optimized the function of fill_connection_key. Remove some unnecessary code to improve COLO. Rao, Lei (7): Some minor optimizations for COLO Fixed qemu crash when guest powe

[PATCH 1/7] Some minor optimizations for COLO

2021-06-16 Thread Lei Rao
From: "Rao, Lei" Signed-off-by: Lei Rao --- migration/colo.c | 2 +- net/colo-compare.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index 79fa1f6..616dc00 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -15