From patchwork Tue Sep 20 14:19:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 115597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9C453B70C3 for ; Wed, 21 Sep 2011 02:16:02 +1000 (EST) Received: from localhost ([::1]:58012 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R61Bg-0005CX-UX for incoming@patchwork.ozlabs.org; Tue, 20 Sep 2011 10:20:40 -0400 Received: from eggs.gnu.org ([140.186.70.92]:39143) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R61BC-0004SS-8v for qemu-devel@nongnu.org; Tue, 20 Sep 2011 10:20:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R61B5-000856-67 for qemu-devel@nongnu.org; Tue, 20 Sep 2011 10:20:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R61B4-000850-Qz for qemu-devel@nongnu.org; Tue, 20 Sep 2011 10:20:03 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8KEK1CS031665 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 Sep 2011 10:20:02 -0400 Received: from trasno.mitica (ovpn-113-56.phx2.redhat.com [10.3.113.56]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p8KEJv9V015328; Tue, 20 Sep 2011 10:20:01 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 20 Sep 2011 16:19:30 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 02/23] migration: Use FdMigrationState instead of MigrationState when possible X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Juan Quintela --- migration.c | 34 ++++++++++++++++------------------ migration.h | 16 ++++++++-------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/migration.c b/migration.c index 1a5e25f..007b162 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,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; } @@ -120,20 +121,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; } @@ -149,7 +150,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 +228,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 = ¤t_migration->mig_state; + + switch (s->get_status(current_migration)) { case MIG_STATE_ACTIVE: qdict = qdict_new(); qdict_put(qdict, "status", qstring_from_str("active")); @@ -398,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; @@ -420,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 0591e82..bbcdefb 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);