From patchwork Thu Feb 11 01:49:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 45092 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7FA26B6F08 for ; Thu, 11 Feb 2010 13:12:00 +1100 (EST) Received: from localhost ([127.0.0.1]:37381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfOWx-0002gJ-7H for incoming@patchwork.ozlabs.org; Wed, 10 Feb 2010 21:11:47 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NfOCb-000700-Td for qemu-devel@nongnu.org; Wed, 10 Feb 2010 20:50:45 -0500 Received: from [199.232.76.173] (port=57743 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfOCa-0006yu-JL for qemu-devel@nongnu.org; Wed, 10 Feb 2010 20:50:44 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NfOCY-0001Iv-Vz for qemu-devel@nongnu.org; Wed, 10 Feb 2010 20:50:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:9275) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NfOCY-0001IW-Bn for qemu-devel@nongnu.org; Wed, 10 Feb 2010 20:50:42 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1B1of6p014840 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 10 Feb 2010 20:50:41 -0500 Received: from localhost (vpn-10-105.rdu.redhat.com [10.11.10.105]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1B1od6l011516; Wed, 10 Feb 2010 20:50:40 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 10 Feb 2010 23:49:57 -0200 Message-Id: <1265853007-27300-12-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1265853007-27300-1-git-send-email-lcapitulino@redhat.com> References: <1265853007-27300-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: armbru@redhat.com Subject: [Qemu-devel] [PATCH 11/21] Monitor: Convert do_migrate() to cmd_new_ret() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org While there I'm also dropping a unneeded else clause (the last one in the function). Signed-off-by: Luiz Capitulino --- migration.c | 29 +++++++++++++++++------------ migration.h | 2 +- qemu-monitor.hx | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/migration.c b/migration.c index 557bec4..05f6cc5 100644 --- a/migration.c +++ b/migration.c @@ -54,7 +54,7 @@ void qemu_start_incoming_migration(const char *uri) fprintf(stderr, "unknown migration protocol: %s\n", uri); } -void do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) +int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) { MigrationState *s = NULL; const char *p; @@ -64,38 +64,43 @@ void do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) if (current_migration && current_migration->get_status(current_migration) == MIG_STATE_ACTIVE) { monitor_printf(mon, "migration already in progress\n"); - return; + return -1; } - if (strstart(uri, "tcp:", &p)) + if (strstart(uri, "tcp:", &p)) { s = tcp_start_outgoing_migration(mon, p, max_throttle, detach, (int)qdict_get_int(qdict, "blk"), (int)qdict_get_int(qdict, "inc")); #if !defined(WIN32) - else if (strstart(uri, "exec:", &p)) + } else if (strstart(uri, "exec:", &p)) { s = exec_start_outgoing_migration(mon, p, max_throttle, detach, (int)qdict_get_int(qdict, "blk"), (int)qdict_get_int(qdict, "inc")); - else if (strstart(uri, "unix:", &p)) + } else if (strstart(uri, "unix:", &p)) { s = unix_start_outgoing_migration(mon, p, max_throttle, detach, (int)qdict_get_int(qdict, "blk"), (int)qdict_get_int(qdict, "inc")); - else if (strstart(uri, "fd:", &p)) + } else if (strstart(uri, "fd:", &p)) { s = fd_start_outgoing_migration(mon, p, max_throttle, detach, (int)qdict_get_int(qdict, "blk"), (int)qdict_get_int(qdict, "inc")); #endif - else + } else { monitor_printf(mon, "unknown migration protocol: %s\n", uri); + return -1; + } - if (s == NULL) + if (s == NULL) { monitor_printf(mon, "migration failed\n"); - else { - if (current_migration) - current_migration->release(current_migration); + return -1; + } - current_migration = s; + if (current_migration) { + current_migration->release(current_migration); } + + current_migration = s; + return 0; } int do_migrate_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data) diff --git a/migration.h b/migration.h index 9345d97..385423f 100644 --- a/migration.h +++ b/migration.h @@ -52,7 +52,7 @@ struct FdMigrationState void qemu_start_incoming_migration(const char *uri); -void do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data); +int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_migrate_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data); diff --git a/qemu-monitor.hx b/qemu-monitor.hx index e987cf1..3a1f9bc 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -773,7 +773,7 @@ ETEXI "shared storage with incremental copy of disk " "(base image shared between src and destination)", .user_print = monitor_user_noop, - .mhandler.cmd_new = do_migrate, + .cmd_new_ret = do_migrate, },