diff options
author | Juan Quintela <quintela@redhat.com> | 2010-05-11 16:28:39 +0200 |
---|---|---|
committer | Juan Quintela <quintela@redhat.com> | 2011-10-20 13:23:53 +0200 |
commit | 0edda1c42aa49dd3207f3c76bf25fd53ac16345d (patch) | |
tree | 17cfe4f206517d2fc9ded42b4b8c11cd2d28b16f /migration.c | |
parent | 22f00a4445fac68b10d1cb669836eeb8d32af56d (diff) |
migration: Refactor MigrationState creation
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'migration.c')
-rw-r--r-- | migration.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/migration.c b/migration.c index daf3ef6328..78d0f6116e 100644 --- a/migration.c +++ b/migration.c @@ -263,7 +263,7 @@ void do_info_migrate(Monitor *mon, QObject **ret_data) /* shared migration helpers */ -void migrate_fd_monitor_suspend(MigrationState *s, Monitor *mon) +static void migrate_fd_monitor_suspend(MigrationState *s, Monitor *mon) { s->mon = mon; if (monitor_suspend(mon) == 0) { @@ -404,12 +404,12 @@ void migrate_fd_put_ready(void *opaque) } } -int migrate_fd_get_status(MigrationState *s) +static int migrate_fd_get_status(MigrationState *s) { return s->state; } -void migrate_fd_cancel(MigrationState *s) +static void migrate_fd_cancel(MigrationState *s) { if (s->state != MIG_STATE_ACTIVE) return; @@ -423,7 +423,7 @@ void migrate_fd_cancel(MigrationState *s) migrate_fd_cleanup(s); } -void migrate_fd_release(MigrationState *s) +static void migrate_fd_release(MigrationState *s) { DPRINTF("releasing state\n"); @@ -488,3 +488,24 @@ int get_migration_state(void) return MIG_STATE_ERROR; } } + +MigrationState *migrate_new(Monitor *mon, int64_t bandwidth_limit, + int detach, int blk, int inc) +{ + MigrationState *s = g_malloc0(sizeof(*s)); + + s->cancel = migrate_fd_cancel; + s->get_status = migrate_fd_get_status; + s->release = migrate_fd_release; + s->blk = blk; + s->shared = inc; + s->mon = NULL; + s->bandwidth_limit = bandwidth_limit; + s->state = MIG_STATE_ACTIVE; + + if (!detach) { + migrate_fd_monitor_suspend(s, mon); + } + + return s; +} |