On Tue, Sep 05, 2023 at 08:47:34AM -0500, Eric Blake wrote:
diff --git a/info/info-list-uris.sh b/info/info-list-uris.sh
index 0d6a16a0..d8ea9108 100755
--- a/info/info-list-uris.sh
+++ b/info/info-list-uris.sh
@@ -22,7 +22,14 @@ set -e
set -x
requires nbdkit --version
-requires nbdkit file --version
+# Avoid tickling a double-free bug in nbdkit 1.35.11
+requires nbdkit -U- -r file dir=. --run 'nbdsh --opt-mode -u "$uri" -c
"
+try:
+ h.opt_info()
+except nbd.Error:
+ pass
+h.opt_abort()
+"'
# This test requires nbdkit >= 1.22.
I guess the double-free bug is actually in any (or many versions of)
nbdkit between 1.22 and 1.35.11, which is why the requires test is
needed here? The message seems to imply it only affects 1.35.11.
It's a shame that the requires test is so long, but I couldn't see any
way to shorten it.
minor=$( nbdkit --dump-config | grep ^version_minor | cut -d= -f2 )
diff --git a/info/info-uri.sh b/info/info-uri.sh
index d491e904..ba0c36d2 100755
--- a/info/info-uri.sh
+++ b/info/info-uri.sh
@@ -24,7 +24,14 @@ set -e
set -x
requires nbdkit --version
-requires nbdkit file --version
+# Avoid tickling a double-free bug in nbdkit 1.35.11
+requires nbdkit -U- -r file dir=. --run 'nbdsh --opt-mode -u "$uri" -c
"
+try:
+ h.opt_info()
+except nbd.Error:
+ pass
+h.opt_abort()
+"'
requires nbdkit -U - null --run 'test "$uri" != ""'
requires jq --version
diff --git a/info/main.c b/info/main.c
index 204290a5..80d38224 100644
--- a/info/main.c
+++ b/info/main.c
@@ -138,7 +138,6 @@ main (int argc, char *argv[])
size_t output_len = 0;
bool content_flag = false, no_content_flag = false;
bool list_okay = true;
- bool opt_mode = false;
progname = argv[0];
colour = isatty (STDOUT_FILENO);
@@ -281,11 +280,9 @@ main (int argc, char *argv[])
nbd_set_uri_allow_local_file (nbd, true); /* Allow ?tls-psk-file. */
/* Set optional modes in the handle. */
- opt_mode = !can && !map && !size_only;
- if (opt_mode) {
- nbd_set_opt_mode (nbd, true);
+ nbd_set_opt_mode (nbd, true);
+ if (!can && !map && !size_only)
nbd_set_full_info (nbd, true);
- }
if (map)
nbd_add_meta_context (nbd, map);
@@ -398,6 +395,13 @@ do_connect (struct nbd_handle *nbd)
fprintf (stderr, "%s: %s\n", progname, nbd_get_error ());
exit (EXIT_FAILURE);
}
+
+ /* If we are in opt mode, request info on the original export name.
+ * However, ignoring failure at this time is okay, as later code
+ * may want to try an alternate export name.
+ */
+ if (nbd_aio_is_negotiating (nbd))
+ nbd_opt_info (nbd);
I maybe don't fully understand when nbd_aio_is_negotiating would not
be true. Aren't we always in opt mode now?
}
/* The URI field in output is not meaningful unless there's a
diff --git a/info/map.c b/info/map.c
index 594f24ff..399e0355 100644
--- a/info/map.c
+++ b/info/map.c
@@ -54,6 +54,13 @@ do_map (void)
uint64_t offset, align, max_len;
size_t prev_entries_size;
+ /* Map mode requires switching over to transmission phase. */
+ if (nbd_aio_is_negotiating (nbd) &&
+ nbd_opt_go (nbd) == -1) {
+ fprintf (stderr, "%s: %s\n", progname, nbd_get_error ());
+ exit (EXIT_FAILURE);
+ }
+
/* Did we get the requested map? */
if (!nbd_can_meta_context (nbd, map)) {
fprintf (stderr,
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v