qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 02/22] migration: Use FdMigrationState instead o


From: Yoshiaki Tamura
Subject: Re: [Qemu-devel] [PATCH 02/22] migration: Use FdMigrationState instead of MigrationState when possible
Date: Wed, 23 Feb 2011 18:19:20 +0900

2011/2/23 Juan Quintela <address@hidden>:
> Signed-off-by: Juan Quintela <address@hidden>
> ---
>  migration.c |   31 ++++++++++++++-----------------
>  migration.h |   16 ++++++++--------
>  2 files changed, 22 insertions(+), 25 deletions(-)
>
> diff --git a/migration.c b/migration.c
> index f9aaadc..3a371a3 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);
> @@ -86,7 +86,7 @@ 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;
>     }
> @@ -120,20 +120,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);
>     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->cancel(s);
> +        s->mig_state.cancel(s);
>
>     return 0;
>  }
> @@ -149,7 +149,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);
>     }
> @@ -227,10 +227,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"));
> @@ -399,16 +400,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;
>
> @@ -421,9 +419,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 db0e45a..f49a9e2 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);
>

Looks good to me.

Yoshi

> --
> 1.7.4
>
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]