Since NBD_OPT_LIST_META_CONTEXTS is stateless from the server's point of view, there is no reason to make it clear state on the client's side. A previous patch already fixed it to not wipe h->meta_contexts for NBD_OPT_LIST_META_CONTEXTS (since that tracks the server state affected only by NBD_OPT_SET_META_CONTEXTS); but we were still wiping h->exportsize and friends. Better is to wipe size information only if we actually enter NEWSTYLE.OPT_GO.START to attempt NBD_OPT_GO or NBD_OPT_INFO. This change will also help when a future patch adds nbd_opt_set_meta_context() as another API that wants to modify h->meta_contexts but not h->exportsize.
Testsuite coverage for this is in the next patch, for ease of review (that is, this is one case where it is easy to swap the patch order to see a failure fixed by this patch). --- generator/states-newstyle-opt-go.c | 1 + generator/states-newstyle-opt-meta-context.c | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/generator/states-newstyle-opt-go.c b/generator/states-newstyle-opt-go.c index 3c29137d..9881d0f2 100644 --- a/generator/states-newstyle-opt-go.c +++ b/generator/states-newstyle-opt-go.c @@ -22,6 +22,7 @@ STATE_MACHINE { NEWSTYLE.OPT_GO.START: uint16_t nrinfos = 0; + nbd_internal_reset_size_and_flags (h); if (h->request_block_size) nrinfos++; if (h->full_info) diff --git a/generator/states-newstyle-opt-meta-context.c b/generator/states-newstyle-opt-meta-context.c index 5dc7e9ad..e124d06f 100644 --- a/generator/states-newstyle-opt-meta-context.c +++ b/generator/states-newstyle-opt-meta-context.c @@ -35,16 +35,15 @@ NEWSTYLE.OPT_META_CONTEXT.START: * nbd_opt_list_meta_context() * -> unconditionally use LIST, next state NEGOTIATING * - * For now, we start by unconditionally clearing h->exportsize and friends. * If SET is conditional, we skip it if h->request_meta is false, if * structured replies were not negotiated, or if no contexts to request. - * SET then manipulates h->meta_contexts, and sets h->meta_valid on success. + * SET then manipulates h->meta_contexts, and sets h->meta_valid on + * success, while LIST is stateless. * If OPT_GO is later successful, it populates h->exportsize and friends, * and also sets h->meta_valid if h->request_meta but we skipped SET here. * There is a callback if and only if the command is LIST. */ assert (h->gflags & LIBNBD_HANDSHAKE_FLAG_FIXED_NEWSTYLE); - nbd_internal_reset_size_and_flags (h); if (h->opt_current == NBD_OPT_LIST_META_CONTEXT) { assert (h->opt_mode); assert (CALLBACK_IS_NOT_NULL (h->opt_cb.fn.context)); -- 2.37.3 _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://listman.redhat.com/mailman/listinfo/libguestfs