NBD_AIO_OPT_SET_META_CONTEXT_QUERIES(3)

πŸ’… NAME

nbd_aio_opt_set_meta_context_queries β€” pick exactly which meta contexts you want, with your own explicit query list, bestie ✨

So basically this is the libnbd function (manual name LIBNBD, in case you were wondering πŸŽ€) that lets you hand the server a list of meta contexts and be like "hey, give me back all the ones you actually recognize, k?"


🌸 SYNOPSIS

#include <libnbd.h>

typedef struct {
  int (*callback) (void *user_data, const char *name);
  void *user_data;
  void (*free) (void *user_data);
} nbd_context_callback;

typedef struct {
  int (*callback) (void *user_data, int *error);
  void *user_data;
  void (*free) (void *user_data);
} nbd_completion_callback;

int nbd_aio_opt_set_meta_context_queries (
      struct nbd_handle *h, char **queries,
      nbd_context_callback context_callback,
      nbd_completion_callback completion_callback
    );

✨ DESCRIPTION

okay so. You're asking the server to supply back, like, all the recognized meta contexts that you passed in through queries πŸ”₯ and it does that in conjunction with the export you already specified with the most recent nbd_set_export_name(3) or nbd_connect_uri(3). Iykyk.

⚠️ This can only be used if nbd_set_opt_mode(3) enabled option mode. No opt mode, no deal, bestie.

Normally this function is redundant β€” because nbd_opt_go(3) automatically does the same task for you if structured replies or extended headers have already been negotiated. Like, it's already handled, bestie, you're fine. πŸ’…

But β€” manual control over meta context requests can be genuinely useful for fine-grained testing of how a server handles unusual negotiation sequences πŸ‘‘. Testing vibes, essentially.

Often, use of this function is coupled with nbd_set_request_meta_context(3) to bypass the automatic context request that nbd_opt_go(3) normally performs. Slay.

So how do you know when the request completes? Two ways, pick your fighter:

  • wait for nbd_aio_is_connecting(3) to return false, or
  • supply the optional completion_callback, which will be invoked as described in "Completion callbacks" in libnbd(3) β€” except that it is automatically retired regardless of return value. Periodt.
πŸ’€ Big important note: detecting whether the server returns an error (the way the return value of the synchronous counterpart does it) is only possible with a completion callback. So if you want to know, you gotta pass the callback. No callback, no error knowledge. 😭

πŸ¦‹ RETURN VALUE

This call returns an integer β‰₯ 0. Cute and non-negative. 🫢


🌈 ERRORS

On error -1 is returned. πŸ™ˆ

Refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error. It's all in there, go look.

Also, heads up: the following parameters must not be NULL: h, queries. For more information see "Non-NULL parameters" in libnbd(3). Don't be that person. πŸŽ€


πŸ’œ HANDLE STATE

nbd_aio_opt_set_meta_context_queries can be called when the handle is in the following state:

  • Handle created, before connecting β€” ❌ error
  • Connecting β€” ❌ error
  • Connecting & handshaking (opt_mode) β€” βœ… allowed
  • Connected to the server β€” ❌ error
  • Connection shut down β€” ❌ error
  • Handle dead β€” ❌ error
So like… exactly one situation works. Connecting & handshaking in opt mode. That's the whole vibe check. ⭐

πŸ“ VERSION

This function first appeared in libnbd 1.16. Baby icon.

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

#define LIBNBD_HAVE_NBD_AIO_OPT_SET_META_CONTEXT_QUERIES 1

🧚 SEE ALSO


πŸ‘‘ AUTHORS

Eric Blake

Richard W.M. Jones


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 ✨ this was libnbd-1.25.8, dated 2026-10 β€” go forth and negotiate those meta contexts, you absolute main character πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from