1nbd_opt_set_meta_context_queries(3) LIBNBD nbd_opt_set_meta_context_queries(3)
2
3
4
6 nbd_opt_set_meta_context_queries - select specific meta contexts, using
7 explicit query list
8
10 #include <libnbd.h>
11
12 typedef struct {
13 int (*callback) (void *user_data, const char *name);
14 void *user_data;
15 void (*free) (void *user_data);
16 } nbd_context_callback;
17
18 int nbd_opt_set_meta_context_queries (
19 struct nbd_handle *h, char **queries,
20 nbd_context_callback context_callback
21 );
22
24 Request that the server supply all recognized meta contexts passed in
25 through "queries", in conjunction with the export previously specified
26 by the most recent nbd_set_export_name(3) or nbd_connect_uri(3). This
27 can only be used if nbd_set_opt_mode(3) enabled option mode. Normally,
28 this function is redundant, as nbd_opt_go(3) automatically does the
29 same task if structured replies have already been negotiated. But
30 manual control over meta context requests can be useful for fine-
31 grained testing of how a server handles unusual negotiation sequences.
32 Often, use of this function is coupled with
33 nbd_set_request_meta_context(3) to bypass the automatic context request
34 normally performed by nbd_opt_go(3).
35
36 The NBD protocol allows a client to decide how many queries to ask the
37 server. This function takes an explicit list of queries; to instead
38 reuse an implicit list, see nbd_opt_set_meta_context(3). Since this
39 function is primarily designed for testing servers, libnbd does not
40 prevent the use of this function on an empty list or when
41 nbd_set_request_structured_replies(3) has disabled structured replies,
42 in order to see how a server behaves.
43
44 The "context" function is called once per server reply, with any
45 "user_data" passed to this function, and with "name" supplied by the
46 server. Additionally, each server name will remain visible through
47 nbd_can_meta_context(3) until the next attempt at
48 nbd_set_export_name(3) or nbd_opt_set_meta_context(3), as well as
49 nbd_opt_go(3) or nbd_opt_info(3) that trigger an automatic meta context
50 request. Remember that it is not safe to call any "nbd_*" APIs from
51 within the context of the callback function. At present, the return
52 value of the callback is ignored, although a return of -1 should be
53 avoided.
54
55 For convenience, when this function succeeds, it returns the number of
56 replies returned by the server.
57
58 Not all servers understand this request, and even when it is
59 understood, the server might intentionally send an empty list because
60 it does not support the requested context, or may encounter a failure
61 after delivering partial results. Thus, this function may succeed even
62 when no contexts are reported, or may fail but have a non-empty list.
63
65 This call returns an integer ≥ 0.
66
68 On error -1 is returned.
69
70 Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
71 of the error.
72
73 The following parameters must not be NULL: "h", "queries". For more
74 information see "Non-NULL parameters" in libnbd(3).
75
77 The handle must be negotiating, otherwise this call will return an
78 error.
79
81 This function first appeared in libnbd 1.16.
82
83 If you need to test if this function is available at compile time check
84 if the following macro is defined:
85
86 #define LIBNBD_HAVE_NBD_OPT_SET_META_CONTEXT_QUERIES 1
87
89 nbd_aio_opt_set_meta_context_queries(3), nbd_can_meta_context(3),
90 nbd_connect_uri(3), nbd_create(3), nbd_opt_go(3), nbd_opt_info(3),
91 nbd_opt_list_meta_context_queries(3), nbd_opt_set_meta_context(3),
92 nbd_set_export_name(3), nbd_set_opt_mode(3),
93 nbd_set_request_meta_context(3), nbd_set_request_structured_replies(3),
94 libnbd(3).
95
97 Eric Blake
98
99 Richard W.M. Jones
100
102 Copyright Red Hat
103
105 This library is free software; you can redistribute it and/or modify it
106 under the terms of the GNU Lesser General Public License as published
107 by the Free Software Foundation; either version 2 of the License, or
108 (at your option) any later version.
109
110 This library is distributed in the hope that it will be useful, but
111 WITHOUT ANY WARRANTY; without even the implied warranty of
112 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
113 Lesser General Public License for more details.
114
115 You should have received a copy of the GNU Lesser General Public
116 License along with this library; if not, write to the Free Software
117 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
118 02110-1301 USA
119
120
121
122libnbd-1.16.5 2023-09-26nbd_opt_set_meta_context_queries(3)