@@ -170,11 +170,32 @@ bool vfio_device_state_is_precopy(VFIODevice *vbasedev)
170
170
migration -> device_state == VFIO_DEVICE_STATE_PRE_COPY_P2P ;
171
171
}
172
172
173
- static bool vfio_devices_all_dirty_tracking (VFIOContainerBase * bcontainer )
173
+ static bool vfio_devices_all_device_dirty_tracking_started (
174
+ const VFIOContainerBase * bcontainer )
174
175
{
175
176
VFIODevice * vbasedev ;
176
177
177
- if (!migration_is_active () && !migration_is_device ()) {
178
+ QLIST_FOREACH (vbasedev , & bcontainer -> device_list , container_next ) {
179
+ if (!vbasedev -> dirty_tracking ) {
180
+ return false;
181
+ }
182
+ }
183
+
184
+ return true;
185
+ }
186
+
187
+ bool vfio_devices_all_dirty_tracking_started (
188
+ const VFIOContainerBase * bcontainer )
189
+ {
190
+ return vfio_devices_all_device_dirty_tracking_started (bcontainer ) ||
191
+ bcontainer -> dirty_pages_started ;
192
+ }
193
+
194
+ static bool vfio_log_sync_needed (const VFIOContainerBase * bcontainer )
195
+ {
196
+ VFIODevice * vbasedev ;
197
+
198
+ if (!vfio_devices_all_dirty_tracking_started (bcontainer )) {
178
199
return false;
179
200
}
180
201
@@ -210,36 +231,6 @@ bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer)
210
231
return true;
211
232
}
212
233
213
- /*
214
- * Check if all VFIO devices are running and migration is active, which is
215
- * essentially equivalent to the migration being in pre-copy phase.
216
- */
217
- bool
218
- vfio_devices_all_running_and_mig_active (const VFIOContainerBase * bcontainer )
219
- {
220
- VFIODevice * vbasedev ;
221
-
222
- if (!migration_is_active ()) {
223
- return false;
224
- }
225
-
226
- QLIST_FOREACH (vbasedev , & bcontainer -> device_list , container_next ) {
227
- VFIOMigration * migration = vbasedev -> migration ;
228
-
229
- if (!migration ) {
230
- return false;
231
- }
232
-
233
- if (vfio_device_state_is_running (vbasedev ) ||
234
- vfio_device_state_is_precopy (vbasedev )) {
235
- continue ;
236
- } else {
237
- return false;
238
- }
239
- }
240
- return true;
241
- }
242
-
243
234
static bool vfio_listener_skipped_section (MemoryRegionSection * section )
244
235
{
245
236
return (!memory_region_is_ram (section -> mr ) &&
@@ -1373,7 +1364,7 @@ static void vfio_listener_log_sync(MemoryListener *listener,
1373
1364
return ;
1374
1365
}
1375
1366
1376
- if (vfio_devices_all_dirty_tracking (bcontainer )) {
1367
+ if (vfio_log_sync_needed (bcontainer )) {
1377
1368
ret = vfio_sync_dirty_bitmap (bcontainer , section , & local_err );
1378
1369
if (ret ) {
1379
1370
error_report_err (local_err );
0 commit comments