From patchwork Wed May 30 09:43:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 858585 jemmy X-Patchwork-Id: 10438055 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 9593A602CC for ; Wed, 30 May 2018 09:46:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8496328898 for ; Wed, 30 May 2018 09:46:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 834052891A; Wed, 30 May 2018 09:46:56 +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 B243F2891F for ; Wed, 30 May 2018 09:46:55 +0000 (UTC) Received: from localhost ([::1]:37249 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNxh0-0001uL-KT for patchwork-qemu-devel@patchwork.kernel.org; Wed, 30 May 2018 05:46:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNxeR-0000YW-Ab for qemu-devel@nongnu.org; Wed, 30 May 2018 05:44:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNxeQ-0006tp-FB for qemu-devel@nongnu.org; Wed, 30 May 2018 05:44:15 -0400 Received: from mail-pf0-x236.google.com ([2607:f8b0:400e:c00::236]:43742) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fNxeQ-0006tb-9h for qemu-devel@nongnu.org; Wed, 30 May 2018 05:44:14 -0400 Received: by mail-pf0-x236.google.com with SMTP id j20-v6so8747081pff.10 for ; Wed, 30 May 2018 02:44:14 -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=c70yoJBa+cc/cgPMQyUADt91a4QHWwOKywxcjHB3KaDeAFXPqruZrFtZOipIUMF0DK nl5735M052+tIWrdUJAZBnW832lG3N1LJM3uCQbCcBC3nDlRDRA7jSyxHMip38AaE8bl KhXfFhDdUzq1uwqdlJCnI/fQa8wr5vUQHyV/RQJU/pn7g+QraJxe6M5ddONiX7oo8dCs jI9C94luuO8R4i+CW9ViaLlCyjTJPDXK5jnd6+X2s3Y+ZaZ9PNGKl4XaIPLcq2c3qcL6 SyCq/IbYW5pa5RYLY622qCP/AvK/XfU3zm4mZy0czW7nBsLX3p8QyhsXnbcKx3GWfJUg KirQ== 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=lGFZ8Jm8tt6uKO8C+3nPh5932r9TieeL7aJh+p3seRp5PHRPwkjaOUqKKMbGPh4NkQ woMYxxEfPhvWdFfE5ZQW78Y0GldAKUBm//egGCI4/egwfWN54pxBpwcOPtjZ9Tltf2P/ Xk+Z+oeCjdhsQ4c1YVeniKD4oPihTdvFRM9os+6RCoYSpV3GDZEp+NaguNT5F5Jdm9VD CjqeuZkR0wCDUX6f8V6vABGaumAjTdjw4er3xohbqNmC0DOqn4q3KbX9kRYMqetSpET4 dfE3MfT5aHCgp6FJhMuZNOeYhF7LPe2rmn4pwnKrgnm6ML+reMGhBBaFKfRdbrobf6JN jXcQ== X-Gm-Message-State: ALKqPwea1wLCK/g8wjpx7c7ubR6F7hBtcKiW+l7RVQ11kmkhMKyt1oR5 jCNn8v9+n4LyqM+7Z478wHw= X-Google-Smtp-Source: ADUXVKL7vL4XJ9u+XfjhDvHd9O6LNYGF8aNdLia45jayAWP59OL4cWSPoBsHTu8Nicx67T5z/lLenw== X-Received: by 2002:a62:1549:: with SMTP id 70-v6mr2089022pfv.91.1527673453401; Wed, 30 May 2018 02:44:13 -0700 (PDT) Received: from VM_93_245_centos.localdomain ([150.109.57.149]) by smtp.gmail.com with ESMTPSA id 29-v6sm60565257pfj.14.2018.05.30.02.44.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 May 2018 02:44:12 -0700 (PDT) From: Lidong Chen X-Google-Original-From: Lidong Chen To: zhang.zhanghailiang@huawei.com, quintela@redhat.com, dgilbert@redhat.com, berrange@redhat.com, aviadye@mellanox.com, pbonzini@redhat.com Date: Wed, 30 May 2018 17:43:33 +0800 Message-Id: <1527673416-31268-10-git-send-email-lidongchen@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1527673416-31268-1-git-send-email-lidongchen@tencent.com> References: <1527673416-31268-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:c00::236 Subject: [Qemu-devel] [PATCH v4 09/12] 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 , adido@mellanox.com, 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 --- 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;