From nobody Sat Apr 27 13:31:03 2024 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.zohomail.com; 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 1503332224302898.5741072608838; Mon, 21 Aug 2017 09:17:04 -0700 (PDT) Received: from localhost ([::1]:58790 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djpNu-0000Ne-A5 for importer@patchew.org; Mon, 21 Aug 2017 12:17:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djpMi-00088T-HU for qemu-devel@nongnu.org; Mon, 21 Aug 2017 12:15:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djpMh-0001aW-Jv for qemu-devel@nongnu.org; Mon, 21 Aug 2017 12:15:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51720) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1djpMc-0001R1-Pi; Mon, 21 Aug 2017 12:15:42 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F9DA81E0E; Mon, 21 Aug 2017 16:15:41 +0000 (UTC) Received: from localhost (ovpn-116-250.ams2.redhat.com [10.36.116.250]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEB3870473; Mon, 21 Aug 2017 16:15:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7F9DA81E0E Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Mon, 21 Aug 2017 17:15:39 +0100 Message-Id: <20170821161539.11066-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 21 Aug 2017 16:15:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] nbd-client: fix hang after server closes connection 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: Paolo Bonzini , Stefan Hajnoczi , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit 72b6ffc76653214b69a94a7b1643ff80df134486 ("nbd-client: Fix regression when server sends garbage") improved NBD client behavior when the connection enters a broken state. The following still does not behave as expected: $ qemu-nbd -p 1234 -x drive0 -f qcow2 test.qcow2 $ qemu-system-x86_64 -M accel=3Dkvm -m 1G \ -drive if=3Dvirtio,id=3Ddrive0,file=3Dnbd://localhost:1234/drive0,f= ormat=3Draw $ pkill qemu-nbd (qemu) quit ...hang... QEMU should be able to quit even when the connection was previously closed by the NBD server. Currently the nbd_read_reply_entry() coroutine terminates without letting in-flight requests know that the connection is dead. This patch flags the connection as dead so in-flight requests can complete. Reported-by: Longxiang Lyu Cc: Eric Blake Cc: Paolo Bonzini Signed-off-by: Stefan Hajnoczi Acked-by: Philippe Mathieu-Daud=C3=A9 --- block/nbd-client.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/block/nbd-client.c b/block/nbd-client.c index 422ecb4307..5a5fe02015 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -80,6 +80,7 @@ static coroutine_fn void nbd_read_reply_entry(void *opaqu= e) error_report_err(local_err); } if (ret <=3D 0) { + s->quit =3D true; break; } =20 @@ -107,9 +108,6 @@ static coroutine_fn void nbd_read_reply_entry(void *opa= que) qemu_coroutine_yield(); } =20 - if (ret < 0) { - s->quit =3D true; - } nbd_recv_coroutines_enter_all(s); s->read_reply_co =3D NULL; } --=20 2.13.5