[Libguestfs] [PATCH nbdkit 3/4] common/protocol: Update nbd-protocol.h so it matches libnbd’s copy.

Eric Blake eblake at redhat.com
Tue Sep 24 22:20:10 UTC 2019


On 9/24/19 4:07 PM, Richard W.M. Jones wrote:
> Diff against libnbd’s copy of this file, and change this one until it
> matches.
> ---
>  common/protocol/nbd-protocol.h       | 76 +++++++++++++++++-----------
>  server/protocol-handshake-newstyle.c | 26 +++++-----
>  server/protocol-handshake-oldstyle.c |  4 +-
>  server/protocol.c                    | 25 ++++-----
>  tests/test-layers.c                  | 14 ++---
>  5 files changed, 81 insertions(+), 64 deletions(-)
> 
> diff --git a/common/protocol/nbd-protocol.h b/common/protocol/nbd-protocol.h
> index 60d35d0..724ffb6 100644
> --- a/common/protocol/nbd-protocol.h
> +++ b/common/protocol/nbd-protocol.h
> @@ -40,37 +40,46 @@
>   * these structures.
>   */
>  
> +#define NBD_MAX_STRING 4096 /* Maximum length of a string field */
> +
>  /* Old-style handshake. */
> -struct old_handshake {
> +struct nbd_old_handshake {
>    char nbdmagic[8];           /* "NBDMAGIC" */
> -  uint64_t version;           /* OLD_VERSION */
> +  uint64_t version;           /* NBD_OLD_VERSION */
>    uint64_t exportsize;
>    uint16_t gflags;            /* global flags */
>    uint16_t eflags;            /* per-export flags */

Different from the current NBD protocol spec, which calls out uint64_t
exportsize, uint32_t eflags (partly to emphasize that no oldstyle server
will ever set gflags).  The difference is not fatal.


>  
> +/* Newstyle handshake OPT_EXPORT_NAME reply message. */
> +struct nbd_export_name_option_reply {
> +  uint64_t exportsize;          /* size of export */
> +  uint16_t eflags;              /* per-export flags */
> +  char zeroes[124];             /* optional zeroes */
> +} __attribute__((packed));;

Double ;;


>  
>  #define NBD_INFO_EXPORT      0

We're missing other defined NBD_INFO_* constants (from both projects);
we'll get there when we add support for block size constraints, but
could add them now (even if they remain unused a bit longer) if desired.
 Probably as a separate patch.


> @@ -144,14 +157,14 @@ struct block_descriptor {
>  /* New-style handshake server reply when using NBD_OPT_EXPORT_NAME.
>   * Modern clients use NBD_OPT_GO instead of this.
>   */
> -struct new_handshake_finish {
> +struct nbd_new_handshake_finish {
>    uint64_t exportsize;
>    uint16_t eflags;            /* per-export flags */
>    char zeroes[124];           /* must be sent as zero bytes */
>  } __attribute__((packed));

Redundant with nbd_export_name_option_reply.

Otherwise looks good.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190924/aa0ae60d/attachment.sig>


More information about the Libguestfs mailing list