From nobody Mon Feb 9 16:12:49 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.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153860189093882.05144991469047; Wed, 3 Oct 2018 14:24:50 -0700 (PDT) Received: from localhost ([::1]:53221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7odO-0002pg-GM for importer@patchew.org; Wed, 03 Oct 2018 17:24:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7obN-0001e9-3U for qemu-devel@nongnu.org; Wed, 03 Oct 2018 17:22:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7obL-00010V-NB for qemu-devel@nongnu.org; Wed, 03 Oct 2018 17:22:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57606) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g7obF-0000rT-VR; Wed, 03 Oct 2018 17:22:30 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B4F03DD47; Wed, 3 Oct 2018 21:22:22 +0000 (UTC) Received: from red.redhat.com (ovpn-126-73.rdu2.redhat.com [10.10.126.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21FF5662E7; Wed, 3 Oct 2018 21:22:21 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 16:22:11 -0500 Message-Id: <20181003212211.812374-6-eblake@redhat.com> In-Reply-To: <20181003212211.812374-1-eblake@redhat.com> References: <20181003212211.812374-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 03 Oct 2018 21:22:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/5] nbd/server: drop old-style negotiation 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: Kevin Wolf , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , "open list:Network Block Dev..." , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy After the previous commit, nbd_client_new's first parameter is always NULL. Let's drop it with all corresponding old-style negotiation code path which is unreachable now. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20181003170228.95973-3-vsementsov@virtuozzo.com> Reviewed-by: Eric Blake [eblake: re-wrap short line] Signed-off-by: Eric Blake --- include/block/nbd.h | 3 +-- blockdev-nbd.c | 3 +-- nbd/server.c | 53 +++++++++++++-------------------------------- qemu-nbd.c | 2 +- 4 files changed, 18 insertions(+), 43 deletions(-) diff --git a/include/block/nbd.h b/include/block/nbd.h index 4638c839f51..0129d1a4b46 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -308,8 +308,7 @@ void nbd_export_set_name(NBDExport *exp, const char *na= me); void nbd_export_set_description(NBDExport *exp, const char *description); void nbd_export_close_all(void); -void nbd_client_new(NBDExport *exp, - QIOChannelSocket *sioc, +void nbd_client_new(QIOChannelSocket *sioc, QCryptoTLSCreds *tlscreds, const char *tlsaclname, void (*close_fn)(NBDClient *, bool)); diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 1ef11041a73..1d170c80b82 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -36,8 +36,7 @@ static void nbd_accept(QIONetListener *listener, QIOChann= elSocket *cioc, gpointer opaque) { qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server"); - nbd_client_new(NULL, cioc, - nbd_server->tlscreds, NULL, + nbd_client_new(cioc, nbd_server->tlscreds, NULL, nbd_blockdev_client_closed); } diff --git a/nbd/server.c b/nbd/server.c index 4fb247b1166..a1eda0114fa 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1253,7 +1253,6 @@ static coroutine_fn int nbd_negotiate(NBDClient *clie= nt, Error **errp) const uint16_t myflags =3D (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM | NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA | NBD_FLAG_SEND_WRITE_ZEROES | NBD_FLAG_SEND_C= ACHE); - bool oldStyle; /* Old style negotiation header, no room for options [ 0 .. 7] passwd ("NBDMAGIC") @@ -1274,33 +1273,19 @@ static coroutine_fn int nbd_negotiate(NBDClient *cl= ient, Error **errp) trace_nbd_negotiate_begin(); memcpy(buf, "NBDMAGIC", 8); - oldStyle =3D client->exp !=3D NULL && !client->tlscreds; - if (oldStyle) { - trace_nbd_negotiate_old_style(client->exp->size, - client->exp->nbdflags | myflags); - stq_be_p(buf + 8, NBD_CLIENT_MAGIC); - stq_be_p(buf + 16, client->exp->size); - stl_be_p(buf + 24, client->exp->nbdflags | myflags); + stq_be_p(buf + 8, NBD_OPTS_MAGIC); + stw_be_p(buf + 16, NBD_FLAG_FIXED_NEWSTYLE | NBD_FLAG_NO_ZEROES); - if (nbd_write(client->ioc, buf, sizeof(buf), errp) < 0) { - error_prepend(errp, "write failed: "); - return -EINVAL; - } - } else { - stq_be_p(buf + 8, NBD_OPTS_MAGIC); - stw_be_p(buf + 16, NBD_FLAG_FIXED_NEWSTYLE | NBD_FLAG_NO_ZEROES); - - if (nbd_write(client->ioc, buf, 18, errp) < 0) { - error_prepend(errp, "write failed: "); - return -EINVAL; - } - ret =3D nbd_negotiate_options(client, myflags, errp); - if (ret !=3D 0) { - if (ret < 0) { - error_prepend(errp, "option negotiation failed: "); - } - return ret; + if (nbd_write(client->ioc, buf, 18, errp) < 0) { + error_prepend(errp, "write failed: "); + return -EINVAL; + } + ret =3D nbd_negotiate_options(client, myflags, errp); + if (ret !=3D 0) { + if (ret < 0) { + error_prepend(errp, "option negotiation failed: "); } + return ret; } assert(!client->optlen); @@ -2396,13 +2381,8 @@ static void nbd_client_receive_next_request(NBDClien= t *client) static coroutine_fn void nbd_co_client_start(void *opaque) { NBDClient *client =3D opaque; - NBDExport *exp =3D client->exp; Error *local_err =3D NULL; - if (exp) { - nbd_export_get(exp); - QTAILQ_INSERT_TAIL(&exp->clients, client, next); - } qemu_co_mutex_init(&client->send_lock); if (nbd_negotiate(client, &local_err)) { @@ -2417,13 +2397,11 @@ static coroutine_fn void nbd_co_client_start(void *= opaque) } /* - * Create a new client listener on the given export @exp, using the - * given channel @sioc. Begin servicing it in a coroutine. When the - * connection closes, call @close_fn with an indication of whether the - * client completed negotiation. + * Create a new client listener using the given channel @sioc. + * Begin servicing it in a coroutine. When the connection closes, call + * @close_fn with an indication of whether the client completed negotiatio= n. */ -void nbd_client_new(NBDExport *exp, - QIOChannelSocket *sioc, +void nbd_client_new(QIOChannelSocket *sioc, QCryptoTLSCreds *tlscreds, const char *tlsaclname, void (*close_fn)(NBDClient *, bool)) @@ -2433,7 +2411,6 @@ void nbd_client_new(NBDExport *exp, client =3D g_new0(NBDClient, 1); client->refcount =3D 1; - client->exp =3D exp; client->tlscreds =3D tlscreds; if (tlscreds) { object_ref(OBJECT(client->tlscreds)); diff --git a/qemu-nbd.c b/qemu-nbd.c index 6aaebe7d938..e76fe3082ab 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -354,7 +354,7 @@ static void nbd_accept(QIONetListener *listener, QIOCha= nnelSocket *cioc, nb_fds++; nbd_update_server_watch(); - nbd_client_new(NULL, cioc, tlscreds, NULL, nbd_client_closed); + nbd_client_new(cioc, tlscreds, NULL, nbd_client_closed); } static void nbd_update_server_watch(void) --=20 2.17.1