[PATCH v2] migration: Replace current_migration with migrate_get_current()

Aadeshveer Singh posted 1 patch 2 weeks, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260513063513.250911-1-aadeshveer07@gmail.com
Maintainers: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>
migration/migration.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH v2] migration: Replace current_migration with migrate_get_current()
Posted by Aadeshveer Singh 2 weeks, 3 days ago
Replaces the direct accesses to global variable `current_migration`
with `migrate_get_current()` to ensure consistency across systems.

Note: Following this only direct access to `current_migration` will be
* `migrate_get_current()` itself
* `migration_object_init()` initializes `current_migration`
* `migration_shutdown()` to pair up with initialization
* `migration_is_running()`, as there might be a case where this function
  is called by a thread before object initialization

Signed-off-by: Aadeshveer Singh <aadeshveer07@gmail.com>
---
 migration/migration.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index ecc69dc4d2..0e142ff6f2 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1029,7 +1029,7 @@ bool migration_is_running(void)
 
 static bool migration_is_active(void)
 {
-    MigrationState *s = current_migration;
+    MigrationState *s = migrate_get_current();
 
     return (s->state == MIGRATION_STATUS_ACTIVE ||
             s->state == MIGRATION_STATUS_POSTCOPY_DEVICE ||
@@ -1634,7 +1634,7 @@ bool migration_in_bg_snapshot(void)
 
 bool migration_thread_is_self(void)
 {
-    MigrationState *s = current_migration;
+    MigrationState *s = migrate_get_current();
 
     return qemu_thread_is_self(&s->thread);
 }
@@ -3062,7 +3062,7 @@ static MigThrError postcopy_pause(MigrationState *s)
 
 void migration_file_set_error(int ret, Error *err)
 {
-    MigrationState *s = current_migration;
+    MigrationState *s = migrate_get_current();
 
     WITH_QEMU_LOCK_GUARD(&s->qemu_file_lock) {
         if (s->to_dst_file) {
-- 
2.54.0
Re: [PATCH v2] migration: Replace current_migration with migrate_get_current()
Posted by Peter Xu 2 weeks, 2 days ago
On Wed, May 13, 2026 at 12:05:13PM +0530, Aadeshveer Singh wrote:
> Replaces the direct accesses to global variable `current_migration`
> with `migrate_get_current()` to ensure consistency across systems.
> 
> Note: Following this only direct access to `current_migration` will be
> * `migrate_get_current()` itself
> * `migration_object_init()` initializes `current_migration`
> * `migration_shutdown()` to pair up with initialization
> * `migration_is_running()`, as there might be a case where this function
>   is called by a thread before object initialization
> 
> Signed-off-by: Aadeshveer Singh <aadeshveer07@gmail.com>

queued, thanks.

-- 
Peter Xu