From patchwork Tue Sep 20 14:19:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 115569 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 E94881007D1 for ; Wed, 21 Sep 2011 01:06:17 +1000 (EST) Received: from localhost ([::1]:59286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R61C1-0005qK-K6 for incoming@patchwork.ozlabs.org; Tue, 20 Sep 2011 10:21:01 -0400 Received: from eggs.gnu.org ([140.186.70.92]:39222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R61BL-0004kG-4B for qemu-devel@nongnu.org; Tue, 20 Sep 2011 10:20:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R61BC-0008Af-AT for qemu-devel@nongnu.org; Tue, 20 Sep 2011 10:20:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24344) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R61BB-0008A8-Vh for qemu-devel@nongnu.org; Tue, 20 Sep 2011 10:20:10 -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 p8KEK91j009184 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 Sep 2011 10:20:09 -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 p8KEJv9b015328; Tue, 20 Sep 2011 10:20:08 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 20 Sep 2011 16:19:36 +0200 Message-Id: <28ddda7a669bf5b384209bf93b085cb274416da8.1316526970.git.quintela@redhat.com> 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 08/23] migration: Introduce MIG_STATE_NONE 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 Use MIG_STATE_ACTIVE only when migration has really started Signed-off-by: Juan Quintela --- migration.c | 6 +++++- migration.h | 11 +++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/migration.c b/migration.c index 1d7a488..59e8f06 100644 --- a/migration.c +++ b/migration.c @@ -239,6 +239,9 @@ void do_info_migrate(Monitor *mon, QObject **ret_data) MigrationState *s = current_migration; switch (s->get_status(current_migration)) { + case MIG_STATE_NONE: + /* no migration has happened ever */ + break; case MIG_STATE_ACTIVE: qdict = qdict_new(); qdict_put(qdict, "status", qstring_from_str("active")); @@ -469,6 +472,7 @@ void migrate_fd_connect(MigrationState *s) { int ret; + s->state = MIG_STATE_ACTIVE; s->file = qemu_fopen_ops_buffered(s, s->bandwidth_limit, migrate_fd_put_buffer, @@ -499,7 +503,7 @@ static MigrationState *migrate_create_state(Monitor *mon, s->shared = inc; s->mon = NULL; s->bandwidth_limit = bandwidth_limit; - s->state = MIG_STATE_ACTIVE; + s->state = MIG_STATE_NONE; if (!detach) { migrate_fd_monitor_suspend(s, mon); diff --git a/migration.h b/migration.h index a08b5fa..b9e8a76 100644 --- a/migration.h +++ b/migration.h @@ -18,10 +18,13 @@ #include "qemu-common.h" #include "notify.h" -#define MIG_STATE_ERROR -1 -#define MIG_STATE_COMPLETED 0 -#define MIG_STATE_CANCELLED 1 -#define MIG_STATE_ACTIVE 2 +enum migration_state { + MIG_STATE_ERROR, + MIG_STATE_NONE, + MIG_STATE_CANCELLED, + MIG_STATE_ACTIVE, + MIG_STATE_COMPLETED, +}; typedef struct MigrationState MigrationState;