From patchwork Mon Aug 6 13:29:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 858585 jemmy X-Patchwork-Id: 10557141 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 3D8B9157B for ; Mon, 6 Aug 2018 13:31:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BFEC29529 for ; Mon, 6 Aug 2018 13:31:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 202FF2952B; Mon, 6 Aug 2018 13:31:37 +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 B860C29529 for ; Mon, 6 Aug 2018 13:31:36 +0000 (UTC) Received: from localhost ([::1]:34115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmfbj-0003Ld-TU for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Aug 2018 09:31:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmfa9-0003JC-0q for qemu-devel@nongnu.org; Mon, 06 Aug 2018 09:29:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmfa7-0008Gt-WA for qemu-devel@nongnu.org; Mon, 06 Aug 2018 09:29:57 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:45777) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmfa7-0008Gl-Oz for qemu-devel@nongnu.org; Mon, 06 Aug 2018 09:29:55 -0400 Received: by mail-pg1-x536.google.com with SMTP id f1-v6so6224119pgq.12 for ; Mon, 06 Aug 2018 06:29:55 -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=V6VZn/TLDJ0rcpWXxTwI8ayG4VlrvGWwAP//SDZcvS8=; b=Hrp62WMmoXHqXZ8Y3igaW83kYSNRL0LNViqNYoTzZaaXGNnGeOPY/GSJoZkUqzovFa MlISneU/Jbgoa0lReBvIzmuWqAJBxsZc207JPGaXZOD1d+smhWQmkm3bZzPWzPb7FL/q OLuHA93CGFTHiytZ0+aQ81+Bt16oAQYGNyOuXEcoDAab4UfUvOrbzllGg9MmATX6io1M hc3R9L4HYzrajFz1icwuezDuvfns2om+f0CsKjikxBs/0fZRcXEsZuhBNmeVITRVHfmH xxQYboDNcHkeP2hmpKqaai3mLWwuCGhZvlALXKyXCnW+6xLDtWyLYFRvb9Pvpq2Wowf6 jaUA== 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=V6VZn/TLDJ0rcpWXxTwI8ayG4VlrvGWwAP//SDZcvS8=; b=Eh06mBip5tPbjw3HRXdNctsz02TNvvxEF/ElVyxpMvU1+0crUbb6KPkJ89QYS6EJro M4JFArLgzl0VNGsq6nMDZXGZmMT02JoVtZJSmOZqrBfh2kFJ7tO6sbvwio1sB/mpZdCL cav42EpH3pKLPNAaZmZXsYnBJhwQ9hAQHPd6di0GiNvhKqQ5mFLW6Y1i4iYAL39PQLnQ 3vwXZDSQ069ZPHehkem7Z+8kYF6ANHee8qqvxUUWMtVqG7ZgrFxgZuqVwHbK8KXOG4hy 6lb76NuS9DUZ7CLyFRlLGZxX1h+oDmi+6H04hfLFaGccysWXMBhqdNibXKijgHLmUCYA pPUQ== X-Gm-Message-State: AOUpUlFiVYnEGLvKr445UnkzuNtM1XcPbOjTsyr1cyWvJ3qy5FGac+h/ Qte+YnmB6AQjAtUp+1ao1UqfqgM5H2U= X-Google-Smtp-Source: AAOMgpcPi9cu2pcWPnyzuVsXWSbf6OO60tss2r5TQwwtnMy0IGhD59ZGu5xyAbx9wR2T1WWVjE2axA== X-Received: by 2002:a62:aa02:: with SMTP id e2-v6mr16939868pff.211.1533562194980; Mon, 06 Aug 2018 06:29:54 -0700 (PDT) Received: from VM_120_46_centos.localdomain ([119.28.87.64]) by smtp.gmail.com with ESMTPSA id f11-v6sm11756302pfa.131.2018.08.06.06.29.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 06:29:54 -0700 (PDT) From: Lidong Chen X-Google-Original-From: Lidong Chen To: zhang.zhanghailiang@huawei.com, quintela@redhat.com, dgilbert@redhat.com Date: Mon, 6 Aug 2018 21:29:32 +0800 Message-Id: <1533562177-16447-7-git-send-email-lidongchen@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1533562177-16447-1-git-send-email-lidongchen@tencent.com> References: <1533562177-16447-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:4864:20::536 Subject: [Qemu-devel] [PATCH v6 06/11] migration: invoke qio_channel_yield only when qemu_in_coroutine() 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: Lidong Chen , 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 From: Lidong Chen when qio_channel_read return QIO_CHANNEL_ERR_BLOCK, the source qemu crash. The backtrace is: (gdb) bt #0 0x00007fb20aba91d7 in raise () from /lib64/libc.so.6 #1 0x00007fb20abaa8c8 in abort () from /lib64/libc.so.6 #2 0x00007fb20aba2146 in __assert_fail_base () from /lib64/libc.so.6 #3 0x00007fb20aba21f2 in __assert_fail () from /lib64/libc.so.6 #4 0x00000000008dba2d in qio_channel_yield (ioc=0x22f9e20, condition=G_IO_IN) at io/channel.c:460 #5 0x00000000007a870b in channel_get_buffer (opaque=0x22f9e20, buf=0x3d54038 "", pos=0, size=32768) at migration/qemu-file-channel.c:83 #6 0x00000000007a70f6 in qemu_fill_buffer (f=0x3d54000) at migration/qemu-file.c:299 #7 0x00000000007a79d0 in qemu_peek_byte (f=0x3d54000, offset=0) at migration/qemu-file.c:562 #8 0x00000000007a7a22 in qemu_get_byte (f=0x3d54000) at migration/qemu-file.c:575 #9 0x00000000007a7c46 in qemu_get_be16 (f=0x3d54000) at migration/qemu-file.c:647 #10 0x0000000000796db7 in source_return_path_thread (opaque=0x2242280) at migration/migration.c:1794 #11 0x00000000009428fa in qemu_thread_start (args=0x3e58420) at util/qemu-thread-posix.c:504 #12 0x00007fb20af3ddc5 in start_thread () from /lib64/libpthread.so.0 #13 0x00007fb20ac6b74d in clone () from /lib64/libc.so.6 This patch fixed by invoke qio_channel_yield only when qemu_in_coroutine(). Signed-off-by: Lidong Chen Reviewed-by: Juan Quintela Reviewed-by: Juan Quintela --- migration/qemu-file-channel.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index e202d73..8e639eb 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -49,7 +49,11 @@ static ssize_t channel_writev_buffer(void *opaque, ssize_t len; len = qio_channel_writev(ioc, local_iov, nlocal_iov, NULL); if (len == QIO_CHANNEL_ERR_BLOCK) { - qio_channel_wait(ioc, G_IO_OUT); + if (qemu_in_coroutine()) { + qio_channel_yield(ioc, G_IO_OUT); + } else { + qio_channel_wait(ioc, G_IO_OUT); + } continue; } if (len < 0) { @@ -80,7 +84,11 @@ static ssize_t channel_get_buffer(void *opaque, ret = qio_channel_read(ioc, (char *)buf, size, NULL); if (ret < 0) { if (ret == QIO_CHANNEL_ERR_BLOCK) { - qio_channel_yield(ioc, G_IO_IN); + if (qemu_in_coroutine()) { + qio_channel_yield(ioc, G_IO_IN); + } else { + qio_channel_wait(ioc, G_IO_IN); + } } else { /* XXX handle Error * object */ return -EIO;