Message ID | 20241216094638.26406-5-avihaih@nvidia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | migration: Drop/unexport migration_is_device() and migration_is_active() | expand |
On 16/12/2024 09:46, Avihai Horon wrote: > vfio_devices_all_dirty_tracking() and vfio_dma_unmap_dirty_sync_needed() > share the same code that checks if dirty page tracking has been started. > > Extract it to a common helper vfio_devices_all_dirty_tracking_started(). > > Signed-off-by: Avihai Horon <avihaih@nvidia.com> Reviewed-by: Joao Martins <joao.m.martins@oracle.com> > --- > hw/vfio/common.c | 25 +++++++++++++------------ > 1 file changed, 13 insertions(+), 12 deletions(-) > > diff --git a/hw/vfio/common.c b/hw/vfio/common.c > index 81fba81a6f..45783982c9 100644 > --- a/hw/vfio/common.c > +++ b/hw/vfio/common.c > @@ -184,16 +184,22 @@ static bool vfio_devices_all_device_dirty_tracking_started( > return true; > } > > +static bool > +vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcontainer) > +{ > + if (!migration_is_running()) { > + return false; > + } > + > + return vfio_devices_all_device_dirty_tracking_started(bcontainer) || > + bcontainer->dirty_pages_started; > +} > + > static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer) > { > VFIODevice *vbasedev; > > - if (!migration_is_running()) { > - return false; > - } > - > - if (!(vfio_devices_all_device_dirty_tracking_started(bcontainer) || > - bcontainer->dirty_pages_started)) { > + if (!vfio_devices_all_dirty_tracking_started(bcontainer)) { > return false; > } > > @@ -231,12 +237,7 @@ bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer) > > bool vfio_dma_unmap_dirty_sync_needed(const VFIOContainerBase *bcontainer) > { > - if (!migration_is_running()) { > - return false; > - } > - > - return vfio_devices_all_device_dirty_tracking_started(bcontainer) || > - bcontainer->dirty_pages_started; > + return vfio_devices_all_dirty_tracking_started(bcontainer); > } > > static bool vfio_listener_skipped_section(MemoryRegionSection *section)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 81fba81a6f..45783982c9 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -184,16 +184,22 @@ static bool vfio_devices_all_device_dirty_tracking_started( return true; } +static bool +vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcontainer) +{ + if (!migration_is_running()) { + return false; + } + + return vfio_devices_all_device_dirty_tracking_started(bcontainer) || + bcontainer->dirty_pages_started; +} + static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer) { VFIODevice *vbasedev; - if (!migration_is_running()) { - return false; - } - - if (!(vfio_devices_all_device_dirty_tracking_started(bcontainer) || - bcontainer->dirty_pages_started)) { + if (!vfio_devices_all_dirty_tracking_started(bcontainer)) { return false; } @@ -231,12 +237,7 @@ bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer) bool vfio_dma_unmap_dirty_sync_needed(const VFIOContainerBase *bcontainer) { - if (!migration_is_running()) { - return false; - } - - return vfio_devices_all_device_dirty_tracking_started(bcontainer) || - bcontainer->dirty_pages_started; + return vfio_devices_all_dirty_tracking_started(bcontainer); } static bool vfio_listener_skipped_section(MemoryRegionSection *section)
vfio_devices_all_dirty_tracking() and vfio_dma_unmap_dirty_sync_needed() share the same code that checks if dirty page tracking has been started. Extract it to a common helper vfio_devices_all_dirty_tracking_started(). Signed-off-by: Avihai Horon <avihaih@nvidia.com> --- hw/vfio/common.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)