@@ -143,7 +143,7 @@ typedef struct VFIODevice {
OnOffAuto pre_copy_dirty_page_tracking;
OnOffAuto device_dirty_page_tracking;
bool dirty_pages_supported;
- bool dirty_tracking;
+ bool dirty_tracking; /* Protected by BQL */
bool iommu_dirty_tracking;
HostIOMMUDevice *hiod;
int devid;
@@ -170,11 +170,26 @@ bool vfio_device_state_is_precopy(VFIODevice *vbasedev)
migration->device_state == VFIO_DEVICE_STATE_PRE_COPY_P2P;
}
+static bool vfio_devices_all_device_dirty_tracking_started(
+ const VFIOContainerBase *bcontainer)
+{
+ VFIODevice *vbasedev;
+
+ QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) {
+ if (!vbasedev->dirty_tracking) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer)
{
VFIODevice *vbasedev;
- if (!migration_is_active() && !migration_is_device()) {
+ if (!(vfio_devices_all_device_dirty_tracking_started(bcontainer) ||
+ bcontainer->dirty_pages_started)) {
return false;
}