From patchwork Tue Jun 5 15:28:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 858585 jemmy X-Patchwork-Id: 925532 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oGSed8Jw"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 410bTJ0zZLz9s08 for ; Wed, 6 Jun 2018 01:34:42 +1000 (AEST) Received: from localhost ([::1]:47538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQDyp-00058H-Fy for incoming@patchwork.ozlabs.org; Tue, 05 Jun 2018 11:34:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQDsz-0008GI-De for qemu-devel@nongnu.org; Tue, 05 Jun 2018 11:28:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQDsy-0003wN-Ia for qemu-devel@nongnu.org; Tue, 05 Jun 2018 11:28:37 -0400 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]:42690) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQDsy-0003wA-C8 for qemu-devel@nongnu.org; Tue, 05 Jun 2018 11:28:36 -0400 Received: by mail-pf0-x231.google.com with SMTP id w7-v6so1480113pfn.9 for ; Tue, 05 Jun 2018 08:28:36 -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=oGSed8JwGF9ZzJTs+lH32Vn/ywsQPftL93xgVT5Jy4LyZVYVBAnHp9hrOBJjZuxGNs 56f9LU3i7gBTB8Zi3uctBJU9fhc4I0CBc/GdMDCXZDb5midw/ymwnDMoDviXGu3ulsYW UfxhcluKNPjJ//LpwLVkua81tNV4Bxd16mmMJ48bAFRaKxO0bGomaTL+gWGkY1rwYyL5 O1h4TlVcVuHEz6xazSja3YgGOBD8ojeJdqc+IMpk3lSpzmG2yd2MGMb8sxO4eNDE+HyW N9PvneuYgDUR0INpPfD335zVrDfsH+uw9IE8eKNVw2kGG2ZAhfKLpOZNiv7V2tJyBq4R 6TOg== 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=fTP3TT3FS/U4Wi7u43NwoW4+K3QrQ52RGqSU3yGP2/ovnYy3ZusnjBnj61WVwBDC0H 2+1H/aviI8w+7FnYvAbNAPR5lOBtW5q/n1aPeIjSfVbzneEtVrkMSvksacGxUOwZP54U QRSI038xfU78gpblt+d0NhnSxZFooAzQerEYzDYp6a5KVj+fSZjuMYnGdfDpDbRYame0 CCN38/abmz+WjZzzMQeq3blOyyM6f4wYcwManMEE7NRI688AO2gn6nEy50CLqAJno+Hp 8B7Pq/SBumt/RcNBBr/euTIDLuobmFhi34l+iymjhWCQtSO5Z5EMYz/RDsD+WOWAabSJ Fyuw== X-Gm-Message-State: APt69E3SWapW+qH+qdQkl/Yn/SdY6ul2wDPzTULhM9ptiGw2S3KZWc3w ZVwl+wU7jTrE2yltZn6U0GI= X-Google-Smtp-Source: ADUXVKJE1hKZttVMFhAjr8jrZTf+qSB+upESUwcFuwWZbHqhmMpgA1kjF+LifFnijiTP8ihfEYmK5A== X-Received: by 2002:a65:5084:: with SMTP id r4-v6mr856528pgp.202.1528212515583; Tue, 05 Jun 2018 08:28:35 -0700 (PDT) Received: from VM_93_245_centos.localdomain ([150.109.57.149]) by smtp.gmail.com with ESMTPSA id t14-v6sm101952007pfh.109.2018.06.05.08.28.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jun 2018 08:28:35 -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: Tue, 5 Jun 2018 23:28:06 +0800 Message-Id: <1528212489-19137-8-git-send-email-lidongchen@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1528212489-19137-1-git-send-email-lidongchen@tencent.com> References: <1528212489-19137-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::231 Subject: [Qemu-devel] [PATCH v5 07/10] 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: galsha@mellanox.com, Lidong Chen , adido@mellanox.com, qemu-devel@nongnu.org, Lidong Chen Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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;