* [PATCH] [migration] Replace current_migration with migrate_get_current()
@ 2026-05-12 10:00 Aadeshveer Singh
2026-05-12 15:28 ` Peter Xu
0 siblings, 1 reply; 2+ messages in thread
From: Aadeshveer Singh @ 2026-05-12 10:00 UTC (permalink / raw)
To: qemu-devel; +Cc: peterx, farosas, Aadeshveer Singh
Replaces the direct accesses to global variable `current_migration`
with `migrate_get_current()` to ensure safety and
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_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 | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index ecc69dc4d2..f3a96b1949 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -321,7 +321,7 @@ void migration_object_init(void)
current_incoming->exit_on_error = INMIGRATE_DEFAULT_EXIT_ON_ERROR;
- migration_object_check(current_migration, &error_fatal);
+ migration_object_check(migrate_get_current(), &error_fatal);
ram_mig_init();
dirty_bitmap_mig_init();
@@ -385,7 +385,7 @@ void migration_shutdown(void)
* stop the migration using this structure
*/
migration_cancel();
- object_unref(OBJECT(current_migration));
+ object_unref(OBJECT(migrate_get_current()));
/*
* Cancel outgoing migration of dirty bitmaps. It should
@@ -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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] [migration] Replace current_migration with migrate_get_current()
2026-05-12 10:00 [PATCH] [migration] Replace current_migration with migrate_get_current() Aadeshveer Singh
@ 2026-05-12 15:28 ` Peter Xu
0 siblings, 0 replies; 2+ messages in thread
From: Peter Xu @ 2026-05-12 15:28 UTC (permalink / raw)
To: Aadeshveer Singh; +Cc: qemu-devel, farosas
On Tue, May 12, 2026 at 03:30:00PM +0530, Aadeshveer Singh wrote:
For subject, please use "migration: " as prefix.
> Replaces the direct accesses to global variable `current_migration`
> with `migrate_get_current()` to ensure safety and
> consistency across systems.
Safety shouldn't be a major concern, but maybe it helps consistency.
>
> Note: Following this only direct access to `current_migration` will be
> * `migrate_get_current()` itself
> * `migration_object_init()` initializes `current_migration`
> * `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 | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/migration/migration.c b/migration/migration.c
> index ecc69dc4d2..f3a96b1949 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -321,7 +321,7 @@ void migration_object_init(void)
>
> current_incoming->exit_on_error = INMIGRATE_DEFAULT_EXIT_ON_ERROR;
>
> - migration_object_check(current_migration, &error_fatal);
> + migration_object_check(migrate_get_current(), &error_fatal);
IMHO we can still keep this one as-is, when in obj init path.
>
> ram_mig_init();
> dirty_bitmap_mig_init();
> @@ -385,7 +385,7 @@ void migration_shutdown(void)
> * stop the migration using this structure
> */
> migration_cancel();
> - object_unref(OBJECT(current_migration));
> + object_unref(OBJECT(migrate_get_current()));
Maybe keep this one too? Just to pair with the init function.
>
> /*
> * Cancel outgoing migration of dirty bitmaps. It should
> @@ -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
>
--
Peter Xu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-12 15:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12 10:00 [PATCH] [migration] Replace current_migration with migrate_get_current() Aadeshveer Singh
2026-05-12 15:28 ` Peter Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.