From patchwork Fri Dec 1 05:58:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fangying X-Patchwork-Id: 10087523 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 D61946037E for ; Fri, 1 Dec 2017 17:09:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1ADA29211 for ; Fri, 1 Dec 2017 17:09:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5BC42A565; Fri, 1 Dec 2017 17:09:32 +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 24A0F29211 for ; Fri, 1 Dec 2017 17:09:31 +0000 (UTC) Received: from localhost ([::1]:58819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eKooc-0001RI-KG for patchwork-qemu-devel@patchwork.kernel.org; Fri, 01 Dec 2017 12:09:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eKnpa-00016K-TA for qemu-devel@nongnu.org; Fri, 01 Dec 2017 11:06:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eKnpW-00022c-UG for qemu-devel@nongnu.org; Fri, 01 Dec 2017 11:06:26 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2838) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1eKnpW-0001pw-83 for qemu-devel@nongnu.org; Fri, 01 Dec 2017 11:06:22 -0500 Received: from 172.30.72.59 (EHLO DGGEMS411-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DLQ24828; Fri, 01 Dec 2017 13:58:55 +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; Fri, 1 Dec 2017 13:58:47 +0800 From: fangying To: , Date: Fri, 1 Dec 2017 13:58:32 +0800 Message-ID: <20171201055832.8392-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-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.5A20EFA0.0020, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 40e49472166c0c366c4443e4e9fb25c9 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [PATCH v4] vhost: Don't abort when vhost-user connection is lost 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 when vhost_log_global_start/stop is called. The reason is clear that vhost_dev_set_log returns -1 because network connection is lost. To handle this situation, let's cancel migration by setting migrate state to failure and report it to user. --- hw/virtio/vhost.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index ddc42f0..92725f7 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -26,6 +26,8 @@ #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" #include "migration/blocker.h" +#include "migration/migration.h" +#include "migration/qemu-file.h" #include "sysemu/dma.h" /* enabled until disconnected backend stabilizes */ @@ -885,7 +887,10 @@ static void vhost_log_global_start(MemoryListener *listener) r = vhost_migration_log(listener, true); if (r < 0) { - abort(); + error_report("Failed to start vhost dirty log"); + if (migrate_get_current()->migration_thread_running) { + qemu_file_set_error(migrate_get_current()->to_dst_file, -ECHILD); + } } } @@ -895,7 +900,10 @@ static void vhost_log_global_stop(MemoryListener *listener) r = vhost_migration_log(listener, false); if (r < 0) { - abort(); + error_report("Failed to stop vhost dirty log"); + if (migrate_get_current()->migration_thread_running) { + qemu_file_set_error(migrate_get_current()->to_dst_file, -ECHILD); + } } }