Eric Blake
2022-Aug-31 14:39 UTC
[Libguestfs] [libnbd PATCH v2 06/12] info: Explicitly skip NBD_OPT_SET_META_CONTEXT in --list mode
When listing information about an export, we do not use nbd_block_status() or nbd_can_meta_context(), because we were already utilizing the callback to nbd_opt_list_meta_context() to collect supported context names. In practice, because we also never called nbd_add_meta_context() (important because nbd_opt_list_meta_context() only outputs all possible contexts when passed an empty list on input), we were not causing nbd_opt_info() to invoke NBD_OPT_SET_META_CONTEXT (SET on an empty list selects nothing, so the state machine short-circuits that step). However, now that we have the API to express our intentions, we might as well be explicit that we don't need the server to set any contexts, even if such a change does not impact the amount of traffic sent over the wire in list mode. --- info/list.c | 3 ++- info/show.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/info/list.c b/info/list.c index 7646bf1..c2741ba 100644 --- a/info/list.c +++ b/info/list.c @@ -1,5 +1,5 @@ /* NBD client library in userspace - * Copyright (C) 2020-2021 Red Hat Inc. + * Copyright (C) 2020-2022 Red Hat Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -104,6 +104,7 @@ list_all_exports (void) } nbd_set_uri_allow_local_file (nbd2, true); /* Allow ?tls-psk-file. */ nbd_set_opt_mode (nbd2, true); + nbd_set_request_meta_context (nbd2, false); nbd_set_full_info (nbd2, true); do_connect (nbd2); diff --git a/info/show.c b/info/show.c index 79038b0..4bf5967 100644 --- a/info/show.c +++ b/info/show.c @@ -1,5 +1,5 @@ /* NBD client library in userspace - * Copyright (C) 2020-2021 Red Hat Inc. + * Copyright (C) 2020-2022 Red Hat Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -65,6 +65,7 @@ show_one_export (struct nbd_handle *nbd, const char *desc, * advertising something it later refuses to serve), return rather * than exit, to allow output on the rest of the list. */ + nbd_set_request_meta_context (nbd, false); if (nbd_aio_is_negotiating (nbd) && nbd_opt_info (nbd) == -1 && nbd_opt_go (nbd) == -1) { -- 2.37.2
Laszlo Ersek
2022-Sep-09 04:55 UTC
[Libguestfs] [libnbd PATCH v2 06/12] info: Explicitly skip NBD_OPT_SET_META_CONTEXT in --list mode
On 08/31/22 16:39, Eric Blake wrote:> When listing information about an export, we do not use > nbd_block_status() or nbd_can_meta_context(), because we were already > utilizing the callback to nbd_opt_list_meta_context() to collect > supported context names. In practice, because we also never called > nbd_add_meta_context() (important because nbd_opt_list_meta_context() > only outputs all possible contexts when passed an empty list on > input), we were not causing nbd_opt_info() to invoke > NBD_OPT_SET_META_CONTEXT (SET on an empty list selects nothing, so the > state machine short-circuits that step). However, now that we have > the API to express our intentions, we might as well be explicit that > we don't need the server to set any contexts, even if such a change > does not impact the amount of traffic sent over the wire in list mode. > --- > info/list.c | 3 ++- > info/show.c | 3 ++- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/info/list.c b/info/list.c > index 7646bf1..c2741ba 100644 > --- a/info/list.c > +++ b/info/list.c > @@ -1,5 +1,5 @@ > /* NBD client library in userspace > - * Copyright (C) 2020-2021 Red Hat Inc. > + * Copyright (C) 2020-2022 Red Hat Inc. > * > * This library is free software; you can redistribute it and/or > * modify it under the terms of the GNU Lesser General Public > @@ -104,6 +104,7 @@ list_all_exports (void) > } > nbd_set_uri_allow_local_file (nbd2, true); /* Allow ?tls-psk-file. */ > nbd_set_opt_mode (nbd2, true); > + nbd_set_request_meta_context (nbd2, false); > nbd_set_full_info (nbd2, true); > > do_connect (nbd2); > diff --git a/info/show.c b/info/show.c > index 79038b0..4bf5967 100644 > --- a/info/show.c > +++ b/info/show.c > @@ -1,5 +1,5 @@ > /* NBD client library in userspace > - * Copyright (C) 2020-2021 Red Hat Inc. > + * Copyright (C) 2020-2022 Red Hat Inc. > * > * This library is free software; you can redistribute it and/or > * modify it under the terms of the GNU Lesser General Public > @@ -65,6 +65,7 @@ show_one_export (struct nbd_handle *nbd, const char *desc, > * advertising something it later refuses to serve), return rather > * than exit, to allow output on the rest of the list. > */ > + nbd_set_request_meta_context (nbd, false); > if (nbd_aio_is_negotiating (nbd) && > nbd_opt_info (nbd) == -1 && > nbd_opt_go (nbd) == -1) { >Acked-by: Laszlo Ersek <lersek at redhat.com>