diff mbox series

[1/3] nbd: Preparation for NBD_INFO_INIT_STATE

Message ID 20200210214109.751734-2-eblake@redhat.com (mailing list archive)
State New, archived
Headers show
Series NBD_INFO_INIT_STATE extension | expand

Commit Message

Eric Blake Feb. 10, 2020, 9:41 p.m. UTC
Declare the constants being proposed for an NBD extension, which will
let qemu advertise/learn if an image began life with all zeroes.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 docs/interop/nbd.txt | 1 +
 include/block/nbd.h  | 9 +++++++++
 nbd/common.c         | 2 ++
 3 files changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/docs/interop/nbd.txt b/docs/interop/nbd.txt
index 45118809618e..35ba85367153 100644
--- a/docs/interop/nbd.txt
+++ b/docs/interop/nbd.txt
@@ -55,3 +55,4 @@  the operation of that feature.
 NBD_CMD_BLOCK_STATUS for "qemu:dirty-bitmap:", NBD_CMD_CACHE
 * 4.2: NBD_FLAG_CAN_MULTI_CONN for sharable read-only exports,
 NBD_CMD_FLAG_FAST_ZERO
+* 5.0: NBD_INFO_INIT_STATE
diff --git a/include/block/nbd.h b/include/block/nbd.h
index 7f46932d80f1..0de020904a37 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -200,6 +200,15 @@  enum {
 #define NBD_INFO_NAME           1
 #define NBD_INFO_DESCRIPTION    2
 #define NBD_INFO_BLOCK_SIZE     3
+#define NBD_INFO_INIT_STATE     4
+
+/* Initial state bits, when replying to NBD_INFO_INIT_STATE */
+enum {
+    NBD_INIT_SPARSE_BIT       = 0,
+    NBD_INIT_ZERO_BIT         = 1,
+};
+#define NBD_INIT_SPARSE         (1 << NBD_INIT_SPARSE_BIT)
+#define NBD_INIT_ZERO           (1 << NBD_INIT_ZERO_BIT)

 /* Request flags, sent from client to server during transmission phase */
 #define NBD_CMD_FLAG_FUA        (1 << 0) /* 'force unit access' during write */
diff --git a/nbd/common.c b/nbd/common.c
index ddfe7d118371..3e24feb0d502 100644
--- a/nbd/common.c
+++ b/nbd/common.c
@@ -129,6 +129,8 @@  const char *nbd_info_lookup(uint16_t info)
         return "description";
     case NBD_INFO_BLOCK_SIZE:
         return "block size";
+    case NBD_INFO_INIT_STATE:
+        return "init state";
     default:
         return "<unknown>";
     }