Depending on command line options and server capabilities, nbdinfo has
legitimate reasons to either be in opt mode or fully connected at the
time a handle is ready to close.  Previously, to avoid unwanted error
messages, we had to manually check state to call the correct function
out of nbd_opt_abort or nbd_shutdown that would not fail; but now that
nbd_shutdown has a new flag, it is simpler to not have to worry about
it.

Signed-off-by: Eric Blake <ebl...@redhat.com>
---
 info/list.c | 8 +-------
 info/main.c | 4 +---
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/info/list.c b/info/list.c
index 7848923f..d39e26e6 100644
--- a/info/list.c
+++ b/info/list.c
@@ -62,12 +62,6 @@ collect_exports (void)
     fprintf (stderr, "%s: %s\n", progname, nbd_get_error ());
     exit (EXIT_FAILURE);
   }
-  if (probe_content)
-    /* Disconnect from the server to move the handle into a closed
-     * state, in case the server serializes further connections.
-     * But we can ignore errors in this case.
-     */
-    nbd_opt_abort (nbd);
 }

 void
@@ -127,7 +121,7 @@ list_all_exports (void)
       list_okay = false;

     if (probe_content) {
-      nbd_shutdown (nbd2, 0);
+      nbd_shutdown (nbd2, LIBNBD_SHUTDOWN_COVER_OPT_MODE);
       nbd_close (nbd2);
     }
   }
diff --git a/info/main.c b/info/main.c
index 572dd536..204290a5 100644
--- a/info/main.c
+++ b/info/main.c
@@ -354,9 +354,7 @@ main (int argc, char *argv[])
   }

   free_exports ();
-  if (opt_mode)
-    nbd_opt_abort (nbd);
-  nbd_shutdown (nbd, 0);
+  nbd_shutdown (nbd, LIBNBD_SHUTDOWN_COVER_OPT_MODE);
   nbd_close (nbd);

   /* Close the output stream and copy it to the real stdout. */
-- 
2.41.0

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to