From afe2df69cf9305b195d96afc545d3fefc0fb5f5d Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 25 Oct 2011 13:50:11 +0200 Subject: [PATCH] migration: add status query functions Add migration_is_active and migration_has_failed functions to query migration state. Signed-off-by: Gerd Hoffmann --- migration.c | 11 +++++++++++ migration.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/migration.c b/migration.c index bdca72e008..d6935678b9 100644 --- a/migration.c +++ b/migration.c @@ -372,11 +372,22 @@ void remove_migration_state_change_notifier(Notifier *notify) notifier_list_remove(&migration_state_notifiers, notify); } +bool migration_is_active(MigrationState *s) +{ + return s->state == MIG_STATE_ACTIVE; +} + bool migration_has_finished(MigrationState *s) { return s->state == MIG_STATE_COMPLETED; } +bool migration_has_failed(MigrationState *s) +{ + return (s->state == MIG_STATE_CANCELLED || + s->state == MIG_STATE_ERROR); +} + void migrate_fd_connect(MigrationState *s) { int ret; diff --git a/migration.h b/migration.h index a1f80d0728..1b8ee58530 100644 --- a/migration.h +++ b/migration.h @@ -76,7 +76,9 @@ void migrate_fd_connect(MigrationState *s); void add_migration_state_change_notifier(Notifier *notify); void remove_migration_state_change_notifier(Notifier *notify); +bool migration_is_active(MigrationState *); bool migration_has_finished(MigrationState *); +bool migration_has_failed(MigrationState *); uint64_t ram_bytes_remaining(void); uint64_t ram_bytes_transferred(void);