mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03: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
|
@ -411,7 +411,7 @@ static void vfio_state_pending_estimate(void *opaque, uint64_t *must_precopy,
|
|||
VFIODevice *vbasedev = opaque;
|
||||
VFIOMigration *migration = vbasedev->migration;
|
||||
|
||||
if (migration->device_state != VFIO_DEVICE_STATE_PRE_COPY) {
|
||||
if (!vfio_device_state_is_precopy(vbasedev)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -444,7 +444,7 @@ static void vfio_state_pending_exact(void *opaque, uint64_t *must_precopy,
|
|||
vfio_query_stop_copy_size(vbasedev, &stop_copy_size);
|
||||
*must_precopy += stop_copy_size;
|
||||
|
||||
if (migration->device_state == VFIO_DEVICE_STATE_PRE_COPY) {
|
||||
if (vfio_device_state_is_precopy(vbasedev)) {
|
||||
vfio_query_precopy_size(migration);
|
||||
|
||||
*must_precopy +=
|
||||
|
@ -459,9 +459,8 @@ static void vfio_state_pending_exact(void *opaque, uint64_t *must_precopy,
|
|||
static bool vfio_is_active_iterate(void *opaque)
|
||||
{
|
||||
VFIODevice *vbasedev = opaque;
|
||||
VFIOMigration *migration = vbasedev->migration;
|
||||
|
||||
return migration->device_state == VFIO_DEVICE_STATE_PRE_COPY;
|
||||
return vfio_device_state_is_precopy(vbasedev);
|
||||
}
|
||||
|
||||
static int vfio_save_iterate(QEMUFile *f, void *opaque)
|
||||
|
@ -656,7 +655,6 @@ static const SaveVMHandlers savevm_vfio_handlers = {
|
|||
static void vfio_vmstate_change(void *opaque, bool running, RunState state)
|
||||
{
|
||||
VFIODevice *vbasedev = opaque;
|
||||
VFIOMigration *migration = vbasedev->migration;
|
||||
enum vfio_device_mig_state new_state;
|
||||
int ret;
|
||||
|
||||
|
@ -664,7 +662,7 @@ static void vfio_vmstate_change(void *opaque, bool running, RunState state)
|
|||
new_state = VFIO_DEVICE_STATE_RUNNING;
|
||||
} else {
|
||||
new_state =
|
||||
(migration->device_state == VFIO_DEVICE_STATE_PRE_COPY &&
|
||||
(vfio_device_state_is_precopy(vbasedev) &&
|
||||
(state == RUN_STATE_FINISH_MIGRATE || state == RUN_STATE_PAUSED)) ?
|
||||
VFIO_DEVICE_STATE_STOP_COPY :
|
||||
VFIO_DEVICE_STATE_STOP;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue