From patchwork Tue Oct 18 01:29:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 120350 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 B99EDB70C0 for ; Tue, 18 Oct 2011 12:30:04 +1100 (EST) Received: from localhost ([::1]:55855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFyVD-0005vQ-DP for incoming@patchwork.ozlabs.org; Mon, 17 Oct 2011 21:29:59 -0400 Received: from eggs.gnu.org ([140.186.70.92]:53609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFyV6-0005v6-To for qemu-devel@nongnu.org; Mon, 17 Oct 2011 21:29:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RFyV5-0007Nd-5e for qemu-devel@nongnu.org; Mon, 17 Oct 2011 21:29:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFyV4-0007NR-SS for qemu-devel@nongnu.org; Mon, 17 Oct 2011 21:29:51 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9I1TmRc005583 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 17 Oct 2011 21:29:48 -0400 Received: from localhost (ovpn-116-20.ams2.redhat.com [10.36.116.20]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9I1TkFC001858; Mon, 17 Oct 2011 21:29:47 -0400 From: Juan Quintela To: Anthony Liguori In-Reply-To: <4E9C35BC.4030003@codemonkey.ws> (Anthony Liguori's message of "Mon, 17 Oct 2011 09:03:40 -0500") References: <336a3c5cc754339152f09baa96788f1b00b706f9.1318326684.git.quintela@redhat.com> <4E9C35BC.4030003@codemonkey.ws> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Date: Tue, 18 Oct 2011 03:29:46 +0200 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH 22/36] migration: Introduce MIG_STATE_SETUP X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: quintela@redhat.com 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 Anthony Liguori wrote: > On 10/11/2011 05:00 AM, Juan Quintela wrote: > CODING_STYLE. > > Regards, > > Anthony Liguori Attached v2 of this patch. Only change is s/enum migration_state/enum/ From 990ccd38f0ff916ada859d28831b2be63983c309 Mon Sep 17 00:00:00 2001 Message-Id: <990ccd38f0ff916ada859d28831b2be63983c309.1318901257.git.quintela@redhat.com> In-Reply-To: References: From: Juan Quintela Date: Tue, 11 May 2010 23:01:53 +0200 Subject: [PATCH 22/36] migration: Introduce MIG_STATE_SETUP Use MIG_STATE_ACTIVE only when migration has really started. Use this new state to setup migration parameters. Change defines for an anonymous struct. 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 e93f3f7..a01bf4f 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_SETUP: + /* no migration has happened ever */ + break; case MIG_STATE_ACTIVE: qdict = qdict_new(); qdict_put(qdict, "status", qstring_from_str("active")); @@ -478,6 +481,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, @@ -507,7 +511,7 @@ static MigrationState *migrate_new(Monitor *mon, int64_t bandwidth_limit, s->shared = inc; s->mon = NULL; s->bandwidth_limit = bandwidth_limit; - s->state = MIG_STATE_ACTIVE; + s->state = MIG_STATE_SETUP; if (!detach) { migrate_fd_monitor_suspend(s, mon); diff --git a/migration.h b/migration.h index 14c3ebc..fed1cf1 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 { + MIG_STATE_ERROR, + MIG_STATE_SETUP, + MIG_STATE_CANCELLED, + MIG_STATE_ACTIVE, + MIG_STATE_COMPLETED, +}; typedef struct MigrationState MigrationState;