1nbd_add_meta_context(3)             LIBNBD             nbd_add_meta_context(3)
2
3
4

NAME

6       nbd_add_meta_context - ask server to negotiate metadata context
7

SYNOPSIS

9        #include <libnbd.h>
10
11        int nbd_add_meta_context (struct nbd_handle *h,
12                                  const char *name);
13

DESCRIPTION

15       During connection libnbd can negotiate zero or more metadata contexts
16       with the server.  Metadata contexts are features (such as
17       "base:allocation") which describe information returned by the
18       nbd_block_status(3) command (for "base:allocation" this is whether
19       blocks of data are allocated, zero or sparse).
20
21       This call adds one metadata context to the list to be negotiated.  You
22       can call it as many times as needed.  The list is initially empty when
23       the handle is created; you can check the contents of the list with
24       nbd_get_nr_meta_contexts(3) and nbd_get_meta_context(3), or clear it
25       with nbd_clear_meta_contexts(3).
26
27       The NBD protocol limits meta context names to 4096 bytes, but servers
28       may not support the full length.  The encoding of meta context names is
29       always UTF-8.
30
31       Not all servers support all metadata contexts.  To learn if a context
32       was actually negotiated, call nbd_can_meta_context(3) after connecting.
33
34       The single parameter is the name of the metadata context, for example
35       "LIBNBD_CONTEXT_BASE_ALLOCATION".  <libnbd.h> includes defined
36       constants beginning with "LIBNBD_CONTEXT_" for some well-known
37       contexts, but you are free to pass in other contexts.
38
39       Other metadata contexts are server-specific, but include
40       "qemu:dirty-bitmap:..." and "qemu:allocation-depth" for qemu-nbd (see
41       qemu-nbd -B and -A options).
42

RETURN VALUE

44       If the call is successful the function returns 0.
45

ERRORS

47       On error "-1" is returned.
48
49       Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
50       of the error.
51
52       The following parameters must not be NULL: "h", "name".  For more
53       information see "Non-NULL parameters" in libnbd(3).
54

HANDLE STATE

56       The handle must be newly created, or negotiating, otherwise this call
57       will return an error.
58

VERSION

60       This function first appeared in libnbd 1.0.
61
62       If you need to test if this function is available at compile time check
63       if the following macro is defined:
64
65        #define LIBNBD_HAVE_NBD_ADD_META_CONTEXT 1
66

SEE ALSO

68       nbd_block_status(3), nbd_can_meta_context(3),
69       nbd_clear_meta_contexts(3), nbd_create(3), nbd_get_meta_context(3),
70       nbd_get_nr_meta_contexts(3), libnbd(3).
71

AUTHORS

73       Eric Blake
74
75       Richard W.M. Jones
76
78       Copyright (C) 2019-2021 Red Hat Inc.
79

LICENSE

81       This library is free software; you can redistribute it and/or modify it
82       under the terms of the GNU Lesser General Public License as published
83       by the Free Software Foundation; either version 2 of the License, or
84       (at your option) any later version.
85
86       This library is distributed in the hope that it will be useful, but
87       WITHOUT ANY WARRANTY; without even the implied warranty of
88       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
89       Lesser General Public License for more details.
90
91       You should have received a copy of the GNU Lesser General Public
92       License along with this library; if not, write to the Free Software
93       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
94       02110-1301 USA
95
96
97
98libnbd-1.14.2                     2023-01-03           nbd_add_meta_context(3)
Impressum