nbd_set_request_meta_context(3)

✨ nbd_set_request_meta_context β€” your girl's guide to libnbd ✨

okay so bestie, grab your iced coffee πŸ“ because today we're talking about nbd_set_request_meta_context(3) from the <libnbd.h> girlies. this one's a setter, it's lowkey powerful, and yes it's giving "small function, big consequences" energy. πŸ’…


🌸 SYNOPSIS 🌸

#include <libnbd.h>

int nbd_set_request_meta_context (
      struct nbd_handle *h, bool request
    );

that's it. that's the whole vibe. one handle, one bool, no cap. ✨


πŸ’– DESCRIPTION πŸ’–

so here's the tea, bestie πŸ«– β€” this function controls whether the actual act of connecting to an export will ALSO try to issue NBD_OPT_SET_META_CONTEXT for you. and when I say "the act of connecting", I mean:

and it only does that little extra step when both of these are true:

  • the server supports structured replies or extended headers, and
  • any contexts were registered by nbd_add_meta_context(3)

default setting? true. iconic. but like… the extra step of negotiating meta contexts is not always desirable, and here's why (per the manpage, not me making stuff up, i promise πŸ™ˆ):

  • performing both info and go on the same export works fine without needing to re-negotiate contexts on that second call β€” so why do the work twice? πŸ’€
  • integration testing of other servers may benefit from manually invoking nbd_opt_set_meta_context(3) at other points in the negotiation sequence β€” main character energy, choosing your own timing πŸŽ€
  • and even when you're just using nbd_opt_info(3), it can be faster to collect the server's results by relying on the callback function you passed to nbd_opt_list_meta_context(3) than by doing a whole series of post-process calls to nbd_can_meta_context(3). efficiency queen 🐝
⚠️ important note, fr fr: this control has no effect if the server doesn't negotiate structured replies or extended headers, or if the client didn't request any contexts via nbd_add_meta_context(3). and heads up β€” setting this control to false may cause nbd_block_status(3) to fail. so like, know what you're doing before you turn it off bestie 😭

πŸ”₯ RETURN VALUE πŸ”₯

if the call is successful, the function returns 0. slay. βœ…


πŸ’€ ERRORS πŸ’€

on error, -1 is returned. not slay. ❌

refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error β€” that's where the actual gossip lives.

also: the following parameters must not be NULL: h. for more info, see "Non-NULL parameters" in libnbd(3). don't pass a null handle, please, i'm begging 🫢


πŸ‘‘ HANDLE STATE πŸ‘‘

nbd_set_request_meta_context can be called when the handle is in the following states β€” vibe check incoming:

  • Handle created, before connecting β€” βœ… allowed
  • Connecting β€” ❌ error
  • Connecting & handshaking (opt_mode) β€” βœ… allowed
  • Connected to the server β€” ❌ error
  • Connection shut down β€” ❌ error
  • Handle dead β€” ❌ error

so basically: before you connect (yes πŸŽ€), or while you're in opt_mode handshaking (yes πŸŽ€). everywhere else? absolutely not, don't even try it πŸ’…


⭐ VERSION ⭐

this function first appeared in libnbd 1.16. a genuine icon of its era πŸ’œ

if you need to test whether this function is available at compile time, check if the following macro is defined:

#define LIBNBD_HAVE_NBD_SET_REQUEST_META_CONTEXT 1

🌈 SEE ALSO 🌈

go read these next, i'm obsessed with all of them:

nbd_add_meta_context(3), nbd_block_status(3), nbd_can_meta_context(3), nbd_create(3), nbd_get_request_meta_context(3), nbd_get_structured_replies_negotiated(3), nbd_opt_go(3), nbd_opt_info(3), nbd_opt_list_meta_context(3), nbd_opt_set_meta_context(3), nbd_set_opt_mode(3), libnbd(3).


🧚 AUTHORS 🧚

  • Eric Blake
  • Richard W.M. Jones

legends, honestly. we stan πŸ’–


Copyright Red Hat


🌸 LICENSE 🌸

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA


and that's the whole page bestie!! πŸ¦‹ written from libnbd-1.25.8, dated 2026-10-13, and we're closing out nbd_set_request_meta_context(3) with a lil kiss 😘 mwah. go negotiate some meta contexts responsibly. πŸ’œβœ¨

πŸ“¦ where this page comes from