From nobody Mon Feb 9 16:02:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498743765830634.1830910877254; Thu, 29 Jun 2017 06:42:45 -0700 (PDT) Received: from localhost ([::1]:39438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQZiT-00025a-Ad for importer@patchew.org; Thu, 29 Jun 2017 09:42:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQZUQ-0005xA-SO for qemu-devel@nongnu.org; Thu, 29 Jun 2017 09:28:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQZUM-0001Tc-Nc for qemu-devel@nongnu.org; Thu, 29 Jun 2017 09:28:10 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:35302) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dQZUM-0001T1-Fh; Thu, 29 Jun 2017 09:28:06 -0400 Received: by mail-wm0-x241.google.com with SMTP id u23so2590731wma.2; Thu, 29 Jun 2017 06:28:06 -0700 (PDT) Received: from localhost.localdomain (94-39-191-51.adsl-ull.clienti.tiscali.it. [94.39.191.51]) by smtp.gmail.com with ESMTPSA id i22sm4087691wrb.30.2017.06.29.06.28.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Jun 2017 06:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=OxJ4SUtUOhPcvEiqes/sd5XvBopHOTVBC/35a9AXaxY=; b=LSKwDg2/HhDf9Do1AgkNX3WYFmx/o1TsXuqYwRHGs8iOqSWwC97FeXt+LB3T63b+GI 7WAWod7Orm6AbkeZHPj/cMYgZC8/0zCTCoI85xcDOLch3K9pNosiU1LLbUttgmxtiHcM OtKaedHPU4vEOTkhd2bMaXbWtKiXPShLSx9TeEyrZ85QOGb7tUC3lb5Jk+lpaQJ+KfnM E+9unoH2LUAaStzM52d+JI40q8j3xXJ7R4RtznAj4ca7UJYdkk3/F7mPUisigTmK+w5Q 0QuYM1tB3XXWYu6orBpysDKUrP7mOWVLobBCPqih2tAs0svXZ3iFYbVYO4jhqje+2PsK I9OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=OxJ4SUtUOhPcvEiqes/sd5XvBopHOTVBC/35a9AXaxY=; b=Cb499+sZqQQVHFiOni7naNtTdX24ZTDiSNopxefbgnRrZ8qyq+2MZlAy0Y2/B5+kh1 5tu327Kx5GHIa+U+KKvsYIpjtwFdMRde2GLvvor3Sd3piYEPzzjizpQ8FdMfd7HSla4x m4ceN7QpurC/a+LvWYuiSis9wvmtQKChpXyqEs39Hsgi7/OSjnENJMxcp0OUNHIgx33C Ah4fU4e83JjzKWEup6NNlR3COYw5B4Yn6sjqAF2STSkHDpsbuFAclEe8Ipozxk0CMmBi 7ZxDZhiJUhuNlE84zj0dBtcifTxd4Bf3Yx67kvCX+oFiMx+Xg+HgqCz8SiNlSt29AQM2 +adQ== X-Gm-Message-State: AIVw112KF2A45fRvIa1jxlZw9aOQzoyJ1GhisIvZtsBftZx24qbH6H0o OUKe2uRd0IgaUvlkk2U= X-Received: by 10.28.132.13 with SMTP id g13mr2082315wmd.58.1498742885285; Thu, 29 Jun 2017 06:28:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 29 Jun 2017 15:27:49 +0200 Message-Id: <20170629132749.997-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170629132749.997-1-pbonzini@redhat.com> References: <20170629132749.997-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH 11/11] ssh: support I/O from any AioContext 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: kwolf@redhat.com, qemu-block@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The coroutine may run in a different AioContext, causing the fd handler to busy wait. Fix this by resetting the handler in restart_coroutine, before the coroutine is restarted. Reviewed-by: Stefan Hajnoczi Signed-off-by: Paolo Bonzini --- block/ssh.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/block/ssh.c b/block/ssh.c index 52964416da..e6a5b08de3 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -888,13 +888,22 @@ static int ssh_has_zero_init(BlockDriverState *bs) return has_zero_init; } =20 +typedef struct BDRVSSHRestart { + BlockDriverState *bs; + Coroutine *co; +} BDRVSSHRestart; + static void restart_coroutine(void *opaque) { - Coroutine *co =3D opaque; + BDRVSSHRestart *restart =3D opaque; + BlockDriverState *bs =3D restart->bs; + BDRVSSHState *s =3D bs->opaque; + AioContext *ctx =3D bdrv_get_aio_context(bs); =20 - DPRINTF("co=3D%p", co); + DPRINTF("co=3D%p", restart->co); + aio_set_fd_handler(ctx, s->sock, false, NULL, NULL, NULL, NULL); =20 - aio_co_wake(co); + aio_co_wake(restart->co); } =20 /* A non-blocking call returned EAGAIN, so yield, ensuring the @@ -905,7 +914,10 @@ static coroutine_fn void co_yield(BDRVSSHState *s, Blo= ckDriverState *bs) { int r; IOHandler *rd_handler =3D NULL, *wr_handler =3D NULL; - Coroutine *co =3D qemu_coroutine_self(); + BDRVSSHRestart restart =3D { + .bs =3D bs, + .co =3D qemu_coroutine_self() + }; =20 r =3D libssh2_session_block_directions(s->session); =20 @@ -920,11 +932,9 @@ static coroutine_fn void co_yield(BDRVSSHState *s, Blo= ckDriverState *bs) rd_handler, wr_handler); =20 aio_set_fd_handler(bdrv_get_aio_context(bs), s->sock, - false, rd_handler, wr_handler, NULL, co); + false, rd_handler, wr_handler, NULL, &restart); qemu_coroutine_yield(); DPRINTF("s->sock=3D%d - back", s->sock); - aio_set_fd_handler(bdrv_get_aio_context(bs), s->sock, false, - NULL, NULL, NULL, NULL); } =20 /* SFTP has a function `libssh2_sftp_seek64' which seeks to a position --=20 2.13.0