From nobody Sun Oct 5 19:23:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547739532325217.07721447081622; Thu, 17 Jan 2019 07:38:52 -0800 (PST) Received: from localhost ([127.0.0.1]:46739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gk9kp-0004xS-4z for importer@patchew.org; Thu, 17 Jan 2019 10:38:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gk9ft-00016t-Go for qemu-devel@nongnu.org; Thu, 17 Jan 2019 10:33:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gk9fs-0005TZ-Lh for qemu-devel@nongnu.org; Thu, 17 Jan 2019 10:33:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41070) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gk9fn-0004s2-Iu; Thu, 17 Jan 2019 10:33:41 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83DD08E3E7; Thu, 17 Jan 2019 15:33:26 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-153.phx2.redhat.com [10.3.116.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA7C817264; Thu, 17 Jan 2019 15:33:25 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 17 Jan 2019 09:33:19 -0600 Message-Id: <20190117153321.29749-2-eblake@redhat.com> In-Reply-To: <20190117153321.29749-1-eblake@redhat.com> References: <20190117153321.29749-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 17 Jan 2019 15:33:26 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH 1/3] block: Expose protocol-specific data to 'qemu-img info' 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, vsementsov@virtuozzo.com, "open list:Block layer core" , Markus Armbruster , Max Reitz , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 'qemu-img info' is useful for showing additional information about an image - but sometimes the interesting information is specific to the protocol rather than to the format layer. Set the groundwork for showing this information; further patches will then enable specific pieces of information. Signed-off-by: Eric Blake --- qapi/block-core.json | 6 +++++- block/qapi.c | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 91685be6c29..f28d5f5fc76 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -152,6 +152,9 @@ # @format-specific: structure supplying additional format-specific # information (since 1.7) # +# @protocol-specific: structure supplying additional protocol-specific +# information (since 4.0) +# # Since: 1.3 # ## @@ -162,7 +165,8 @@ '*backing-filename': 'str', '*full-backing-filename': 'str', '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo= '], '*backing-image': 'ImageInfo', - '*format-specific': 'ImageInfoSpecific' } } + '*format-specific': 'ImageInfoSpecific', + '*protocol-specific': 'ImageInfoSpecific' } } ## # @ImageCheck: diff --git a/block/qapi.c b/block/qapi.c index c66f949db83..a8d104ba8ce 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -284,6 +284,9 @@ void bdrv_query_image_info(BlockDriverState *bs, } info->format_specific =3D bdrv_get_specific_info(bs); info->has_format_specific =3D info->format_specific !=3D NULL; + info->protocol_specific =3D + bs->file ? bdrv_get_specific_info(bs->file->bs) : NULL; + info->has_protocol_specific =3D info->protocol_specific !=3D NULL; backing_filename =3D bs->backing_file; if (backing_filename[0] !=3D '\0') { @@ -870,4 +873,8 @@ void bdrv_image_info_dump(fprintf_function func_fprintf= , void *f, func_fprintf(f, "Format specific information:\n"); bdrv_image_info_specific_dump(func_fprintf, f, info->format_specif= ic); } + if (info->has_protocol_specific) { + func_fprintf(f, "Protocol specific information:\n"); + bdrv_image_info_specific_dump(func_fprintf, f, info->protocol_spec= ific); + } } --=20 2.20.1 From nobody Sun Oct 5 19:23:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 15477397143878.700265532584467; Thu, 17 Jan 2019 07:41:54 -0800 (PST) Received: from localhost ([127.0.0.1]:46798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gk9nf-0007TN-TU for importer@patchew.org; Thu, 17 Jan 2019 10:41:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gk9fu-00017j-Ff for qemu-devel@nongnu.org; Thu, 17 Jan 2019 10:33:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gk9ft-0005Un-Az for qemu-devel@nongnu.org; Thu, 17 Jan 2019 10:33:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33650) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gk9fn-0004sX-Ik; Thu, 17 Jan 2019 10:33:41 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 48826C0C7CB8; Thu, 17 Jan 2019 15:33:27 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-153.phx2.redhat.com [10.3.116.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FA765C729; Thu, 17 Jan 2019 15:33:26 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 17 Jan 2019 09:33:20 -0600 Message-Id: <20190117153321.29749-3-eblake@redhat.com> In-Reply-To: <20190117153321.29749-1-eblake@redhat.com> References: <20190117153321.29749-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 17 Jan 2019 15:33:27 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH 2/3] file: Expose some protocol-specific information 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, vsementsov@virtuozzo.com, "open list:raw" , Markus Armbruster , Max Reitz , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When analyzing performance, it might be nice to let 'qemu-img info' expose details that it learned from the underlying file or block device. Start the process by picking a few useful items determined during raw_open_common(). Signed-off-by: Eric Blake --- qapi/block-core.json | 24 +++++++++++++++++++++++- block/file-posix.c | 21 +++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index f28d5f5fc76..296c22a1003 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -101,6 +101,25 @@ 'extents': ['ImageInfo'] } } +## +# @ImageInfoSpecificFile: +# +# Details about a file protocol BDS. +# +# @align: Alignment in use +# +# @discard: True if discard operations can be attempted +# +# @write-zero: True if efficient write zero operations can be attempted +# +# @discard-zero: True if discarding is known to read back as zero +# +# Since: 4.0 +## +{ 'struct': 'ImageInfoSpecificFile', + 'data': { 'align': 'int', 'discard': 'bool', 'write-zero': 'bool', + '*discard-zero': 'bool' } } + ## # @ImageInfoSpecific: # @@ -110,12 +129,15 @@ ## { 'union': 'ImageInfoSpecific', 'data': { + # Format drivers: 'qcow2': 'ImageInfoSpecificQCow2', 'vmdk': 'ImageInfoSpecificVmdk', # If we need to add block driver specific parameters for # LUKS in future, then we'll subclass QCryptoBlockInfoLUKS # to define a ImageInfoSpecificLUKS - 'luks': 'QCryptoBlockInfoLUKS' + 'luks': 'QCryptoBlockInfoLUKS', + # Protocol drivers: + 'file': 'ImageInfoSpecificFile' } } ## diff --git a/block/file-posix.c b/block/file-posix.c index 8aee7a3fb8b..d4ce0e9116c 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1079,6 +1079,23 @@ static void raw_refresh_limits(BlockDriverState *bs,= Error **errp) bs->bl.opt_mem_alignment =3D MAX(s->buf_align, getpagesize()); } +static ImageInfoSpecific *raw_get_specific_info(BlockDriverState *bs) +{ + BDRVRawState *s =3D bs->opaque; + ImageInfoSpecific *info =3D g_new0(ImageInfoSpecific, 1); + ImageInfoSpecificFile *infofile =3D g_new0(ImageInfoSpecificFile, 1); + + info->type =3D IMAGE_INFO_SPECIFIC_KIND_FILE; + info->u.file.data =3D infofile; + infofile->align =3D s->buf_align; + infofile->discard =3D s->has_discard; + infofile->write_zero =3D s->has_write_zeroes; + infofile->has_discard_zero =3D s->has_discard; + infofile->discard_zero =3D s->discard_zeroes; + + return info; +} + static int check_for_dasd(int fd) { #ifdef BIODASDINFO2 @@ -2765,6 +2782,7 @@ BlockDriver bdrv_file =3D { .bdrv_co_copy_range_from =3D raw_co_copy_range_from, .bdrv_co_copy_range_to =3D raw_co_copy_range_to, .bdrv_refresh_limits =3D raw_refresh_limits, + .bdrv_get_specific_info =3D raw_get_specific_info, .bdrv_io_plug =3D raw_aio_plug, .bdrv_io_unplug =3D raw_aio_unplug, .bdrv_attach_aio_context =3D raw_aio_attach_aio_context, @@ -3240,6 +3258,7 @@ static BlockDriver bdrv_host_device =3D { .bdrv_co_copy_range_from =3D raw_co_copy_range_from, .bdrv_co_copy_range_to =3D raw_co_copy_range_to, .bdrv_refresh_limits =3D raw_refresh_limits, + .bdrv_get_specific_info =3D raw_get_specific_info, .bdrv_io_plug =3D raw_aio_plug, .bdrv_io_unplug =3D raw_aio_unplug, .bdrv_attach_aio_context =3D raw_aio_attach_aio_context, @@ -3363,6 +3382,7 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_co_pwritev =3D raw_co_pwritev, .bdrv_co_flush_to_disk =3D raw_co_flush_to_disk, .bdrv_refresh_limits =3D raw_refresh_limits, + .bdrv_get_specific_info =3D raw_get_specific_info, .bdrv_io_plug =3D raw_aio_plug, .bdrv_io_unplug =3D raw_aio_unplug, .bdrv_attach_aio_context =3D raw_aio_attach_aio_context, @@ -3494,6 +3514,7 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_co_pwritev =3D raw_co_pwritev, .bdrv_co_flush_to_disk =3D raw_co_flush_to_disk, .bdrv_refresh_limits =3D raw_refresh_limits, + .bdrv_get_specific_info =3D raw_get_specific_info, .bdrv_io_plug =3D raw_aio_plug, .bdrv_io_unplug =3D raw_aio_unplug, .bdrv_attach_aio_context =3D raw_aio_attach_aio_context, --=20 2.20.1 From nobody Sun Oct 5 19:23:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547739424953538.811864852836; Thu, 17 Jan 2019 07:37:04 -0800 (PST) Received: from localhost ([127.0.0.1]:46717 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gk9j5-0003Sj-Mr for importer@patchew.org; Thu, 17 Jan 2019 10:37:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gk9ft-00016q-Fd for qemu-devel@nongnu.org; Thu, 17 Jan 2019 10:33:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gk9fr-0005SS-UL for qemu-devel@nongnu.org; Thu, 17 Jan 2019 10:33:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1449) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gk9fl-0004vB-6h; Thu, 17 Jan 2019 10:33:37 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1B9508666E; Thu, 17 Jan 2019 15:33:28 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-153.phx2.redhat.com [10.3.116.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 713AC5C8B8; Thu, 17 Jan 2019 15:33:27 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 17 Jan 2019 09:33:21 -0600 Message-Id: <20190117153321.29749-4-eblake@redhat.com> In-Reply-To: <20190117153321.29749-1-eblake@redhat.com> References: <20190117153321.29749-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 17 Jan 2019 15:33:28 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH 3/3] RFC: nbd: Expose protocol-specific information 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, vsementsov@virtuozzo.com, "open list:Network Block Dev..." , Markus Armbruster , Max Reitz , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Expose information that the NBD client remembers from its handshake with the server. This is comparable to what 'qemu-nbd --list' outputs when describing a server's capability, so a future patch may refactor that to reuse this QAPI type. The display of flags is interesting - rather than compute the ImageInfoSpecificNBDFlagsList on every handshake, the client code just saves raw flags. But it we know we will be presenting things to an end user, it's nicer to have a list of flag names than it is to have a raw integer that must be decoded. Example output: $ ./qemu-img info nbd://localhost:10809 image: nbd://localhost:10809 file format: raw virtual size: 1.0M (1048576 bytes) disk size: unavailable Protocol specific information: flags: active contexts: [0]: name: base:allocation id: 0 unknown flags: 1260 Signed-off-by: Eric Blake --- Work in progress; there are several todos that I would polish up if the idea behind this patch is agreeable, including making the 'flags' reporting accurate. Also, if this works well, I'd like to improve 'qemu-nbd --list' to reuse this QAPI type. --- qapi/block-core.json | 59 +++++++++++++++++++++++++++++++++++++++++++- block/nbd-client.h | 1 + block/nbd-client.c | 39 +++++++++++++++++++++++++++++ block/nbd.c | 3 +++ 4 files changed, 101 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 296c22a1003..f5fcd329dc6 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -120,6 +120,62 @@ 'data': { 'align': 'int', 'discard': 'bool', 'write-zero': 'bool', '*discard-zero': 'bool' } } +## +# @ImageInfoSpecificNBDFlags: +# +# Enumeration of known NBD export flags. +# +# Since: 4.0 +## +{ 'enum': 'ImageInfoSpecificNBDFlags', 'data': [ + 'readonly', 'flush', 'fua', 'rotational', 'trim', 'zeroes', 'df', + 'multi', 'resize', 'cache' + ] } + +## +# @ImageInfoSpecificNBDContext: +# +# Details about an NBD meta-context negotiated with NBD_OPT_SET_META_CONTE= XT +# and later observed via NBD_CMD_BLOCK_STATUS. +# +# @name: context name +# +# @id: context id, if context is active +# +# Since: 4.0 +## +{ 'struct': 'ImageInfoSpecificNBDContext', + 'data': { 'name': 'str', '*id': 'uint32' } } + +## +# @ImageInfoSpecificNBD: +# +# @description: server's description of export +# +# @flags: listing of servers' export flags with names recognized by qemu +# +# @unknown-flags: any remaining export flags +# +# @min-block: minimum I/O size reported by server (assumed 512 if omitted) +# +# @opt-block: optimum I/O size reported by server +# +# @max-block: maximum I/O size reported by server (assumed 32M if omitted) +# +# @active-contexts: server meta-contexts in use by this client +# +# @contexts: server meta-contexts that were advertised but not selected +# +# Since: 4.0 +## +{ 'struct': 'ImageInfoSpecificNBD', + 'data': { '*description': 'str', '*flags': [ 'ImageInfoSpecificNBDFlags'= ], + '*unknown-flags': 'uint16', '*min-block': 'uint32', + '*opt-block': 'uint32', '*max-block': 'uint32', + '*active-contexts': [ 'ImageInfoSpecificNBDContext' ], + '*contexts': [ 'ImageInfoSpecificNBDContext' ] + } } + ## # @ImageInfoSpecific: # @@ -137,7 +193,8 @@ # to define a ImageInfoSpecificLUKS 'luks': 'QCryptoBlockInfoLUKS', # Protocol drivers: - 'file': 'ImageInfoSpecificFile' + 'file': 'ImageInfoSpecificFile', + 'nbd': 'ImageInfoSpecificNBD' } } ## diff --git a/block/nbd-client.h b/block/nbd-client.h index cfc90550b99..09f51ca2529 100644 --- a/block/nbd-client.h +++ b/block/nbd-client.h @@ -67,5 +67,6 @@ int coroutine_fn nbd_client_co_block_status(BlockDriverSt= ate *bs, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map, BlockDriverState **file); +ImageInfoSpecific *nbd_client_specific_info(BlockDriverState *bs); #endif /* NBD_CLIENT_H */ diff --git a/block/nbd-client.c b/block/nbd-client.c index 813539676d2..0cc67d45b5e 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -952,6 +952,45 @@ int coroutine_fn nbd_client_co_block_status(BlockDrive= rState *bs, (extent.flags & NBD_STATE_ZERO ? BDRV_BLOCK_ZERO : 0); } +ImageInfoSpecific *nbd_client_specific_info(BlockDriverState *bs) +{ + NBDClientSession *client =3D nbd_get_client_session(bs); + ImageInfoSpecific *info; + ImageInfoSpecificNBD *infonbd; + + info =3D g_new0(ImageInfoSpecific, 1); + info->type =3D IMAGE_INFO_SPECIFIC_KIND_NBD; + infonbd =3D info->u.nbd.data =3D g_new0(ImageInfoSpecificNBD, 1); + + /* TODO: Remember/expose server's description during handshake? */ + if (client->info.flags & NBD_FLAG_HAS_FLAGS) { + uint16_t remaining =3D client->info.flags; + + infonbd->has_flags =3D true; + remaining &=3D ~NBD_FLAG_HAS_FLAGS; + /* TODO: Populate flags */ + if (remaining) { + infonbd->has_unknown_flags =3D true; + infonbd->unknown_flags =3D remaining; + } + } + /* TODO: Populate block sizing */ + if (client->info.base_allocation) { + ImageInfoSpecificNBDContext *context; + + infonbd->has_active_contexts =3D true; + infonbd->active_contexts =3D g_new0(ImageInfoSpecificNBDContextLis= t, 1); + context =3D g_new(ImageInfoSpecificNBDContext, 1); + infonbd->active_contexts->value =3D context; + context->name =3D g_strdup(client->info.x_dirty_bitmap ?: + "base:allocation"); + context->has_id =3D true; + context->id =3D client->info.context_id; + } + /* TODO: Remember/expose non-tracked contexts learned during handshake= ? */ + return info; +} + void nbd_client_detach_aio_context(BlockDriverState *bs) { NBDClientSession *client =3D nbd_get_client_session(bs); diff --git a/block/nbd.c b/block/nbd.c index e87699fb73b..8b6d3d6cf4a 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -576,6 +576,7 @@ static BlockDriver bdrv_nbd =3D { .bdrv_close =3D nbd_close, .bdrv_co_flush_to_os =3D nbd_co_flush, .bdrv_co_pdiscard =3D nbd_client_co_pdiscard, + .bdrv_get_specific_info =3D nbd_client_specific_info, .bdrv_refresh_limits =3D nbd_refresh_limits, .bdrv_getlength =3D nbd_getlength, .bdrv_detach_aio_context =3D nbd_detach_aio_context, @@ -596,6 +597,7 @@ static BlockDriver bdrv_nbd_tcp =3D { .bdrv_close =3D nbd_close, .bdrv_co_flush_to_os =3D nbd_co_flush, .bdrv_co_pdiscard =3D nbd_client_co_pdiscard, + .bdrv_get_specific_info =3D nbd_client_specific_info, .bdrv_refresh_limits =3D nbd_refresh_limits, .bdrv_getlength =3D nbd_getlength, .bdrv_detach_aio_context =3D nbd_detach_aio_context, @@ -616,6 +618,7 @@ static BlockDriver bdrv_nbd_unix =3D { .bdrv_close =3D nbd_close, .bdrv_co_flush_to_os =3D nbd_co_flush, .bdrv_co_pdiscard =3D nbd_client_co_pdiscard, + .bdrv_get_specific_info =3D nbd_client_specific_info, .bdrv_refresh_limits =3D nbd_refresh_limits, .bdrv_getlength =3D nbd_getlength, .bdrv_detach_aio_context =3D nbd_detach_aio_context, --=20 2.20.1