From patchwork Mon Mar 24 13:04:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 333054 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5E6E0140099 for ; Tue, 25 Mar 2014 00:49:14 +1100 (EST) Received: from localhost ([::1]:36439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS5FY-0000q9-Dk for incoming@patchwork.ozlabs.org; Mon, 24 Mar 2014 09:49:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS5Et-0007CS-Lv for qemu-devel@nongnu.org; Mon, 24 Mar 2014 09:48:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WS58k-00074K-Nq for qemu-devel@nongnu.org; Mon, 24 Mar 2014 09:42:17 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:16217) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS4ZO-0005h7-Bo for qemu-devel@nongnu.org; Mon, 24 Mar 2014 09:05:39 -0400 Received: from 172.24.2.119 (EHLO szxeml207-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BRM91498; Mon, 24 Mar 2014 21:04:54 +0800 (CST) Received: from SZXEML407-HUB.china.huawei.com (10.82.67.94) by szxeml207-edg.china.huawei.com (172.24.2.56) with Microsoft SMTP Server (TLS) id 14.3.158.1; Mon, 24 Mar 2014 21:04:51 +0800 Received: from localhost (10.177.19.102) by szxeml407-hub.china.huawei.com (10.82.67.94) with Microsoft SMTP Server id 14.3.158.1; Mon, 24 Mar 2014 21:04:44 +0800 From: To: Date: Mon, 24 Mar 2014 21:04:24 +0800 Message-ID: <1395666264-12060-1-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 1.7.3.1.msysgit.0 MIME-Version: 1.0 X-Originating-IP: [10.177.19.102] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Cc: quintela@redhat.com, yanqiangjun@huawei.com, lefty.zhao@huawei.com, owasserm@redhat.com, Gonglei , zengjunliang , pbonzini@redhat.com Subject: [Qemu-devel] [PATCH] migration: Fix possible bug for migrate cancel 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 From: zengjunliang Return error for migrate cancel, when migration status is not MIG_STATE_SETUP or MIG_STATE_ACTIVE. Thus, libvirt can can perceive the operation fails. Signed-off-by: zengjunliang Signed-off-by: Gonglei --- include/qapi/qmp/qerror.h | 3 +++ migration.c | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index da75abf..b13e3e0 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -164,6 +164,9 @@ void qerror_report_err(Error *err); #define QERR_MIGRATION_ACTIVE \ ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress" +#define QERR_MIGRATION_COMPLETED \ + ERROR_CLASS_GENERIC_ERROR, "There's no migration process in progress" + #define QERR_MIGRATION_NOT_SUPPORTED \ ERROR_CLASS_GENERIC_ERROR, "State blocked by non-migratable device '%s'" diff --git a/migration.c b/migration.c index e0e24d4..2f34c67 100644 --- a/migration.c +++ b/migration.c @@ -336,7 +336,7 @@ void migrate_fd_error(MigrationState *s) notifier_list_notify(&migration_state_notifiers, s); } -static void migrate_fd_cancel(MigrationState *s) +static void migrate_fd_cancel(MigrationState *s, Error **errp) { int old_state ; DPRINTF("cancelling migration\n"); @@ -344,6 +344,7 @@ static void migrate_fd_cancel(MigrationState *s) do { old_state = s->state; if (old_state != MIG_STATE_SETUP && old_state != MIG_STATE_ACTIVE) { + error_set(errp, QERR_MIGRATION_COMPLETED); break; } migrate_set_state(s, old_state, MIG_STATE_CANCELLING); @@ -470,7 +471,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, void qmp_migrate_cancel(Error **errp) { - migrate_fd_cancel(migrate_get_current()); + migrate_fd_cancel(migrate_get_current(), errp); } void qmp_migrate_set_cache_size(int64_t value, Error **errp)