migration: migration_is_device
authorSteve Sistare <steven.sistare@oracle.com>
Mon, 11 Mar 2024 17:48:54 +0000 (10:48 -0700)
committerPeter Xu <peterx@redhat.com>
Mon, 11 Mar 2024 20:28:59 +0000 (16:28 -0400)
Define and export migration_is_device to eliminate a dependency
on MigrationState.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Link: https://lore.kernel.org/r/1710179338-294359-8-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
hw/vfio/common.c
include/migration/misc.h
migration/migration.c

index 2dbbf62e1551894fb6ac267cf858d80dee122e7c..de010680ff192a537bd715945a529d764e73cabc 100644 (file)
@@ -180,10 +180,8 @@ bool vfio_device_state_is_precopy(VFIODevice *vbasedev)
 static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer)
 {
     VFIODevice *vbasedev;
-    MigrationState *ms = migrate_get_current();
 
-    if (!migration_is_active() &&
-        ms->state != MIGRATION_STATUS_DEVICE) {
+    if (!migration_is_active() && !migration_is_device()) {
         return false;
     }
 
index c4b541635740c2feb968fdbc52d1d16593c92237..28cfaed2c754fb02d947bdbbc8d970cae2abfc63 100644 (file)
@@ -61,6 +61,7 @@ void migration_object_init(void);
 void migration_shutdown(void);
 bool migration_is_idle(void);
 bool migration_is_active(void);
+bool migration_is_device(void);
 bool migration_thread_is_self(void);
 bool migration_is_setup_or_active(void);
 bool migrate_mode_is_cpr(MigrationState *);
index afe72af0b18ca140c392049c59bc7ec3d67185d3..db1e6278481b078d037855cce7aea2edfddb74e9 100644 (file)
@@ -1647,6 +1647,13 @@ bool migration_is_active(void)
             s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE);
 }
 
+bool migration_is_device(void)
+{
+    MigrationState *s = current_migration;
+
+    return s->state == MIGRATION_STATUS_DEVICE;
+}
+
 bool migration_thread_is_self(void)
 {
     MigrationState *s = current_migration;