[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/15] migration: Add a wrapper to qemu_bh_schedule
From: |
peterx |
Subject: |
[PULL 13/15] migration: Add a wrapper to qemu_bh_schedule |
Date: |
Fri, 26 Jan 2024 12:17:23 +0800 |
From: Fabiano Rosas <farosas@suse.de>
Wrap qemu_bh_schedule() to ensure we always hold a reference to the
current_migration object.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Link: 20240119233922.32588-5-farosas@suse.de">https://lore.kernel.org/r/20240119233922.32588-5-farosas@suse.de
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/migration.c | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index b1213b59ce..0e7f101d64 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -199,6 +199,16 @@ void migration_object_init(void)
dirty_bitmap_mig_init();
}
+static void migration_bh_schedule(MigrationState *s, QEMUBH *bh)
+{
+ /*
+ * Ref the state for bh, because it may be called when
+ * there're already no other refs
+ */
+ object_ref(OBJECT(s));
+ qemu_bh_schedule(bh);
+}
+
void migration_cancel(const Error *error)
{
if (error) {
@@ -714,8 +724,7 @@ process_incoming_migration_co(void *opaque)
}
mis->bh = qemu_bh_new(process_incoming_migration_bh, mis);
- object_ref(OBJECT(migrate_get_current()));
- qemu_bh_schedule(mis->bh);
+ migration_bh_schedule(migrate_get_current(), mis->bh);
return;
fail:
migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
@@ -1332,16 +1341,6 @@ static void migrate_fd_cleanup(MigrationState *s)
yank_unregister_instance(MIGRATION_YANK_INSTANCE);
}
-static void migrate_fd_cleanup_schedule(MigrationState *s)
-{
- /*
- * Ref the state for bh, because it may be called when
- * there're already no other refs
- */
- object_ref(OBJECT(s));
- qemu_bh_schedule(s->cleanup_bh);
-}
-
static void migrate_fd_cleanup_bh(void *opaque)
{
MigrationState *s = opaque;
@@ -3140,7 +3139,7 @@ static void migration_iteration_finish(MigrationState *s)
error_report("%s: Unknown ending state %d", __func__, s->state);
break;
}
- migrate_fd_cleanup_schedule(s);
+ migration_bh_schedule(s, s->cleanup_bh);
bql_unlock();
}
@@ -3171,7 +3170,7 @@ static void bg_migration_iteration_finish(MigrationState
*s)
break;
}
- migrate_fd_cleanup_schedule(s);
+ migration_bh_schedule(s, s->cleanup_bh);
bql_unlock();
}
@@ -3487,9 +3486,7 @@ static void *bg_migration_thread(void *opaque)
* writes to virtio VQs memory which is in write-protected region.
*/
s->vm_start_bh = qemu_bh_new(bg_migration_vm_start_bh, s);
- object_ref(OBJECT(s));
- qemu_bh_schedule(s->vm_start_bh);
-
+ migration_bh_schedule(s, s->vm_start_bh);
bql_unlock();
while (migration_is_active(s)) {
--
2.43.0
- Re: [PULL 06/15] tests/qtest/migration: Don't use -cpu max for aarch64, (continued)
[PULL 07/15] ci: Add a migration compatibility test job, peterx, 2024/01/25
[PULL 08/15] ci: Disable migration compatibility tests for aarch64, peterx, 2024/01/25
[PULL 09/15] migration/yank: Use channel features, peterx, 2024/01/25
[PULL 10/15] migration: Fix use-after-free of migration state object, peterx, 2024/01/25
[PULL 11/15] migration: Take reference to migration state around bg_migration_vm_start_bh, peterx, 2024/01/25
[PULL 12/15] migration: Reference migration state around loadvm_postcopy_handle_run_bh, peterx, 2024/01/25
[PULL 14/15] migration: Centralize BH creation and dispatch, peterx, 2024/01/25
[PULL 13/15] migration: Add a wrapper to qemu_bh_schedule,
peterx <=
[PULL 15/15] Make 'uri' optional for migrate QAPI, peterx, 2024/01/25
Re: [PULL 00/15] Migration 20240126 patches, Peter Maydell, 2024/01/26