From patchwork Sat Apr 21 07:22:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Xin X-Patchwork-Id: 10354009 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 B3A73602B7 for ; Sat, 21 Apr 2018 08:09:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97DB0288C3 for ; Sat, 21 Apr 2018 08:09:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89AC3288F4; Sat, 21 Apr 2018 08:09:27 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 C8E55288C3 for ; Sat, 21 Apr 2018 08:09:26 +0000 (UTC) Received: from localhost ([::1]:51382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9naF-0007xD-OV for patchwork-qemu-devel@patchwork.kernel.org; Sat, 21 Apr 2018 04:09:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9nZb-0007X8-1L for qemu-devel@nongnu.org; Sat, 21 Apr 2018 04:08:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9nZW-0004LE-WB for qemu-devel@nongnu.org; Sat, 21 Apr 2018 04:08:42 -0400 Received: from [45.249.212.35] (port=34199 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9nZW-0004IB-KM for qemu-devel@nongnu.org; Sat, 21 Apr 2018 04:08:38 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0E63DC306CB93; Sat, 21 Apr 2018 15:22:22 +0800 (CST) Received: from localhost (10.177.218.69) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.361.1; Sat, 21 Apr 2018 15:22:14 +0800 From: Wang Xin To: Date: Sat, 21 Apr 2018 15:22:05 +0800 Message-ID: <1524295325-18136-1-git-send-email-wangxinxin.wang@huawei.com> X-Mailer: git-send-email 2.8.1.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.177.218.69] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 45.249.212.35 Subject: [Qemu-devel] [PATCH] migration/fd: abort migration if receive POLLHUP event 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: Wang Xin , arei.gonglei@huawei.com, dgilbert@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 If the fd socket peer closed shortly, ppoll may receive a POLLHUP event before the expected POLLIN event, and qemu will do nothing but goes into an infinite loop of the POLLHUP event. So, abort the migration if we receive a POLLHUP event. Signed-off-by: Wang Xin diff --git a/migration/fd.c b/migration/fd.c index cd06182..5932c87 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -15,6 +15,7 @@ */ #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "channel.h" #include "fd.h" #include "monitor/monitor.h" @@ -46,6 +47,11 @@ static gboolean fd_accept_incoming_migration(QIOChannel *ioc, GIOCondition condition, gpointer opaque) { + if (condition & G_IO_HUP) { + error_report("The migration peer closed, job abort"); + exit(EXIT_FAILURE); + } + migration_channel_process_incoming(ioc); object_unref(OBJECT(ioc)); return G_SOURCE_REMOVE; @@ -67,7 +73,7 @@ void fd_start_incoming_migration(const char *infd, Error **errp) qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-incoming"); qio_channel_add_watch(ioc, - G_IO_IN, + G_IO_IN | G_IO_HUP, fd_accept_incoming_migration, NULL, NULL);