X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=migration%2Fmigration.c;h=2865ae3fa94884a1ad9890711e7373d2e55a70fa;hb=c4107e8208d0222f9b328691b519aaee4101db87;hp=4844ad438bdab8fb81e4175b365075d209f5d880;hpb=15d2d64cf58dcf666a07a695c0c4ec307da8f2ae;p=mirror_qemu.git diff --git a/migration/migration.c b/migration/migration.c index 4844ad438b..2865ae3fa9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1495,10 +1495,8 @@ static void block_cleanup_parameters(MigrationState *s) } } -static void migrate_fd_cleanup(void *opaque) +static void migrate_fd_cleanup(MigrationState *s) { - MigrationState *s = opaque; - qemu_bh_delete(s->cleanup_bh); s->cleanup_bh = NULL; @@ -1543,6 +1541,23 @@ static void migrate_fd_cleanup(void *opaque) block_cleanup_parameters(s); } +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; + migrate_fd_cleanup(s); + object_unref(OBJECT(s)); +} + void migrate_set_error(MigrationState *s, const Error *error) { qemu_mutex_lock(&s->error_mutex); @@ -1713,7 +1728,7 @@ int migrate_add_blocker(Error *reason, Error **errp) if (only_migratable) { error_propagate_prepend(errp, error_copy(reason), "disallowing migration blocker " - "(--only_migratable) for: "); + "(--only-migratable) for: "); return -EACCES; } @@ -3143,7 +3158,7 @@ static void migration_iteration_finish(MigrationState *s) error_report("%s: Unknown ending state %d", __func__, s->state); break; } - qemu_bh_schedule(s->cleanup_bh); + migrate_fd_cleanup_schedule(s); qemu_mutex_unlock_iothread(); } @@ -3278,7 +3293,7 @@ void migrate_fd_connect(MigrationState *s, Error *error_in) bool resume = s->state == MIGRATION_STATUS_POSTCOPY_PAUSED; s->expected_downtime = s->parameters.downtime_limit; - s->cleanup_bh = qemu_bh_new(migrate_fd_cleanup, s); + s->cleanup_bh = qemu_bh_new(migrate_fd_cleanup_bh, s); if (error_in) { migrate_fd_error(s, error_in); migrate_fd_cleanup(s);