From nobody Sun Feb 8 19:55:43 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; 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 1496155084067688.7363369828025; Tue, 30 May 2017 07:38:04 -0700 (PDT) Received: from localhost ([::1]:54189 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFiHZ-0003FQ-ME for importer@patchew.org; Tue, 30 May 2017 10:38:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFiAp-0005QB-1v for qemu-devel@nongnu.org; Tue, 30 May 2017 10:31:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFiAl-0000Oi-SS for qemu-devel@nongnu.org; Tue, 30 May 2017 10:31:02 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:48695 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFiAl-0000NX-6O for qemu-devel@nongnu.org; Tue, 30 May 2017 10:30:59 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4UEUqEU027829; Tue, 30 May 2017 17:30:56 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Date: Tue, 30 May 2017 17:30:47 +0300 Message-Id: <20170530143052.165002-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170530143052.165002-1-vsementsov@virtuozzo.com> References: <20170530143052.165002-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 14/19] nbd/server: nbd_negotiate: return 1 on NBD_OPT_ABORT 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: pbonzini@redhat.com, vsementsov@virtuozzo.com, den@openvz.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" Separate case when client sent NBD_OPT_ABORT from other errors. It will be needed for the following patch, where errors will be reported. Considered case is not actually the error - it honestly follows NBD protocol. Therefore it should not be reported like an error. -EPIPE case means client not read server reply on NBD_OPT_ABORT, which is also OK. Signed-off-by: Vladimir Sementsov-Ogievskiy --- nbd/server.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index 30dfb81a5c..0e53d3dd91 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -369,9 +369,13 @@ static QIOChannel *nbd_negotiate_handle_starttls(NBDCl= ient *client, return QIO_CHANNEL(tioc); } =20 - -/* Process all NBD_OPT_* client option commands. - * Return -errno on error, 0 on success. */ +/* nbd_negotiate_options + * Process all NBD_OPT_* client option commands. + * Return: + * < 0 on error + * 0 on successful negotiation + * 1 if client sent NBD_OPT_ABORT, i.e. on legal disconnect + */ static int nbd_negotiate_options(NBDClient *client) { int ret; @@ -483,7 +487,7 @@ static int nbd_negotiate_options(NBDClient *client) } /* Let the client keep trying, unless they asked to quit */ if (clientflags =3D=3D NBD_OPT_ABORT) { - return -EINVAL; + return 1; } break; } @@ -502,7 +506,7 @@ static int nbd_negotiate_options(NBDClient *client) * guests that don't wait for our reply. */ ret =3D nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK, clientflags); - return ret < 0 ? ret : -EINVAL; + return ret < 0 && ret !=3D -EPIPE ? ret : 1; =20 case NBD_OPT_EXPORT_NAME: return nbd_negotiate_handle_export_name(client, length); @@ -560,6 +564,12 @@ static int nbd_negotiate_options(NBDClient *client) } } =20 +/* nbd_negotiate + * Return: + * < 0 on error + * 0 on successful negotiation + * 1 if client sent NBD_OPT_ABORT, i.e. on legal disconnect + */ static coroutine_fn int nbd_negotiate(NBDClient *client) { char buf[8 + 8 + 8 + 128]; --=20 2.11.1