The NBD protocol is adding an extension to make it possible for servers to advertise to the client if the export is known to start life as a sparse file or with all-zero state. Although this extension is optional, clients can take advantage of it during certain operations (such as making image copying more efficient by not having to request a pre-zeroing pass). This patch exposes the constants that will be used by nbdkit, as well as shared in libnbd for client side use.
Signed-off-by: Eric Blake <[email protected]> --- common/protocol/nbd-protocol.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/common/protocol/nbd-protocol.h b/common/protocol/nbd-protocol.h index df0b4c6..50531a0 100644 --- a/common/protocol/nbd-protocol.h +++ b/common/protocol/nbd-protocol.h @@ -1,5 +1,5 @@ /* nbdkit - * Copyright (C) 2013-2019 Red Hat Inc. + * Copyright (C) 2013-2020 Red Hat Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -146,6 +146,7 @@ struct nbd_fixed_new_option_reply { #define NBD_INFO_NAME 1 #define NBD_INFO_DESCRIPTION 2 #define NBD_INFO_BLOCK_SIZE 3 +#define NBD_INFO_INIT_STATE 4 /* NBD_INFO_EXPORT reply (follows fixed_new_option_reply). */ struct nbd_fixed_new_option_reply_info_export { @@ -154,6 +155,16 @@ struct nbd_fixed_new_option_reply_info_export { uint16_t eflags; /* per-export flags */ } NBD_ATTRIBUTE_PACKED; +/* NBD_INFO_INIT_STATE reply. */ +struct nbd_fixed_new_option_reply_info_init { + uint16_t info; /* NBD_INFO_INIT_STATE */ + uint16_t flags; /* per-export init flags */ +} NBD_ATTRIBUTE_PACKED; + +/* Constants for use in reply to NBD_INFO_INIT_STATE. */ +#define NBD_INIT_SPARSE (1 << 0) +#define NBD_INIT_ZERO (1 << 1) + /* NBD_REP_META_CONTEXT reply (follows fixed_new_option_reply). */ struct nbd_fixed_new_option_reply_meta_context { uint32_t context_id; /* metadata context ID */ -- 2.24.1 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
