aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2010-05-11 15:46:39 +0200
committerJuan Quintela <quintela@redhat.com>2011-10-20 13:23:52 +0200
commitdc7acc61b67a49ce56f6a7c93692f72a3fe0759f (patch)
treef02164b4c79dd9ed5bfcf9279f1701bba6a24569
parent7be4363a2828021fd486f7f45e792aecaf909454 (diff)
migration: Use FdMigrationState instead of MigrationState when possible
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--migration.c34
-rw-r--r--migration.h16
2 files changed, 24 insertions, 26 deletions
diff --git a/migration.c b/migration.c
index 1d0c76064d..e3362b76d8 100644
--- a/migration.c
+++ b/migration.c
@@ -34,7 +34,7 @@
/* Migration speed throttling */
static int64_t max_throttle = (32 << 20);
-static MigrationState *current_migration;
+static FdMigrationState *current_migration;
static NotifierList migration_state_notifiers =
NOTIFIER_LIST_INITIALIZER(migration_state_notifiers);
@@ -87,7 +87,8 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
const char *uri = qdict_get_str(qdict, "uri");
if (current_migration &&
- current_migration->get_status(current_migration) == MIG_STATE_ACTIVE) {
+ current_migration->mig_state.get_status(current_migration) ==
+ MIG_STATE_ACTIVE) {
monitor_printf(mon, "migration already in progress\n");
return -1;
}
@@ -121,20 +122,20 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
}
if (current_migration) {
- current_migration->release(current_migration);
+ current_migration->mig_state.release(current_migration);
}
- current_migration = &s->mig_state;
+ current_migration = s;
notifier_list_notify(&migration_state_notifiers, NULL);
return 0;
}
int do_migrate_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
- MigrationState *s = current_migration;
+ FdMigrationState *s = current_migration;
- if (s && s->get_status(s) == MIG_STATE_ACTIVE) {
- s->cancel(s);
+ if (s && s->mig_state.get_status(s) == MIG_STATE_ACTIVE) {
+ s->mig_state.cancel(s);
}
return 0;
}
@@ -150,7 +151,7 @@ int do_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data)
}
max_throttle = d;
- s = migrate_to_fms(current_migration);
+ s = current_migration;
if (s && s->file) {
qemu_file_set_rate_limit(s->file, max_throttle);
}
@@ -228,10 +229,11 @@ static void migrate_put_status(QDict *qdict, const char *name,
void do_info_migrate(Monitor *mon, QObject **ret_data)
{
QDict *qdict;
- MigrationState *s = current_migration;
- if (s) {
- switch (s->get_status(s)) {
+ if (current_migration) {
+ MigrationState *s = &current_migration->mig_state;
+
+ switch (s->get_status(current_migration)) {
case MIG_STATE_ACTIVE:
qdict = qdict_new();
qdict_put(qdict, "status", qstring_from_str("active"));
@@ -404,16 +406,13 @@ void migrate_fd_put_ready(void *opaque)
}
}
-int migrate_fd_get_status(MigrationState *mig_state)
+int migrate_fd_get_status(FdMigrationState *s)
{
- FdMigrationState *s = migrate_to_fms(mig_state);
return s->state;
}
-void migrate_fd_cancel(MigrationState *mig_state)
+void migrate_fd_cancel(FdMigrationState *s)
{
- FdMigrationState *s = migrate_to_fms(mig_state);
-
if (s->state != MIG_STATE_ACTIVE)
return;
@@ -426,9 +425,8 @@ void migrate_fd_cancel(MigrationState *mig_state)
migrate_fd_cleanup(s);
}
-void migrate_fd_release(MigrationState *mig_state)
+void migrate_fd_release(FdMigrationState *s)
{
- FdMigrationState *s = migrate_to_fms(mig_state);
DPRINTF("releasing state\n");
diff --git a/migration.h b/migration.h
index 58354c7448..b10bb6e79d 100644
--- a/migration.h
+++ b/migration.h
@@ -25,18 +25,18 @@
typedef struct MigrationState MigrationState;
+typedef struct FdMigrationState FdMigrationState;
+
struct MigrationState
{
/* FIXME: add more accessors to print migration info */
- void (*cancel)(MigrationState *s);
- int (*get_status)(MigrationState *s);
- void (*release)(MigrationState *s);
+ void (*cancel)(FdMigrationState *s);
+ int (*get_status)(FdMigrationState *s);
+ void (*release)(FdMigrationState *s);
int blk;
int shared;
};
-typedef struct FdMigrationState FdMigrationState;
-
struct FdMigrationState
{
MigrationState mig_state;
@@ -120,11 +120,11 @@ void migrate_fd_connect(FdMigrationState *s);
void migrate_fd_put_ready(void *opaque);
-int migrate_fd_get_status(MigrationState *mig_state);
+int migrate_fd_get_status(FdMigrationState *mig_state);
-void migrate_fd_cancel(MigrationState *mig_state);
+void migrate_fd_cancel(FdMigrationState *mig_state);
-void migrate_fd_release(MigrationState *mig_state);
+void migrate_fd_release(FdMigrationState *mig_state);
void migrate_fd_wait_for_unfreeze(void *opaque);