From nobody Wed Feb 11 02:07:33 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 1496224305554360.7751521935969; Wed, 31 May 2017 02:51:45 -0700 (PDT) Received: from localhost ([::1]:58173 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG0I4-0000Ti-5W for importer@patchew.org; Wed, 31 May 2017 05:51:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG0AR-0002dM-2B for qemu-devel@nongnu.org; Wed, 31 May 2017 05:43:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG0AP-0001sm-AH for qemu-devel@nongnu.org; Wed, 31 May 2017 05:43:51 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34825) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dG0AP-0001sF-40; Wed, 31 May 2017 05:43:49 -0400 Received: by mail-wm0-x242.google.com with SMTP id g15so2248412wmc.2; Wed, 31 May 2017 02:43:48 -0700 (PDT) Received: from localhost.localdomain (94-39-157-43.adsl-ull.clienti.tiscali.it. [94.39.157.43]) by smtp.gmail.com with ESMTPSA id b30sm18150162wra.6.2017.05.31.02.43.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 May 2017 02:43:47 -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=a+/or5faELN2YqTvtnHS0jj0l9ZdmfRx3s8XotsjETo=; b=kq/8DII0+VaQgfeYUD9NkExFtBNdC5G7NfDX2MUCfE+6TeCSMxSK5WdPqmPhQU41Tr Qz2DLUu8dl11AQkGJL46WD44q9LmHuwFgk6TvIjYpFKPfFW1X1lwmnjWxf7Iu1z4+Uzm h1p1b1buz80tVgLvnfpbX0sjEqryBAMdteAii++rFpA+Z1qZmYWPGe9qFOtjvXklbuZ2 pQMaOtzKcRJlyT4+wk/n0ampGAPZli6JaFtDqnYEJRqc9mBomuaJAVM1yDpq1joSlt+P flqGTbJemwLilCZcvrodNZbuIaRXlv+AG4oDFX0pGnzs9KdJUqvhPky3fbkVnI+7GO5i FKMg== 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=a+/or5faELN2YqTvtnHS0jj0l9ZdmfRx3s8XotsjETo=; b=Wke/GLCxSctAdHqCOEdq9J2CCtuWYASscDvSHgxtYTiJOILw0yCx9Yx4hhqCxXVrNt ZvXp7opRF5e7rhX9C3QwpiYftv91ikvpZ4OyovyxqB//DSroXBIhHiaQ7olMTbTjvafy TOzEJvPWGlvgM7FqiWmOF8R/WnMSQ9SV3hgr9cyX/6Jhp4/QiCwKl7ABS+o/uP2b7eTD SoMTykayoyrNOHtcyEqZG0hjw3jaFs0q4Wy5cpeyjaAyB4H2IV28DL9/bdrxwovv4cMC 0HZAZlaWnlGIPBGM5W2n5ceJ+IYeGlGrGdlgKSFQrdZ3miCuCs5WR839qW+3bIbsdeX1 0Eaw== X-Gm-Message-State: AODbwcAYbGrj7PX02ZMQ3KxA2/fTACXEHQ3aWjreGGVTPaCYziKo42SO g8hVWTWTbnJ0c4gk63E= X-Received: by 10.28.207.207 with SMTP id f198mr4417012wmg.85.1496223827903; Wed, 31 May 2017 02:43:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 11:43:30 +0200 Message-Id: <20170531094330.1808-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170531094330.1808-1-pbonzini@redhat.com> References: <20170531094330.1808-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::242 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, famz@redhat.com, qemu-block@nongnu.org, mreitz@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. 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 11203fc5a2..b5a35824d7 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -889,13 +889,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 @@ -906,7 +915,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 @@ -921,11 +933,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