From patchwork Mon Nov 27 07:32:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: fangying X-Patchwork-Id: 10076069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 260FD60353 for ; Mon, 27 Nov 2017 08:22:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1347027F93 for ; Mon, 27 Nov 2017 08:22:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06C0528B4D; Mon, 27 Nov 2017 08:22:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 79F1927F93 for ; Mon, 27 Nov 2017 08:22:57 +0000 (UTC) Received: from localhost ([::1]:59669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJEgq-000505-OZ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 Nov 2017 03:22:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJEgA-0004zw-Fq for qemu-devel@nongnu.org; Mon, 27 Nov 2017 03:22:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJEg4-0002Vf-AA for qemu-devel@nongnu.org; Mon, 27 Nov 2017 03:22:14 -0500 Received: from [45.249.212.32] (port=48448 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eJEg3-0002So-U8 for qemu-devel@nongnu.org; Mon, 27 Nov 2017 03:22:08 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 568D995B0EAD8; Mon, 27 Nov 2017 15:35:16 +0800 (CST) Received: from localhost (10.177.223.127) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Mon, 27 Nov 2017 15:35:11 +0800 From: fangying To: , Date: Mon, 27 Nov 2017 15:32:33 +0800 Message-ID: <20171127073233.15376-1-fangying1@huawei.com> X-Mailer: git-send-email 2.10.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.177.223.127] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH v3] vhost: Cancel migration when vhost-user process restarted during migration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fangying , marcandre.lureau@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP QEMU will abort when vhost-user process is restarted during migration and vhost_log_global_start/stop is called. The reason is clear that vhost_dev_set_log returns -1 because network connection is temporarily lost. To handle this situation, let's cancel migration here. Signed-off-by: Ying Fang Reviewed-by: Marc-André Lureau --- hw/virtio/vhost.c | 15 +++++++++++++-- migration/migration.c | 2 +- migration/migration.h | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index ddc42f0..e2ade93 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -26,6 +26,7 @@ #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" #include "migration/blocker.h" +#include "migration/migration.h" #include "sysemu/dma.h" /* enabled until disconnected backend stabilizes */ @@ -882,20 +883,30 @@ static int vhost_migration_log(MemoryListener *listener, int enable) static void vhost_log_global_start(MemoryListener *listener) { int r; + MigrationState *s = NULL; r = vhost_migration_log(listener, true); if (r < 0) { - abort(); + error_report("Failed to start vhost dirty log"); + s = migrate_get_current(); + if (s->migration_thread_running) { + migrate_fd_cancel(s); + } } } static void vhost_log_global_stop(MemoryListener *listener) { int r; + MigrationState *s = NULL; r = vhost_migration_log(listener, false); if (r < 0) { - abort(); + error_report("Failed to stop vhost dirty log"); + s = migrate_get_current(); + if (s->migration_thread_running) { + migrate_fd_cancel(s); + } } } diff --git a/migration/migration.c b/migration/migration.c index 4de3b55..6d2b7df 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1131,7 +1131,7 @@ void migrate_fd_error(MigrationState *s, const Error *error) block_cleanup_parameters(s); } -static void migrate_fd_cancel(MigrationState *s) +void migrate_fd_cancel(MigrationState *s) { int old_state ; QEMUFile *f = migrate_get_current()->to_dst_file; diff --git a/migration/migration.h b/migration/migration.h index 663415f..f0261e3 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -167,7 +167,7 @@ uint64_t migrate_max_downtime(void); void migrate_set_error(MigrationState *s, const Error *error); void migrate_fd_error(MigrationState *s, const Error *error); - +void migrate_fd_cancel(MigrationState *s); void migrate_fd_connect(MigrationState *s); MigrationState *migrate_init(void);