From patchwork Fri Aug 3 09:13:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 858585 jemmy X-Patchwork-Id: 10554813 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C757014E2 for ; Fri, 3 Aug 2018 09:19:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFC392C1F3 for ; Fri, 3 Aug 2018 09:19:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1ECD2C1FC; Fri, 3 Aug 2018 09:19:24 +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.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 A29412C1F3 for ; Fri, 3 Aug 2018 09:19:23 +0000 (UTC) Received: from localhost ([::1]:49760 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1flWF0-0005n8-PG for patchwork-qemu-devel@patchwork.kernel.org; Fri, 03 Aug 2018 05:19:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1flWA5-0001Yd-R2 for qemu-devel@nongnu.org; Fri, 03 Aug 2018 05:14:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1flWA4-0001lZ-Ne for qemu-devel@nongnu.org; Fri, 03 Aug 2018 05:14:17 -0400 Received: from mail-pl0-x231.google.com ([2607:f8b0:400e:c01::231]:45562) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1flWA4-0001jy-Gu for qemu-devel@nongnu.org; Fri, 03 Aug 2018 05:14:16 -0400 Received: by mail-pl0-x231.google.com with SMTP id j8-v6so2292912pll.12 for ; Fri, 03 Aug 2018 02:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tmaMPgA/4D3Vt0rma7Rf6cf1XnX0c3yLSjIs9mPFLn8=; b=ETbNHjT5QnxDAAQycXz/kyJ2qIUj5yYcU3lgeRp2SLb8ZKyDr3Qv+WJdX5O+yW+lPu 7Pn2aat9CMRRkOnS+Ht3QuK9PFh+tyXTnqhVeCdfCr6vtsopZOGSQ4xzQjYIpFJ8AL8P qH4HzlPCSAEBSNk/6lsNNxPWAY1hkSfKOyRgpb/nB80IQX5ZYCXEFNX5RttELj39gcFQ GF7COtYJ9pbSyvml4fuDca6x0FV4LD/N38KVq5epeRJm7aIXvZa+Lyn12THgA/g6YrTC gLsDsPIYDtwFcR0Ap1+woPMTgJTjFaZ6XQyIpSHcItIscYoydHRUHb2wH3RVwjwaGLdS bsqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tmaMPgA/4D3Vt0rma7Rf6cf1XnX0c3yLSjIs9mPFLn8=; b=iFubsy98GsvxbgW/kSooUlpEfE4t+VUDyehAuWhJiCcmfugFgsHBFIxWCIG7RVDI3f QcAPBTmUT/Ti0ccaCcqQVX/UM3KJfZe/FDVBKBZvzUfGe0h44n+LRT7OFuxosbGl4Ctg r5Fsk/ZiHOvQTMyS3EBhe5mg+1kaixvdPc2yxQNfjYdPCysaUv2HvBD4vCobDRs8j4iS +lWdFzaphxCx67FyemJK+/n9B8PawuN5wHKLjIo4G3t2dCPp333zFXKLopKMep1yopy5 zJ2XJccCzNHz4S/iktAjQLG0DTxivunf+SXbe+djhln0oqh4b6lWcwxou5GT3nyhZ0LZ f+qQ== X-Gm-Message-State: AOUpUlGuklsIDlXHs9gqgzP0+uO+49xuj32MPBSGBHWcUxn3gC3F0gqN UpzKYzFiDXq5n1pgG8CFrRw= X-Google-Smtp-Source: AAOMgpeR82VFRCs2qWiL5bxge6ZUbpprXqx7dsw7xa3dlWYLHY6C06If3LY/1q3xK6acGpcg9lF4iQ== X-Received: by 2002:a17:902:8b86:: with SMTP id ay6-v6mr2690224plb.25.1533287655772; Fri, 03 Aug 2018 02:14:15 -0700 (PDT) Received: from VM_120_46_centos.localdomain ([119.28.87.64]) by smtp.gmail.com with ESMTPSA id e21-v6sm7991352pfl.187.2018.08.03.02.14.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Aug 2018 02:14:15 -0700 (PDT) From: Lidong Chen X-Google-Original-From: Lidong Chen To: zhang.zhanghailiang@huawei.com, quintela@redhat.com, dgilbert@redhat.com Date: Fri, 3 Aug 2018 17:13:48 +0800 Message-Id: <1533287630-4221-11-git-send-email-lidongchen@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1533287630-4221-1-git-send-email-lidongchen@tencent.com> References: <1533287630-4221-1-git-send-email-lidongchen@tencent.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::231 Subject: [Qemu-devel] [PATCH v6 10/12] migration: poll the cm event for destination qemu 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: qemu-devel@nongnu.org, Lidong Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The destination qemu only poll the comp_channel->fd in qemu_rdma_wait_comp_channel. But when source qemu disconnnect the rdma connection, the destination qemu should be notified. Signed-off-by: Lidong Chen --- migration/migration.c | 3 ++- migration/rdma.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index f190964..360ee94 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -389,6 +389,7 @@ static void process_incoming_migration_co(void *opaque) int ret; assert(mis->from_src_file); + mis->migration_incoming_co = qemu_coroutine_self(); mis->largest_page_size = qemu_ram_pagesize_largest(); postcopy_state_set(POSTCOPY_INCOMING_NONE); migrate_set_state(&mis->state, MIGRATION_STATUS_NONE, @@ -418,7 +419,6 @@ static void process_incoming_migration_co(void *opaque) /* we get COLO info, and know if we are in COLO mode */ if (!ret && migration_incoming_enable_colo()) { - mis->migration_incoming_co = qemu_coroutine_self(); qemu_thread_create(&mis->colo_incoming_thread, "COLO incoming", colo_process_incoming_thread, mis, QEMU_THREAD_JOINABLE); mis->have_colo_incoming_thread = true; @@ -442,6 +442,7 @@ static void process_incoming_migration_co(void *opaque) } mis->bh = qemu_bh_new(process_incoming_migration_bh, mis); qemu_bh_schedule(mis->bh); + mis->migration_incoming_co = NULL; } static void migration_incoming_setup(QEMUFile *f) diff --git a/migration/rdma.c b/migration/rdma.c index 1affc46..62de2ec 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3226,6 +3226,34 @@ err: static void rdma_accept_incoming_migration(void *opaque); +static void rdma_cm_poll_handler(void *opaque) +{ + RDMAContext *rdma = opaque; + int ret; + struct rdma_cm_event *cm_event; + MigrationIncomingState *mis = migration_incoming_get_current(); + + ret = rdma_get_cm_event(rdma->channel, &cm_event); + if (ret) { + return; + } + + if (cm_event->event == RDMA_CM_EVENT_DISCONNECTED || + cm_event->event == RDMA_CM_EVENT_DEVICE_REMOVAL) { + rdma_ack_cm_event(cm_event); + error_report("receive cm event, cm event is %d", cm_event->event); + rdma->error_state = -EPIPE; + if (rdma->return_path) { + rdma->return_path->error_state = -EPIPE; + } + + if (mis->migration_incoming_co) { + qemu_coroutine_enter(mis->migration_incoming_co); + } + return; + } +} + static int qemu_rdma_accept(RDMAContext *rdma) { RDMACapabilities cap; @@ -3326,7 +3354,8 @@ static int qemu_rdma_accept(RDMAContext *rdma) NULL, (void *)(intptr_t)rdma->return_path); } else { - qemu_set_fd_handler(rdma->channel->fd, NULL, NULL, NULL); + qemu_set_fd_handler(rdma->channel->fd, rdma_cm_poll_handler, + NULL, rdma); } ret = rdma_accept(rdma->cm_id, &conn_param);