From nobody Mon Feb 9 16:19:55 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510178379102510.87578299835275; Wed, 8 Nov 2017 13:59:39 -0800 (PST) Received: from localhost ([::1]:34071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCYNS-0006H7-Kw for importer@patchew.org; Wed, 08 Nov 2017 16:59:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCYLV-00050C-Ku for qemu-devel@nongnu.org; Wed, 08 Nov 2017 16:57:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCYLU-0000VG-Ts for qemu-devel@nongnu.org; Wed, 08 Nov 2017 16:57:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44368) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCYLS-0000Ta-U0; Wed, 08 Nov 2017 16:57:15 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F3AD087649; Wed, 8 Nov 2017 21:57:13 +0000 (UTC) Received: from red.redhat.com (ovpn-125-14.rdu2.redhat.com [10.10.125.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FBE85EDFB; Wed, 8 Nov 2017 21:57:12 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 8 Nov 2017 15:57:00 -0600 Message-Id: <20171108215703.9295-5-eblake@redhat.com> In-Reply-To: <20171108215703.9295-1-eblake@redhat.com> References: <20171108215703.9295-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 08 Nov 2017 21:57:14 +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 v2 4/7] nbd: Fix struct name for structured reads 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, pbonzini@redhat.com, vsementsov@virtuozzo.com, qemu-block@nongnu.org, Max Reitz 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" A closer read of the NBD spec shows that a structured reply chunk for a hole is not quite identical to the prefix of a data chunk, because the hole has to also send a 32-bit size field. Although we do not yet send holes, we should fix the misleading information in our header and make it easier for a future patch to support sparse reads. Signed-off-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/block/nbd.h | 18 +++++++++++++----- nbd/server.c | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/block/nbd.h b/include/block/nbd.h index 92d1723d7c..113c707a5e 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -86,15 +86,23 @@ typedef union NBDReply { } QEMU_PACKED; } NBDReply; -/* Header of NBD_REPLY_TYPE_OFFSET_DATA, complete NBD_REPLY_TYPE_OFFSET_HO= LE */ -typedef struct NBDStructuredRead { - NBDStructuredReplyChunk h; +/* Header of chunk for NBD_REPLY_TYPE_OFFSET_DATA */ +typedef struct NBDStructuredReadData { + NBDStructuredReplyChunk h; /* h.length >=3D 9 */ uint64_t offset; -} QEMU_PACKED NBDStructuredRead; + /* At least one byte of data payload follows, calculated from h.length= */ +} QEMU_PACKED NBDStructuredReadData; + +/* Complete chunk for NBD_REPLY_TYPE_OFFSET_HOLE */ +typedef struct NBDStructuredReadHole { + NBDStructuredReplyChunk h; /* h.length =3D=3D 12 */ + uint64_t offset; + uint32_t length; +} QEMU_PACKED NBDStructuredReadHole; /* Header of all NBD_REPLY_TYPE_ERROR* errors */ typedef struct NBDStructuredError { - NBDStructuredReplyChunk h; + NBDStructuredReplyChunk h; /* h.length >=3D 6 */ uint32_t error; uint16_t message_length; } QEMU_PACKED NBDStructuredError; diff --git a/nbd/server.c b/nbd/server.c index bcf0cdb47c..6ebb7d9c2e 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1280,7 +1280,7 @@ static int coroutine_fn nbd_co_send_structured_read(N= BDClient *client, size_t size, Error **errp) { - NBDStructuredRead chunk; + NBDStructuredReadData chunk; struct iovec iov[] =3D { {.iov_base =3D &chunk, .iov_len =3D sizeof(chunk)}, {.iov_base =3D data, .iov_len =3D size} --=20 2.13.6