nbd_aio_opt_go(3)

πŸ’… nbd_aio_opt_go β€” libnbd, bestie edition

okay so this is the nbd_aio_opt_go(3) page, like from the LIBNBD manual, and it's literally the "we're done negotiating, let's GO" button. no cap. ✨


🌸 NAME 🌸

nbd_aio_opt_go β€” end negotiation and move on to using an export πŸŽ€


✨ SYNOPSIS ✨

#include <libnbd.h>

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

int nbd_aio_opt_go (
      struct nbd_handle *h,
      nbd_completion_callback completion_callback
    );

πŸ¦‹ DESCRIPTION πŸ¦‹

So basically you're sliding this function a request: "hey server, u done negotiating? cool, now serve me the export I already picked." 🫢 And which export is that? The one you set with the most recent nbd_set_export_name(3) or nbd_connect_uri(3). iykyk.

Important vibe check: this only works if nbd_set_opt_mode(3) turned option mode ON. no option mode, no deal, periodt.

Now, how do you know when the request finished? Two ways, both iconic:

  • wait for nbd_aio_is_connecting(3) to return false β€” that's your signal πŸŽ€
  • or pass the optional "completion_callback", which gets invoked exactly as described in "Completion callbacks" in libnbd(3) β€” except it's automatically retired regardless of return value. yes, even if it returns something weird. she's retired, she's resting, don't @ her.

And here's the tea β˜•: directly detecting whether the server returned an error β€” which is what the return value of the synchronous counterpart does β€” is only possible with a completion callback. but!! you can also indirectly detect an error when nbd_aio_is_negotiating(3) returns true. sneaky but valid. πŸ’…


πŸ”₯ RETURN VALUE πŸ”₯

If the call is successful, the function returns 0. slay. ✨


πŸ’€ ERRORS πŸ’€

On error, -1 is returned. 😭

Need the deets on what went wrong? Refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error.

Also, these parameters must not be NULL: "h". For more info, see "Non-NULL parameters" in libnbd(3). don't try it. she will not be nice about it. πŸ™ˆ


πŸ‘‘ HANDLE STATE πŸ‘‘

nbd_aio_opt_go can be called when the handle is in the following state β€” so like, check the vibe first, bestie:

  • 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 yeah, exactly ONE state green-lights you: Connecting & handshaking (opt_mode). all the others? nope, blocked, denied, go home. 🚫


⭐ VERSION ⭐

This function first appeared in libnbd 1.4. she's been around, she's got history, she's a legend. πŸ‘‘

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

#define LIBNBD_HAVE_NBD_AIO_OPT_GO 1

🌈 SEE ALSO 🌈

nbd_aio_is_connecting(3), nbd_aio_is_negotiating(3), nbd_connect_uri(3), nbd_create(3), nbd_opt_go(3), nbd_set_export_name(3), nbd_set_opt_mode(3), libnbd(3).

(the whole friend group, fr fr 🫢)


πŸŽ€ 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 little beauty is from libnbd-1.25.8, dated 2026-10-13, and it lives at nbd_aio_opt_go(3). go forth and negotiate responsibly. πŸ“βœ¨

πŸ“¦ where this page comes from