mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
vfio/migration: Refactor PRE_COPY and RUNNING state checks
Move the PRE_COPY and RUNNING state checks to helper functions. This is in preparation for adding P2P VFIO migration support, where these helpers will also test for PRE_COPY_P2P and RUNNING_P2P states. Signed-off-by: Joao Martins <joao.m.martins@oracle.com> Signed-off-by: Avihai Horon <avihaih@nvidia.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Tested-by: YangHang Liu <yanghliu@redhat.com> Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
02b2e25360
commit
3d4d0f0e06
3 changed files with 24 additions and 10 deletions
|
@ -437,6 +437,20 @@ static void vfio_set_migration_error(int err)
|
|||
}
|
||||
}
|
||||
|
||||
bool vfio_device_state_is_running(VFIODevice *vbasedev)
|
||||
{
|
||||
VFIOMigration *migration = vbasedev->migration;
|
||||
|
||||
return migration->device_state == VFIO_DEVICE_STATE_RUNNING;
|
||||
}
|
||||
|
||||
bool vfio_device_state_is_precopy(VFIODevice *vbasedev)
|
||||
{
|
||||
VFIOMigration *migration = vbasedev->migration;
|
||||
|
||||
return migration->device_state == VFIO_DEVICE_STATE_PRE_COPY;
|
||||
}
|
||||
|
||||
static bool vfio_devices_all_dirty_tracking(VFIOContainer *container)
|
||||
{
|
||||
VFIOGroup *group;
|
||||
|
@ -457,8 +471,8 @@ static bool vfio_devices_all_dirty_tracking(VFIOContainer *container)
|
|||
}
|
||||
|
||||
if (vbasedev->pre_copy_dirty_page_tracking == ON_OFF_AUTO_OFF &&
|
||||
(migration->device_state == VFIO_DEVICE_STATE_RUNNING ||
|
||||
migration->device_state == VFIO_DEVICE_STATE_PRE_COPY)) {
|
||||
(vfio_device_state_is_running(vbasedev) ||
|
||||
vfio_device_state_is_precopy(vbasedev))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -503,8 +517,8 @@ static bool vfio_devices_all_running_and_mig_active(VFIOContainer *container)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (migration->device_state == VFIO_DEVICE_STATE_RUNNING ||
|
||||
migration->device_state == VFIO_DEVICE_STATE_PRE_COPY) {
|
||||
if (vfio_device_state_is_running(vbasedev) ||
|
||||
vfio_device_state_is_precopy(vbasedev)) {
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue