aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2023-06-08 08:56:37 -0500
committerEric Blake <eblake@redhat.com>2023-07-19 15:26:13 -0500
commitbfe04d0a7d5e8a4f4c9014ee7622af2056685974 (patch)
tree3d3a227cacfa83af30af271e695d327953952954 /include
parent70fa99f445a6fabe4b46f188cc665cd469cd8293 (diff)
downloadqemu-bfe04d0a7d5e8a4f4c9014ee7622af2056685974.zip
qemu-bfe04d0a7d5e8a4f4c9014ee7622af2056685974.tar.gz
qemu-bfe04d0a7d5e8a4f4c9014ee7622af2056685974.tar.bz2
nbd: Use enum for various negotiation modes
Deciphering the hard-coded list of integer return values from nbd_start_negotiate() will only get more confusing when adding support for 64-bit extended headers. Better is to name things in an enum. Although the function in question is private to client.c, putting the enum in a public header and including an enum-to-string conversion will allow its use in more places in upcoming patches. The enum is intentionally laid out so that operators like <= can be used to group multiple modes with similar characteristics, and where the least powerful mode has value 0, even though this patch does not exploit that. No semantic change intended. Signed-off-by: Eric Blake <eblake@redhat.com> Message-ID: <20230608135653.2918540-9-eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Diffstat (limited to 'include')
-rw-r--r--include/block/nbd.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/block/nbd.h b/include/block/nbd.h
index fb935d5..4428bcf 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -53,6 +53,16 @@ typedef struct NBDOptionReplyMetaContext {
/* metadata context name follows */
} QEMU_PACKED NBDOptionReplyMetaContext;
+/* Track results of negotiation */
+typedef enum NBDMode {
+ /* Keep this list in a continuum of increasing features. */
+ NBD_MODE_OLDSTYLE, /* server lacks newstyle negotiation */
+ NBD_MODE_EXPORT_NAME, /* newstyle but only OPT_EXPORT_NAME safe */
+ NBD_MODE_SIMPLE, /* newstyle but only simple replies */
+ NBD_MODE_STRUCTURED, /* newstyle, structured replies enabled */
+ /* TODO add NBD_MODE_EXTENDED */
+} NBDMode;
+
/* Transmission phase structs
*
* Note: these are _NOT_ the same as the network representation of an NBD
@@ -405,6 +415,7 @@ const char *nbd_rep_lookup(uint32_t rep);
const char *nbd_info_lookup(uint16_t info);
const char *nbd_cmd_lookup(uint16_t info);
const char *nbd_err_lookup(int err);
+const char *nbd_mode_lookup(NBDMode mode);
/* nbd/client-connection.c */
void nbd_client_connection_enable_retry(NBDClientConnection *conn);