From nobody Wed Feb 11 01:09:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1691689475; cv=none; d=zohomail.com; s=zohoarc; b=HiP+MLiSGdIP4RA7FGwAGBl95Fg6RyiclB6V9BwRjJ1K/ozaG+kXDD0I87OJTzR/cmPHD6SqV19K5UukifIyCVrH0OXy9w4OAnhZw2W0UJBgOEymwtJ6WNZ1k6CPUem7xc0sgR8SGxbt+ABkvRDl7u1TCscasgDvyghkCwc5hQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691689475; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dxUwZ8q67Vgr8YGuhKSgFVyGjlO72/H7aWyvec7F8G0=; b=coAfmr2aeBS9U00J/9S/bOwWY/vw81aLXu2U8FCeVUjeGgFWK3vdJsj5dBa8bPT2e6pOp+6nF/gpsZ1fCnCWP5YA4DDTGwdkg1DiXpfEzunnRxgWhQsf6y5TxwZ0g+bSSBQ/a+mQtvpK8V9E/BtEy73XaUtzmB971nCxYPXc9Ls= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691689475049795.3174638511282; Thu, 10 Aug 2023 10:44:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qU9g2-0003qx-4G; Thu, 10 Aug 2023 13:42:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qU9g0-0003pk-Hn for qemu-devel@nongnu.org; Thu, 10 Aug 2023 13:42:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qU9fy-0004xJ-R5 for qemu-devel@nongnu.org; Thu, 10 Aug 2023 13:42:24 -0400 Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-3-Y41eXTnxPU6pMkSTFygAFQ-1; Thu, 10 Aug 2023 13:42:20 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DED5E3C11C67; Thu, 10 Aug 2023 17:42:19 +0000 (UTC) Received: from green.redhat.com (unknown [10.2.16.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A4C31121314; Thu, 10 Aug 2023 17:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691689341; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dxUwZ8q67Vgr8YGuhKSgFVyGjlO72/H7aWyvec7F8G0=; b=Mc4Mdquf+RfC+2aASZRIb8RZlTg3McryOGU7mKZQ6mH9KaU+2RCpSAXwdbsqBRlwRo4vNO 1ioXgIIj8VHN6CTHrzn8zhtgW05JHQxc3jC9wKiNdQCVkMtHSazqbn7u1kYGERy1NkK6hQ +ylgsEXvQokH1cYkw493bfUIay40IEs= X-MC-Unique: Y41eXTnxPU6pMkSTFygAFQ-1 From: Eric Blake To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, vsementsov@yandex-team.ru, Kevin Wolf , Hanna Reitz Subject: [PATCH v5 02/17] nbd/client: Pass mode through to nbd_send_request Date: Thu, 10 Aug 2023 12:36:49 -0500 Message-ID: <20230810173646.17695-21-eblake@redhat.com> In-Reply-To: <20230810173646.17695-19-eblake@redhat.com> References: <20230810173646.17695-19-eblake@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1691689475415100001 Content-Type: text/plain; charset="utf-8" Once the 64-bit headers extension is enabled, the data layout we send over the wire for a client request depends on the mode negotiated with the server. Rather than adding a parameter to nbd_send_request, we can add a member to struct NBDRequest, since it already does not reflect on-wire format. Some callers initialize it directly; many others rely on a common initialization point during nbd_co_send_request(). At this point, there is no semantic change. Signed-off-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy --- v5: R-b added v4: new patch, based on ideas in v3 4/14, but by modifying NBDRequest instead of adding a parameter --- include/block/nbd.h | 12 +++++++----- block/nbd.c | 5 +++-- nbd/client.c | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/block/nbd.h b/include/block/nbd.h index abf6030b513..c4cbe130e07 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -63,17 +63,19 @@ typedef enum NBDMode { /* TODO add NBD_MODE_EXTENDED */ } NBDMode; -/* Transmission phase structs - * - * Note: these are _NOT_ the same as the network representation of an NBD - * request and reply! +/* Transmission phase structs */ + +/* + * Note: NBDRequest is _NOT_ the same as the network representation of an = NBD + * request! */ typedef struct NBDRequest { uint64_t cookie; uint64_t from; uint32_t len; uint16_t flags; /* NBD_CMD_FLAG_* */ - uint16_t type; /* NBD_CMD_* */ + uint16_t type; /* NBD_CMD_* */ + NBDMode mode; /* Determines which network representation to use */ } NBDRequest; typedef struct NBDSimpleReply { diff --git a/block/nbd.c b/block/nbd.c index 5f88f7a819b..ca5991f868a 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -339,7 +339,7 @@ int coroutine_fn nbd_co_do_establish_connection(BlockDr= iverState *bs, * We have connected, but must fail for other reasons. * Send NBD_CMD_DISC as a courtesy to the server. */ - NBDRequest request =3D { .type =3D NBD_CMD_DISC }; + NBDRequest request =3D { .type =3D NBD_CMD_DISC, .mode =3D s->info= .mode }; nbd_send_request(s->ioc, &request); @@ -521,6 +521,7 @@ nbd_co_send_request(BlockDriverState *bs, NBDRequest *r= equest, qemu_co_mutex_lock(&s->send_mutex); request->cookie =3D INDEX_TO_COOKIE(i); + request->mode =3D s->info.mode; assert(s->ioc); @@ -1466,7 +1467,7 @@ static void nbd_yank(void *opaque) static void nbd_client_close(BlockDriverState *bs) { BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; - NBDRequest request =3D { .type =3D NBD_CMD_DISC }; + NBDRequest request =3D { .type =3D NBD_CMD_DISC, .mode =3D s->info.mod= e }; if (s->ioc) { nbd_send_request(s->ioc, &request); diff --git a/nbd/client.c b/nbd/client.c index faa054c4527..40a1eb72346 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -1224,7 +1224,7 @@ int nbd_receive_export_list(QIOChannel *ioc, QCryptoT= LSCreds *tlscreds, /* Send NBD_CMD_DISC as a courtesy to the server, but ignore all * errors now that we have the information we wanted. */ if (nbd_drop(ioc, 124, NULL) =3D=3D 0) { - NBDRequest request =3D { .type =3D NBD_CMD_DISC }; + NBDRequest request =3D { .type =3D NBD_CMD_DISC, .mode =3D res= ult }; nbd_send_request(ioc, &request); } @@ -1354,6 +1354,7 @@ int nbd_send_request(QIOChannel *ioc, NBDRequest *req= uest) { uint8_t buf[NBD_REQUEST_SIZE]; + assert(request->mode <=3D NBD_MODE_STRUCTURED); /* TODO handle extende= d */ trace_nbd_send_request(request->from, request->len, request->cookie, request->flags, request->type, nbd_cmd_lookup(request->type)); --=20 2.41.0