diff options
author | Ashijeet Acharya <ashijeetacharya@gmail.com> | 2017-01-16 17:01:53 +0530 |
---|---|---|
committer | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2017-01-24 18:00:30 +0000 |
commit | fe44dc91807eca59d0230fe828c1e2ee0c305a1e (patch) | |
tree | ecbc1e1fd3a3052910eff44f0f6e8a84b626b199 /migration/migration.c | |
parent | a3a3d8c73889282eb696535f1b5345d88b4dc58c (diff) | |
download | qemu-fe44dc91807eca59d0230fe828c1e2ee0c305a1e.zip qemu-fe44dc91807eca59d0230fe828c1e2ee0c305a1e.tar.gz qemu-fe44dc91807eca59d0230fe828c1e2ee0c305a1e.tar.bz2 |
migration: disallow migrate_add_blocker during migration
If a migration is already in progress and somebody attempts
to add a migration blocker, this should rightly fail.
Add an errp parameter and a retcode return value to migrate_add_blocker.
Signed-off-by: John Snow <jsnow@redhat.com>
Signed-off-by: Ashijeet Acharya <ashijeetacharya@gmail.com>
Message-Id: <1484566314-3987-5-git-send-email-ashijeetacharya@gmail.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Acked-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Merged with recent 'Allow invtsc migration' change
Diffstat (limited to 'migration/migration.c')
-rw-r--r-- | migration/migration.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/migration/migration.c b/migration/migration.c index f498ab8..0d88286 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1044,6 +1044,31 @@ bool migration_in_postcopy_after_devices(MigrationState *s) return migration_in_postcopy(s) && s->postcopy_after_devices; } +bool migration_is_idle(MigrationState *s) +{ + if (!s) { + s = migrate_get_current(); + } + + switch (s->state) { + case MIGRATION_STATUS_NONE: + case MIGRATION_STATUS_CANCELLED: + case MIGRATION_STATUS_COMPLETED: + case MIGRATION_STATUS_FAILED: + return true; + case MIGRATION_STATUS_SETUP: + case MIGRATION_STATUS_CANCELLING: + case MIGRATION_STATUS_ACTIVE: + case MIGRATION_STATUS_POSTCOPY_ACTIVE: + case MIGRATION_STATUS_COLO: + return false; + case MIGRATION_STATUS__MAX: + g_assert_not_reached(); + } + + return false; +} + MigrationState *migrate_init(const MigrationParams *params) { MigrationState *s = migrate_get_current(); @@ -1086,9 +1111,17 @@ MigrationState *migrate_init(const MigrationParams *params) static GSList *migration_blockers; -void migrate_add_blocker(Error *reason) +int migrate_add_blocker(Error *reason, Error **errp) { - migration_blockers = g_slist_prepend(migration_blockers, reason); + if (migration_is_idle(NULL)) { + migration_blockers = g_slist_prepend(migration_blockers, reason); + return 0; + } + + error_propagate(errp, error_copy(reason)); + error_prepend(errp, "disallowing migration blocker (migration in " + "progress) for: "); + return -EBUSY; } void migrate_del_blocker(Error *reason) |