vfio/migration: Refactor vfio_devices_all_dirty_tracking() logic
authorAvihai Horon <avihaih@nvidia.com>
Wed, 18 Dec 2024 13:40:17 +0000 (15:40 +0200)
committerCédric Le Goater <clg@redhat.com>
Thu, 26 Dec 2024 06:23:38 +0000 (07:23 +0100)
commit0ae05e087f99a8e4ca84537bdce65d25912d084e
tree2d65e8651c1e17e24db68cbc958fa3b4d1baa77c
parentd77e85dbd7655cc41af51df74c077d8b31aee93c
vfio/migration: Refactor vfio_devices_all_dirty_tracking() logic

During dirty page log sync, vfio_devices_all_dirty_tracking() is used to
check if dirty tracking has been started in order to avoid errors. The
current logic checks if migration is in ACTIVE or DEVICE states to
ensure dirty tracking has been started.

However, recently there has been an effort to simplify the migration
status API and reduce it to a single migration_is_running() function.

To accommodate this, refactor vfio_devices_all_dirty_tracking() logic so
it won't use migration_is_active() and migration_is_device(). Instead,
use internal VFIO dirty tracking flags.

As a side effect, now that migration status is no longer used to detect
dirty tracking status, VFIO log syncs are untied from migration. This
will make calc-dirty-rate more accurate as now it will also include VFIO
dirty pages.

While at it, as VFIODevice->dirty_tracking is now used to detect dirty
tracking status, add a comment that states how it's protected.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Tested-by: Joao Martins <joao.m.martins@oracle.com>
Link: https://lore.kernel.org/r/20241218134022.21264-3-avihaih@nvidia.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
hw/vfio/common.c
include/hw/vfio/vfio-common.h