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

HANDLE STATE

53       The handle must be newly created, or negotiating, otherwise this call
54       will return an error.
55

VERSION

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

SEE ALSO

65       nbd_block_status(3), nbd_can_meta_context(3),
66       nbd_clear_meta_contexts(3), nbd_create(3), nbd_get_meta_context(3),
67       nbd_get_nr_meta_contexts(3), libnbd(3).
68

AUTHORS

70       Eric Blake
71
72       Richard W.M. Jones
73
75       Copyright (C) 2019-2021 Red Hat Inc.
76

LICENSE

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