diff options
author | Eric Blake <eblake@redhat.com> | 2016-10-14 13:33:10 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-11-02 09:28:55 +0100 |
commit | c8a3a1b6c4034cf53cdbd953331c72f9573edb77 (patch) | |
tree | 152c60a934b497fd819fdee9025b930727e92c44 /include/block | |
parent | 3668328303429f3bc93ab3365c66331600b06a2d (diff) |
nbd: Share common option-sending code in client
Rather than open-coding each option request, it's easier to
have common helper functions do the work. That in turn requires
having convenient packed types for handling option requests
and replies.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1476469998-28592-9-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/block')
-rw-r--r-- | include/block/nbd.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/include/block/nbd.h b/include/block/nbd.h index a33581b6a9..b69bf1dc68 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -26,15 +26,34 @@ #include "io/channel-socket.h" #include "crypto/tlscreds.h" -/* Note: these are _NOT_ the same as the network representation of an NBD +/* Handshake phase structs - this struct is passed on the wire */ + +struct nbd_option { + uint64_t magic; /* NBD_OPTS_MAGIC */ + uint32_t option; /* NBD_OPT_* */ + uint32_t length; +} QEMU_PACKED; +typedef struct nbd_option nbd_option; + +struct nbd_opt_reply { + uint64_t magic; /* NBD_REP_MAGIC */ + uint32_t option; /* NBD_OPT_* */ + uint32_t type; /* NBD_REP_* */ + uint32_t length; +} QEMU_PACKED; +typedef struct nbd_opt_reply nbd_opt_reply; + +/* Transmission phase structs + * + * Note: these are _NOT_ the same as the network representation of an NBD * request and reply! */ struct NBDRequest { uint64_t handle; uint64_t from; uint32_t len; - uint16_t flags; - uint16_t type; + uint16_t flags; /* NBD_CMD_FLAG_* */ + uint16_t type; /* NBD_CMD_* */ }; typedef struct NBDRequest NBDRequest; |