From 9a8baa8dc37a1bbb32c8c5ddaabad711b39f0a17 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 16 Jul 2025 14:17:14 +0100 Subject: [PATCH] Rebase to libnbd 1.22.2 Synch spec file with Fedora Rawhide. resolves: RHEL-78831 Log the version of libnbd / nbdcopy in virt-v2v output resolves: RHEL-104019 --- ...o-build-target-RUST_TARGET-to-be-set.patch | 51 +++ 0003-maint-Spelling-fixes.patch | 318 ++++++++++++++++++ ...const-correctness-warnings-in-golang.patch | 89 +++++ ...olerate-nbdkit-slop-on-large-extents.patch | 114 +++++++ ...uple-of-minor-features-that-have-bee.patch | 42 +++ ...-ublk-Remove-unused-EXPECTED_VERSION.patch | 28 ++ ...atch => 0008-copy-Add-blkhash-option.patch | 2 +- ...hen-blkhash-size-is-not-a-power-of-2.patch | 2 +- ...e-block_type-outside-of-block-struct.patch | 2 +- ...tch => 0011-copy-Shrink-struct-block.patch | 2 +- ...o-optimization-for-allocated-extents.patch | 2 +- ...ix-corrupted-hash-on-incomplete-read.patch | 2 +- 0014-build-Add-.-configure-with-extra.patch | 76 +++++ 0015-lib-New-API-nbd_get_version_extra.patch | 107 ++++++ ...version-information-in-the-output-of.patch | 268 +++++++++++++++ libnbd.spec | 29 +- 16 files changed, 1120 insertions(+), 14 deletions(-) create mode 100644 0001-rust-Allow-cargo-build-target-RUST_TARGET-to-be-set.patch create mode 100644 0003-maint-Spelling-fixes.patch create mode 100644 0004-generator-Avoid-const-correctness-warnings-in-golang.patch create mode 100644 0005-info-Tolerate-nbdkit-slop-on-large-extents.patch create mode 100644 0006-todo-Remove-a-couple-of-minor-features-that-have-bee.patch create mode 100644 0007-ublk-Remove-unused-EXPECTED_VERSION.patch rename 0001-copy-Add-blkhash-option.patch => 0008-copy-Add-blkhash-option.patch (99%) rename 0002-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch => 0009-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch (94%) rename 0003-copy-Define-block_type-outside-of-block-struct.patch => 0010-copy-Define-block_type-outside-of-block-struct.patch (97%) rename 0004-copy-Shrink-struct-block.patch => 0011-copy-Shrink-struct-block.patch (98%) rename 0005-copy-Enable-zero-optimization-for-allocated-extents.patch => 0012-copy-Enable-zero-optimization-for-allocated-extents.patch (97%) rename 0006-copy-Fix-corrupted-hash-on-incomplete-read.patch => 0013-copy-Fix-corrupted-hash-on-incomplete-read.patch (95%) create mode 100644 0014-build-Add-.-configure-with-extra.patch create mode 100644 0015-lib-New-API-nbd_get_version_extra.patch create mode 100644 0016-tools-Add-extra-version-information-in-the-output-of.patch diff --git a/0001-rust-Allow-cargo-build-target-RUST_TARGET-to-be-set.patch b/0001-rust-Allow-cargo-build-target-RUST_TARGET-to-be-set.patch new file mode 100644 index 0000000..47b8f9a --- /dev/null +++ b/0001-rust-Allow-cargo-build-target-RUST_TARGET-to-be-set.patch @@ -0,0 +1,51 @@ +From 1455311720b64b51a75fbc9f4da3e4a43551df53 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 22 Apr 2025 17:30:02 +0100 +Subject: [PATCH] rust: Allow cargo build --target $RUST_TARGET to be set + +(cherry picked from commit 6bfae4e22aad0d21a326ea2418dbc0d59718e14e) +--- + configure.ac | 2 ++ + rust/Makefile.am | 6 ++++-- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 5feb6dbc..40d4f79f 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -751,6 +751,8 @@ AS_IF([test "x$enable_rust" != "xno"],[ + CARGO=no + ]) + ]) ++ AC_ARG_VAR([RUST_TARGET], ++ [if set, cargo build uses --target $RUST_TARGET]) + ],[CARGO=no]) + AM_CONDITIONAL([HAVE_RUST],[test "x$CARGO" != "xno"]) + +diff --git a/rust/Makefile.am b/rust/Makefile.am +index a7700d69..29c29bd9 100644 +--- a/rust/Makefile.am ++++ b/rust/Makefile.am +@@ -98,15 +98,17 @@ libnbd-sys/libnbd_version: Makefile + $(abs_top_builddir)/run echo $(VERSION) > libnbd-sys/libnbd_version.t + mv libnbd-sys/libnbd_version.t libnbd-sys/libnbd_version + ++RUST_TARGET_PARAM := $(if $(RUST_TARGET),--target $(RUST_TARGET)) ++ + target/debug/liblibnbd.rlib: $(source_files) +- $(abs_top_builddir)/run $(CARGO) build ++ $(abs_top_builddir)/run $(CARGO) build $(RUST_TARGET_PARAM) + + target/doc/libnbd/index.html: $(source_files) + $(abs_top_builddir)/run $(CARGO) doc + + # This will actually build all the examples: + target/debug/examples/get-size: $(source_files) +- $(abs_top_builddir)/run $(CARGO) build --examples ++ $(abs_top_builddir)/run $(CARGO) build $(RUST_TARGET_PARAM) --examples + + if HAVE_POD + +-- +2.47.1 + diff --git a/0003-maint-Spelling-fixes.patch b/0003-maint-Spelling-fixes.patch new file mode 100644 index 0000000..2fc86aa --- /dev/null +++ b/0003-maint-Spelling-fixes.patch @@ -0,0 +1,318 @@ +From 3714f8912d9d1a56866df7309c4e9f0e6e60f809 Mon Sep 17 00:00:00 2001 +From: Eric Blake +Date: Thu, 24 Apr 2025 08:30:00 -0500 +Subject: [PATCH] maint: Spelling fixes + +As detected by: + +$ git ls-files | xargs codespell -L Tage + +Signed-off-by: Eric Blake +(cherry picked from commit 17513dabee51b2bbbe878b06aafc50e6e2ba28de) +--- + copy/file-ops.c | 2 +- + docs/libnbd-release-notes-1.18.pod | 2 +- + docs/libnbd.pod | 4 ++-- + examples/copy-libev.c | 12 ++++++------ + golang/aio_buffer.go | 2 +- + golang/callbacks.go | 2 +- + golang/examples/aio_copy/aio_copy.go | 4 ++-- + golang/libnbd_020_aio_buffer_test.go | 2 +- + golang/libnbd_590_aio_copy_test.go | 2 +- + golang/make-dist.sh | 2 +- + info/main.c | 8 ++++---- + interop/interop.c | 2 +- + ocaml/examples/asynch_copy.ml | 2 +- + ocaml/tests/test_590_aio_copy.ml | 2 +- + rust/cargo_test/README.md | 6 +++--- + rust/tests/test_log/mod.rs | 2 +- + tests/closure-lifetimes.c | 2 +- + 17 files changed, 29 insertions(+), 29 deletions(-) + +diff --git a/copy/file-ops.c b/copy/file-ops.c +index 491a4553..b3b04f5d 100644 +--- a/copy/file-ops.c ++++ b/copy/file-ops.c +@@ -82,7 +82,7 @@ struct rw_file { + bool seek_hole_supported; + int sector_size; + +- /* We try to use the most eficient zeroing first. If an efficent zero ++ /* We try to use the most efficient zeroing first. If an efficient zero + * method is not available, we disable the flag so next time we use + * the working method. + */ +diff --git a/docs/libnbd-release-notes-1.18.pod b/docs/libnbd-release-notes-1.18.pod +index 836ebe19..dc284bf4 100644 +--- a/docs/libnbd-release-notes-1.18.pod ++++ b/docs/libnbd-release-notes-1.18.pod +@@ -145,7 +145,7 @@ Consistently wrap source code at 80 columns (Laszlo Ersek). + + Debug messages no longer print the very verbose state transitions + inside the state machine as these are not usually useful. You can +-reenable this by defining C<-DLIBNBD_STATE_VERBOSE=1> at compile time. ++re-enable this by defining C<-DLIBNBD_STATE_VERBOSE=1> at compile time. + + Completion C<.callback> methods are now always called exactly once, + and documentation is clearer on when this happens (Eric Blake). +diff --git a/docs/libnbd.pod b/docs/libnbd.pod +index 796a6f03..a7039210 100644 +--- a/docs/libnbd.pod ++++ b/docs/libnbd.pod +@@ -936,7 +936,7 @@ it would cause deadlock. + + =head2 Completion callbacks + +-All of the asychronous commands have an optional completion callback ++All of the asynchronous commands have an optional completion callback + function that is used if the call to the asynchronous API reports + success. The completion callback is invoked when the submitted + command is eventually marked complete, after any mid-command callbacks +@@ -976,7 +976,7 @@ callback will still be valid (corresponding to the current portion of + the server's reply), and the overall command will still fail (at the + completion callback or L for an + asynchronous command, or as the result of the overall synchronous +-command). Returing C<-1> from a mid-command callback does not prevent ++command). Returning C<-1> from a mid-command callback does not prevent + that callback from being reached again, if the server sends more + mid-command replies that warrant another use of that callback. A + mid-command callback may be reached more times than expected if the +diff --git a/examples/copy-libev.c b/examples/copy-libev.c +index e8e3cda2..6c91c55d 100644 +--- a/examples/copy-libev.c ++++ b/examples/copy-libev.c +@@ -3,7 +3,7 @@ + * + * http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod + * +- * To build it you need the libev-devel pacakge. ++ * To build it you need the libev-devel package. + * + * To run it: + * +@@ -32,7 +32,7 @@ + + #include + +-/* These values depend on the enviroment tested. ++/* These values depend on the environment tested. + * + * For shared storage using direct I/O: + * +@@ -76,8 +76,8 @@ enum request_state { + IDLE, /* Not used yet. */ + EXTENTS, /* Getting extents from source. */ + READ, /* Read from source. */ +- WRITE, /* Write to destiation. */ +- ZERO, /* Write zeroes to destiation. */ ++ WRITE, /* Write to destination. */ ++ ZERO, /* Write zeroes to destination. */ + SLEEP /* Waiting for extents completion. */ + }; + +@@ -631,12 +631,12 @@ main (int argc, char *argv[]) + + debug = getenv ("COPY_LIBEV_DEBUG") != NULL; + +- /* Configure soruce to report extents. */ ++ /* Configure source to report extents. */ + + if (nbd_add_meta_context (src.nbd, LIBNBD_CONTEXT_BASE_ALLOCATION)) + FAIL ("Cannot add base:allocation: %s", nbd_get_error ()); + +- /* Connecting is fast, so use the syncronous API. */ ++ /* Connecting is fast, so use the synchronous API. */ + + if (nbd_connect_uri (src.nbd, argv[1])) + FAIL ("Cannot connect to source: %s", nbd_get_error ()); +diff --git a/golang/aio_buffer.go b/golang/aio_buffer.go +index 3ddfce94..ff00e0a4 100644 +--- a/golang/aio_buffer.go ++++ b/golang/aio_buffer.go +@@ -80,7 +80,7 @@ func (b *AioBuffer) Bytes() []byte { + + // Slice creates a slice backed by the underlying C array. The slice can be + // used to access or modify the contents of the underlying array. The slice +-// must not be used after caling Free(). ++// must not be used after calling Free(). + func (b *AioBuffer) Slice() []byte { + if b.P == nil { + panic("Using AioBuffer after Free()") +diff --git a/golang/callbacks.go b/golang/callbacks.go +index ac53572c..f9b4958a 100644 +--- a/golang/callbacks.go ++++ b/golang/callbacks.go +@@ -36,7 +36,7 @@ + // - Create an exported Golang function whose job will be to retrieve + // the context and execute the callback in it + // (connErrCallback). Such a function should receive a callback ID +-// and will use it to retrive the context. ++// and will use it to retrieve the context. + // + // - Create a CGO function similar to the above function but with the + // appropriate signature to be registered as a callback in C code +diff --git a/golang/examples/aio_copy/aio_copy.go b/golang/examples/aio_copy/aio_copy.go +index 1de115b1..62756a97 100644 +--- a/golang/examples/aio_copy/aio_copy.go ++++ b/golang/examples/aio_copy/aio_copy.go +@@ -62,8 +62,8 @@ + ) + + // command keeps state of single AioPread call while the read is handled by +-// libnbd, until the command reach the front of the queue and can be writen to +-// the output. ++// libnbd, until the command reach the front of the queue and can be written ++// to the output. + type command struct { + buf libnbd.AioBuffer + ready bool +diff --git a/golang/libnbd_020_aio_buffer_test.go b/golang/libnbd_020_aio_buffer_test.go +index 5e63e27c..8addc350 100644 +--- a/golang/libnbd_020_aio_buffer_test.go ++++ b/golang/libnbd_020_aio_buffer_test.go +@@ -75,7 +75,7 @@ func TestAioBuffer(t *testing.T) { + t.Fatalf("Expected %v, got %v", zeroes, buf2.Bytes()) + } + +- /* Crated a zeroed buffer. */ ++ /* Create a zeroed buffer. */ + buf3 := MakeAioBufferZero(uint(32)) + defer buf.Free() + +diff --git a/golang/libnbd_590_aio_copy_test.go b/golang/libnbd_590_aio_copy_test.go +index 6ae0cc63..410c8f45 100644 +--- a/golang/libnbd_590_aio_copy_test.go ++++ b/golang/libnbd_590_aio_copy_test.go +@@ -86,7 +86,7 @@ func write_completed(buf AioBuffer) int { + return 1 + } + +-/* Copy between two libnbd handles using aynchronous I/O (AIO). */ ++/* Copy between two libnbd handles using asynchronous I/O (AIO). */ + func asynch_copy(t *testing.T, src *Libnbd, dst *Libnbd) { + size, _ := dst.GetSize() + +diff --git a/golang/make-dist.sh b/golang/make-dist.sh +index e6c126c3..03cfc6a2 100755 +--- a/golang/make-dist.sh ++++ b/golang/make-dist.sh +@@ -112,7 +112,7 @@ echo "$info" > $v_dir/$version.info + cp go.mod $v_dir/$version.mod + mv $version.zip $v_dir + +-# Create the list file by amending the curent file on the server. ++# Create the list file by amending the current file on the server. + list_url=https://download.libguestfs.org/libnbd/golang/libguestfs.org/libnbd/@v/list + curl --silent --show-error "$list_url" | sort > $v_dir/list + grep -q "$version" $v_dir/list || echo "$version" >> $v_dir/list +diff --git a/info/main.c b/info/main.c +index 1ee9e329..f7da425f 100644 +--- a/info/main.c ++++ b/info/main.c +@@ -130,7 +130,7 @@ main (int argc, char *argv[]) + { "can", required_argument, NULL, CAN_OPTION }, + { "cannot", required_argument, NULL, CANNOT_OPTION }, + { "can-not", required_argument, NULL, CANNOT_OPTION }, +- { "cant", required_argument, NULL, CANNOT_OPTION }, ++ { "can""t", required_argument, NULL, CANNOT_OPTION }, + { "color", no_argument, NULL, COLOUR_OPTION }, + { "colors", no_argument, NULL, COLOUR_OPTION }, + { "colour", no_argument, NULL, COLOUR_OPTION }, +@@ -144,15 +144,15 @@ main (int argc, char *argv[]) + { "has", required_argument, NULL, CAN_OPTION }, + { "hasnot", required_argument, NULL, CANNOT_OPTION }, + { "has-not", required_argument, NULL, CANNOT_OPTION }, +- { "hasnt", required_argument, NULL, CANNOT_OPTION }, ++ { "hasn""t", required_argument, NULL, CANNOT_OPTION }, + { "have", required_argument, NULL, CAN_OPTION }, +- { "havent", required_argument, NULL, CANNOT_OPTION }, ++ { "haven""t", required_argument, NULL, CANNOT_OPTION }, + { "havenot", required_argument, NULL, CANNOT_OPTION }, + { "have-not", required_argument, NULL, CANNOT_OPTION }, + { "is", required_argument, NULL, CAN_OPTION }, + { "isnot", required_argument, NULL, CANNOT_OPTION }, + { "is-not", required_argument, NULL, CANNOT_OPTION }, +- { "isnt", required_argument, NULL, CANNOT_OPTION }, ++ { "isn""t", required_argument, NULL, CANNOT_OPTION }, + { "json", no_argument, NULL, JSON_OPTION }, + { "list", no_argument, NULL, 'L' }, + { "long-options", no_argument, NULL, LONG_OPTIONS }, +diff --git a/interop/interop.c b/interop/interop.c +index 1ea0216e..841b7c9d 100644 +--- a/interop/interop.c ++++ b/interop/interop.c +@@ -131,7 +131,7 @@ main (int argc, char *argv[]) + * need to have our own log handler. + * + * Also the log levels are quite random. Level 2 doesn't show the +- * negotiated cyphersuite, but level 3+ shows excessive detail. ++ * negotiated ciphersuite, but level 3+ shows excessive detail. + */ + gnutls_global_set_log_level (2); + gnutls_global_set_log_function (tls_log); +diff --git a/ocaml/examples/asynch_copy.ml b/ocaml/examples/asynch_copy.ml +index 7132f573..8962a09e 100644 +--- a/ocaml/examples/asynch_copy.ml ++++ b/ocaml/examples/asynch_copy.ml +@@ -10,7 +10,7 @@ let max_reads_in_flight = 16 + let dir_is_read dir = dir land (Int32.to_int NBD.aio_direction_read) <> 0 + let dir_is_write dir = dir land (Int32.to_int NBD.aio_direction_write) <> 0 + +-(* Copy between two libnbd handles using aynchronous I/O (AIO). *) ++(* Copy between two libnbd handles using asynchronous I/O (AIO). *) + let asynch_copy src dst = + let size = NBD.get_size dst in + +diff --git a/ocaml/tests/test_590_aio_copy.ml b/ocaml/tests/test_590_aio_copy.ml +index 25105e07..b5fb5cd6 100644 +--- a/ocaml/tests/test_590_aio_copy.ml ++++ b/ocaml/tests/test_590_aio_copy.ml +@@ -34,7 +34,7 @@ let bytes_written = ref 0 + let dir_is_read dir = dir land (Int32.to_int NBD.aio_direction_read) <> 0 + let dir_is_write dir = dir land (Int32.to_int NBD.aio_direction_write) <> 0 + +-(* Copy between two libnbd handles using aynchronous I/O (AIO). *) ++(* Copy between two libnbd handles using asynchronous I/O (AIO). *) + let asynch_copy src dst = + let size = NBD.get_size dst in + +diff --git a/rust/cargo_test/README.md b/rust/cargo_test/README.md +index f80646b9..039cdb3e 100644 +--- a/rust/cargo_test/README.md ++++ b/rust/cargo_test/README.md +@@ -1,3 +1,3 @@ +-The solely purpose of this directory is to serve as a test crate for checking if Cargo is useable. +-`cargo test`, `cargo doc` and `cargo fmt` are run in the Autoconf script in this directory. If any of the commands failes, +-Cargo is assumed not to be useable and the Rust bindings will be disabled. ++The sole purpose of this directory is to serve as a test crate for checking if Cargo is usable. ++`cargo test`, `cargo doc` and `cargo fmt` are run in the Autoconf script in this directory. If any of the commands fails, ++Cargo is assumed not to be usable and the Rust bindings will be disabled. +diff --git a/rust/tests/test_log/mod.rs b/rust/tests/test_log/mod.rs +index 8dbcd79f..d3fe98eb 100644 +--- a/rust/tests/test_log/mod.rs ++++ b/rust/tests/test_log/mod.rs +@@ -49,7 +49,7 @@ impl DebugLogger { + } + } + +- /// Check wether a specific message has been logged. ++ /// Check whether a specific message has been logged. + pub fn contains(&self, msg: &str) -> bool { + self.entries.lock().unwrap().iter().any(|(_, x)| x == msg) + } +diff --git a/tests/closure-lifetimes.c b/tests/closure-lifetimes.c +index b9d9ce14..d6625095 100644 +--- a/tests/closure-lifetimes.c ++++ b/tests/closure-lifetimes.c +@@ -156,7 +156,7 @@ main (int argc, char *argv[]) + completion_callback, 0); + if (cookie == -1) NBD_ERROR; + /* read_cb_called is indeterminate at this point, as state machine +- * progress may vary based on task schduling and network speed factors. ++ * progress may vary based on task scheduling and network speed factors. + */ + assert (completion_cb_called == 0); + assert (read_cb_freed == 0); +-- +2.47.1 + diff --git a/0004-generator-Avoid-const-correctness-warnings-in-golang.patch b/0004-generator-Avoid-const-correctness-warnings-in-golang.patch new file mode 100644 index 0000000..8e5014b --- /dev/null +++ b/0004-generator-Avoid-const-correctness-warnings-in-golang.patch @@ -0,0 +1,89 @@ +From 3d7cc461d78451cda566d6994a30ae8e1e789575 Mon Sep 17 00:00:00 2001 +From: Eric Blake +Date: Sat, 31 May 2025 07:37:28 -0500 +Subject: [PATCH] generator: Avoid const-correctness warnings in golang + +Hack the generator to add the necessary casts to discard const in a +way that shuts up the warnings from compiling wrappers.go. + +Signed-off-by: Eric Blake +(cherry picked from commit a909e74f902bb9d1e8a4ab87ae5ccf76d4675787) +--- + generator/C.ml | 10 ++++++---- + generator/C.mli | 2 +- + generator/GoLang.ml | 4 ++-- + 3 files changed, 9 insertions(+), 7 deletions(-) + +diff --git a/generator/C.ml b/generator/C.ml +index ad08437c..50d22306 100644 +--- a/generator/C.ml ++++ b/generator/C.ml +@@ -286,16 +286,16 @@ let print_fndecl ?wrap ?closure_style name args optargs ret = + pr "\n LIBNBD_ATTRIBUTE_NONNULL (%s);\n" (String.concat ", " nns) + + let rec print_cbarg_list ?(wrap = false) ?maxcol ?types ?(parens = true) +- cbargs = ++ ?(noconst = false) cbargs = + if parens then pr "("; + if wrap then + pr_wrap ?maxcol ',' +- (fun () -> print_cbarg_list' ?types cbargs) ++ (fun () -> print_cbarg_list' ?types noconst cbargs) + else +- print_cbarg_list' ?types cbargs; ++ print_cbarg_list' ?types noconst cbargs; + if parens then pr ")" + +-and print_cbarg_list' ?(types = true) cbargs = ++and print_cbarg_list' ?(types = true) noconst cbargs = + if types then pr "void *"; + pr "user_data"; + +@@ -316,6 +316,7 @@ and print_cbarg_list' ?(types = true) cbargs = + | CBArrayAndLen _ -> assert false + | CBBytesIn (n, len) -> + if types then pr "const void *"; ++ if noconst then pr "(void *)"; + pr "%s, " n; + if types then pr "size_t "; + pr "%s" len +@@ -331,6 +332,7 @@ and print_cbarg_list' ?(types = true) cbargs = + | CBMutable arg -> assert false + | CBString n -> + if types then pr "const char *"; ++ if noconst then pr "(char *)"; + pr "%s" n + | CBUInt n -> + if types then pr "unsigned "; +diff --git a/generator/C.mli b/generator/C.mli +index a4b31351..75d77276 100644 +--- a/generator/C.mli ++++ b/generator/C.mli +@@ -34,7 +34,7 @@ val print_arg_list : ?wrap:bool -> ?maxcol:int -> + ?closure_style:closure_style -> + API.arg list -> API.optarg list -> unit + val print_cbarg_list : ?wrap:bool -> ?maxcol:int -> +- ?types:bool -> ?parens:bool -> ++ ?types:bool -> ?parens:bool -> ?noconst:bool -> + API.cbarg list -> unit + val print_call : ?wrap:bool -> ?maxcol:int -> + ?closure_style:closure_style -> +diff --git a/generator/GoLang.ml b/generator/GoLang.ml +index 3fe7cd53..1505a598 100644 +--- a/generator/GoLang.ml ++++ b/generator/GoLang.ml +@@ -159,9 +159,9 @@ let print_callback_wrapper { cbname; cbargs } = + C.print_cbarg_list ~wrap:true cbargs; + pr "\n"; + pr "{\n"; +- pr " // golang isn't const-correct, there will be warnings here:\n"; ++ pr " // golang isn't const-correct, casts avoid warnings here:\n"; + pr " return %s_callback ((long *)" cbname; +- C.print_cbarg_list ~types:false ~parens:false cbargs; ++ C.print_cbarg_list ~types:false ~parens:false ~noconst:true cbargs; + pr ");\n"; + pr "}\n"; + pr "\n"; +-- +2.47.1 + diff --git a/0005-info-Tolerate-nbdkit-slop-on-large-extents.patch b/0005-info-Tolerate-nbdkit-slop-on-large-extents.patch new file mode 100644 index 0000000..02472a5 --- /dev/null +++ b/0005-info-Tolerate-nbdkit-slop-on-large-extents.patch @@ -0,0 +1,114 @@ +From 5fef22179c1ce7e032a773733073349d90aab155 Mon Sep 17 00:00:00 2001 +From: Eric Blake +Date: Sat, 31 May 2025 08:24:37 -0500 +Subject: [PATCH] info: Tolerate nbdkit slop on large extents + +The NBD spec currently requires servers to send aligned block extents +back if the client and server agreed to a minimum block size; but +nbdkit 1.42 has an issue where the server recognizes that a plugin +reporting an aligned extent of exactly 4G is too large for a 32-bit +block status response, and truncates it early but to an unaligned +offset (such a truncation is to an offset larger than the client's +request size). Although I'm also submitting a parallel patch to the +NBD spec to relax things on this front, and to nbdkit 1.44 to report +aligned offsets in the first place, it is still worth teaching nbdinfo +to work around this shortcoming of existing nbdkit releases. The +added test fails when applied in isolation without the corresponding +map.c changes and run against nbdkit 1.42. + +Signed-off-by: Eric Blake +(cherry picked from commit 7dc75f2542a003c7429f1af93b7ecbaef00b567c) +--- + info/Makefile.am | 1 + + info/info-map-large-extent.sh | 42 +++++++++++++++++++++++++++++++++++ + info/map.c | 12 +++++++++- + 3 files changed, 54 insertions(+), 1 deletion(-) + create mode 100755 info/info-map-large-extent.sh + +diff --git a/info/Makefile.am b/info/Makefile.am +index 21cf3f46..697bb2b6 100644 +--- a/info/Makefile.am ++++ b/info/Makefile.am +@@ -49,6 +49,7 @@ info_sh_files = \ + info-map-base-allocation-large.sh \ + info-map-base-allocation-weird.sh \ + info-map-base-allocation-zero.sh \ ++ info-map-large-extent.sh \ + info-map-qemu-dirty-bitmap.sh \ + info-map-qemu-allocation-depth.sh \ + info-map-totals.sh \ +diff --git a/info/info-map-large-extent.sh b/info/info-map-large-extent.sh +new file mode 100755 +index 00000000..91867275 +--- /dev/null ++++ b/info/info-map-large-extent.sh +@@ -0,0 +1,42 @@ ++#!/usr/bin/env bash ++# nbd client library in userspace ++# Copyright Red Hat ++# ++# 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 ++ ++. ../tests/functions.sh ++ ++set -e ++set -x ++ ++requires $NBDKIT --version ++requires $NBDKIT -U - --filter=blocksize-policy data 1 --run 'test "$uri" != ""' ++ ++out=info-map-large-extent.out ++cleanup_fn rm -f $out ++rm -f $out ++ ++# nbdkit < 1.44 had a bug where 4G large extents would truncate larger than ++# the aligned request; whether or not nbdkit is fixed, we can work around it. ++$NBDKIT -U - data data='@4294967296 1 @^512' \ ++ --filter=blocksize-policy blocksize-minimum=512 \ ++ --run '$VG nbdinfo --map "$uri"' > $out ++ ++cat $out ++ ++diff -u - $out < max_len) { ++ entries.ptr[i].length = max_len; ++ entries.len = i + 1; ++ } + offset += entries.ptr[i].length; ++ } + } + + if (!totals) +-- +2.47.1 + diff --git a/0006-todo-Remove-a-couple-of-minor-features-that-have-bee.patch b/0006-todo-Remove-a-couple-of-minor-features-that-have-bee.patch new file mode 100644 index 0000000..c5674be --- /dev/null +++ b/0006-todo-Remove-a-couple-of-minor-features-that-have-bee.patch @@ -0,0 +1,42 @@ +From 2a8dbd3840c7b01e7c544035749d3fde893923ed Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Sat, 12 Jul 2025 18:12:42 +0100 +Subject: [PATCH] todo: Remove a couple of minor features that have been + implemented + +Rust was implemented in 2023. + +nbdcopy implemented page cache efficient operations. + +(cherry picked from commit fe284d59fa0e5a85a4abac418efb8b79d81cdbb5) +--- + TODO | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/TODO b/TODO +index e140b4fd..426b0384 100644 +--- a/TODO ++++ b/TODO +@@ -1,10 +1,6 @@ + Explore if nbd_aio_notify_error is needed for faster response if + server goes away. + +-Bindings in other languages. +- - Latest attempt at adding Rust: +- https://www.redhat.com/archives/libguestfs/2019-August/msg00416.html +- + Example code integrating with ppoll, pollfd, APR pollset (and others?). + + NBD resize extension. +@@ -32,8 +28,6 @@ nbdcopy: + - Synchronous loop should be adjusted to take into account + the NBD preferred block size, as was done for multi-thread loop. + - Benchmark. +- - Better page cache usage, see nbdkit-file-plugin options +- fadvise=sequential cache=none. + - Consider io_uring if there are performance bottlenecks. + - Configurable retries in response to read or write failures. + +-- +2.47.1 + diff --git a/0007-ublk-Remove-unused-EXPECTED_VERSION.patch b/0007-ublk-Remove-unused-EXPECTED_VERSION.patch new file mode 100644 index 0000000..00ea8e0 --- /dev/null +++ b/0007-ublk-Remove-unused-EXPECTED_VERSION.patch @@ -0,0 +1,28 @@ +From 5717b3a12ed7df158abf89fc79d030c415c1a113 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 16 Jul 2025 12:31:33 +0100 +Subject: [PATCH] ublk: Remove unused EXPECTED_VERSION + +Probably we should test nbdublk --version. As we do not, this +variable was not used. + +(cherry picked from commit 01f5d93d43f7eab0444c87d9d99e2ecea9bf9d44) +--- + ublk/Makefile.am | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/ublk/Makefile.am b/ublk/Makefile.am +index 667d7d0c..e06e4396 100644 +--- a/ublk/Makefile.am ++++ b/ublk/Makefile.am +@@ -24,7 +24,6 @@ EXTRA_DIST = \ + TESTS_ENVIRONMENT = \ + LIBNBD_DEBUG=1 \ + $(MALLOC_CHECKS) \ +- EXPECTED_VERSION=$(VERSION) \ + $(NULL) + LOG_COMPILER = $(top_builddir)/run + TESTS = +-- +2.47.1 + diff --git a/0001-copy-Add-blkhash-option.patch b/0008-copy-Add-blkhash-option.patch similarity index 99% rename from 0001-copy-Add-blkhash-option.patch rename to 0008-copy-Add-blkhash-option.patch index 1ed32d3..9397cc6 100644 --- a/0001-copy-Add-blkhash-option.patch +++ b/0008-copy-Add-blkhash-option.patch @@ -1,4 +1,4 @@ -From de3038e45dde22cf85961966bfe9bcf6b45e2b14 Mon Sep 17 00:00:00 2001 +From 028271bfaa85afeb6f74cb754655efe463e1b884 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 29 Mar 2025 11:46:52 +0000 Subject: [PATCH] copy: Add --blkhash option diff --git a/0002-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch b/0009-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch similarity index 94% rename from 0002-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch rename to 0009-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch index 53f1b23..a1b8f8b 100644 --- a/0002-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch +++ b/0009-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch @@ -1,4 +1,4 @@ -From 2dd76033ddf81ac21fc1113e1b99ff9c8c354ee5 Mon Sep 17 00:00:00 2001 +From d19e6eb145d93c827c5acf1b4c009ff27749a205 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 7 Apr 2025 11:35:25 +0100 Subject: [PATCH] copy: Fix crash when blkhash size is not a power of 2 diff --git a/0003-copy-Define-block_type-outside-of-block-struct.patch b/0010-copy-Define-block_type-outside-of-block-struct.patch similarity index 97% rename from 0003-copy-Define-block_type-outside-of-block-struct.patch rename to 0010-copy-Define-block_type-outside-of-block-struct.patch index a825abc..7b53b40 100644 --- a/0003-copy-Define-block_type-outside-of-block-struct.patch +++ b/0010-copy-Define-block_type-outside-of-block-struct.patch @@ -1,4 +1,4 @@ -From d6518adef678ac1676d30f2b6fa9297b6f32db73 Mon Sep 17 00:00:00 2001 +From f48db2429c5aa5f56018baa18c2aa37f756975ef Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Sun, 13 Apr 2025 14:51:09 +0000 Subject: [PATCH] copy: Define block_type outside of block struct diff --git a/0004-copy-Shrink-struct-block.patch b/0011-copy-Shrink-struct-block.patch similarity index 98% rename from 0004-copy-Shrink-struct-block.patch rename to 0011-copy-Shrink-struct-block.patch index bff83f7..f3a3397 100644 --- a/0004-copy-Shrink-struct-block.patch +++ b/0011-copy-Shrink-struct-block.patch @@ -1,4 +1,4 @@ -From 7546ba20ec4ddf7e4b1137b294873c4c49b52c99 Mon Sep 17 00:00:00 2001 +From 361ae3810398d0d5c3550267b0470ba235d94c32 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Sun, 13 Apr 2025 14:54:31 +0000 Subject: [PATCH] copy: Shrink struct block diff --git a/0005-copy-Enable-zero-optimization-for-allocated-extents.patch b/0012-copy-Enable-zero-optimization-for-allocated-extents.patch similarity index 97% rename from 0005-copy-Enable-zero-optimization-for-allocated-extents.patch rename to 0012-copy-Enable-zero-optimization-for-allocated-extents.patch index d7edf10..686063f 100644 --- a/0005-copy-Enable-zero-optimization-for-allocated-extents.patch +++ b/0012-copy-Enable-zero-optimization-for-allocated-extents.patch @@ -1,4 +1,4 @@ -From 46d67e16fd65aad6f9f795dfcefcfc19a0e419eb Mon Sep 17 00:00:00 2001 +From d57d58ba193674bef225f0e7094b0efbaa47f680 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Sun, 13 Apr 2025 23:39:15 +0000 Subject: [PATCH] copy: Enable zero optimization for allocated extents diff --git a/0006-copy-Fix-corrupted-hash-on-incomplete-read.patch b/0013-copy-Fix-corrupted-hash-on-incomplete-read.patch similarity index 95% rename from 0006-copy-Fix-corrupted-hash-on-incomplete-read.patch rename to 0013-copy-Fix-corrupted-hash-on-incomplete-read.patch index a53f2ea..56e25cb 100644 --- a/0006-copy-Fix-corrupted-hash-on-incomplete-read.patch +++ b/0013-copy-Fix-corrupted-hash-on-incomplete-read.patch @@ -1,4 +1,4 @@ -From a15fc80c4fd558509a3a8b5cf96bec27c483e656 Mon Sep 17 00:00:00 2001 +From 4db52aea6b2c92e7dd199d5ce00f74d107f7f2f3 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Mon, 14 Apr 2025 21:40:16 +0000 Subject: [PATCH] copy: Fix corrupted hash on incomplete read diff --git a/0014-build-Add-.-configure-with-extra.patch b/0014-build-Add-.-configure-with-extra.patch new file mode 100644 index 0000000..5e4e3ba --- /dev/null +++ b/0014-build-Add-.-configure-with-extra.patch @@ -0,0 +1,76 @@ +From 327d819d8e8161c31da903e8171a89db97862951 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 16 Jul 2025 12:24:12 +0100 +Subject: [PATCH] build: Add ./configure --with-extra="..." + +This is intended for downstream packagers to use, to provide extra +information about the version of the downstream package (such as the +RPM ENVR). This helps when identifying bugs, especially in packges +which have extensive backports (such as the RHEL packages). This is +the same as the equivalent option in nbdkit. + +In Fedora we intend to use this in the spec file: + + ./configure --with-extra='%{name}-%{version}-%{release}' + +resulting in an extra version string something like "libnbd-1.23.4-1.fc43". + +(cherry picked from commit a04cda6938a9f60b26cb9aa6d55a0b4ef4d0fe76) +--- + README.md | 13 +++++++++++++ + configure.ac | 15 +++++++++++++++ + 2 files changed, 28 insertions(+) + +diff --git a/README.md b/README.md +index 0f6bcdd4..385c0e58 100644 +--- a/README.md ++++ b/README.md +@@ -163,6 +163,19 @@ ### Download tarballs + http://libguestfs.org/download/libnbd + + ++### Downstream packagers ++ ++If you are packaging libnbd, use: ++ ++``` ++./configure --with-extra='...' ++``` ++ ++providing extra information about the distribution, and/or ++distro-specific versions. It helps us with troubleshooting bug ++reports. (Also, talk to us!) ++ ++ + ## Developers + + Install the valgrind program and development headers. +diff --git a/configure.ac b/configure.ac +index 40d4f79f..6fc4342e 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -18,6 +18,21 @@ + AC_INIT([libnbd],[1.22.2]) + + AC_CONFIG_MACRO_DIR([m4]) ++ ++dnl Extra string, a freeform string defined by downstream packagers. ++dnl eg. If you are packaging libnbd for Linux distro X 1.1, you could ++dnl ./configure --with-extra="X release 1.1" ++AC_ARG_WITH([extra], ++ [AS_HELP_STRING([--with-extra=...], ++ [extra version information (for use by packagers)])], ++ [LIBNBD_VERSION_EXTRA="$withval"], ++ [LIBNBD_VERSION_EXTRA=] ++) ++AC_DEFINE_UNQUOTED([LIBNBD_VERSION_EXTRA], ["$LIBNBD_VERSION_EXTRA"], ++ [Extra version information (for use by packagers)]) ++ ++AC_MSG_NOTICE([libnbd version $PACKAGE_VERSION ($LIBNBD_VERSION_EXTRA)]) ++ + m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],[], + [m4_define([AC_USE_SYSTEM_EXTENSIONS],[])]) + AC_USE_SYSTEM_EXTENSIONS +-- +2.47.1 + diff --git a/0015-lib-New-API-nbd_get_version_extra.patch b/0015-lib-New-API-nbd_get_version_extra.patch new file mode 100644 index 0000000..e0a07fd --- /dev/null +++ b/0015-lib-New-API-nbd_get_version_extra.patch @@ -0,0 +1,107 @@ +From e17980b7bc91eb74d2cccfcc4dc89e4dcead5609 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 16 Jul 2025 12:26:29 +0100 +Subject: [PATCH] lib: New API: nbd_get_version_extra + +This new API gets the ./configure --with-extra="..." string, usually +the empty string (for upstream builds) or the package NVR (for +downstream builds). + +This commit also adds a test. + +(cherry picked from commit 0b7e0831912c9efcd601b4738756a0aeb948df79) +--- + generator/API.ml | 26 ++++++++++++++++++++++++-- + lib/handle.c | 6 ++++++ + tests/get-version.c | 7 +++++++ + 3 files changed, 37 insertions(+), 2 deletions(-) + +diff --git a/generator/API.ml b/generator/API.ml +index 8ee1843a..b1932dfa 100644 +--- a/generator/API.ml ++++ b/generator/API.ml +@@ -4172,7 +4172,7 @@ versions."; + longdesc = "\ + Returns the name of the library, always C<\"libnbd\"> unless + the library was modified with another name at compile time."; +- see_also = [Link "get_version"]; ++ see_also = [Link "get_version"; Link "get_version_extra"]; + }; + + "get_version", { +@@ -4220,7 +4220,26 @@ The release number is incremented for each release along a particular + branch. + + =back"; +- see_also = [Link "get_package_name"]; ++ see_also = [Link "get_package_name"; Link "get_version_extra"]; ++ }; ++ ++ "get_version_extra", { ++ default_call with ++ args = []; ret = RStaticString; is_locked = false; may_set_error = false; ++ shortdesc = "return the extra version of the library"; ++ longdesc = "\ ++Return the extra version of libnbd. This is a freeform string ++which is set at package build time using: ++ ++ ./configure --with-extra=\"...\" ++ ++and it intended to be used by downstream packagers (eg. Linux distributions) ++to convey extra version information, such as the precise version of ++the libnbd RPM, C<.deb> etc. ++ ++The string may be C<\"\">, indicating that no extra version information ++is available, or that this is an upstream build of libnbd."; ++ see_also = [Link "get_package_name"; Link "get_version_extra"]; + }; + + "kill_subprocess", { +@@ -4515,6 +4534,9 @@ let first_version = [ + "is_uri", (1, 22); + "get_subprocess_pid", (1, 22); + ++ (* Added in 1.23.x development cycle, will be stable and supported in 1.24 *) ++ "get_version_extra", (1, 24); ++ + (* These calls are proposed for a future version of libnbd, but + * have not been added to any released version so far. + "get_tls_certificates", (1, ??); +diff --git a/lib/handle.c b/lib/handle.c +index a263cc4c..ec64d601 100644 +--- a/lib/handle.c ++++ b/lib/handle.c +@@ -566,6 +566,12 @@ nbd_unlocked_get_version (struct nbd_handle *h) + return PACKAGE_VERSION; + } + ++const char * ++nbd_unlocked_get_version_extra (struct nbd_handle *h) ++{ ++ return LIBNBD_VERSION_EXTRA; ++} ++ + int + nbd_unlocked_kill_subprocess (struct nbd_handle *h, int signum) + { +diff --git a/tests/get-version.c b/tests/get-version.c +index b8dc5338..c195e5f5 100644 +--- a/tests/get-version.c ++++ b/tests/get-version.c +@@ -53,6 +53,13 @@ main (int argc, char *argv[]) + } + assert (strcmp (s, PACKAGE_VERSION) == 0); + ++ s = nbd_get_version_extra (nbd); ++ if (s == NULL) { ++ fprintf (stderr, "%s\n", nbd_get_error ()); ++ exit (EXIT_FAILURE); ++ } ++ assert (strcmp (s, LIBNBD_VERSION_EXTRA) == 0); ++ + nbd_close (nbd); + exit (EXIT_SUCCESS); + } +-- +2.47.1 + diff --git a/0016-tools-Add-extra-version-information-in-the-output-of.patch b/0016-tools-Add-extra-version-information-in-the-output-of.patch new file mode 100644 index 0000000..e2b4631 --- /dev/null +++ b/0016-tools-Add-extra-version-information-in-the-output-of.patch @@ -0,0 +1,268 @@ +From 625a79d4eea074d8f83dc590118605d88bd9676a Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 16 Jul 2025 12:27:21 +0100 +Subject: [PATCH] tools: Add extra version information in the output of + --version + +In tools like nbdcopy, add the extra version information, if present +to the output of commands like 'nbdcopy --version'. + +For example in a downstream build you might see: + + $ nbdcopy --version + nbdcopy 1.23.4 (libnbd-1.23.4-1.fc43) + libnbd 1.23.4 (libnbd-1.23.4-1.fc43) + +In upstream builds or builds not using the new ./configure --with-extra +option, the output is unchanged. + +(cherry picked from commit 441eadf352e387aaba687bf424cc46424507bf18) +--- + common/utils/version.c | 13 +++++++++++-- + copy/test-version.sh | 31 ++++++++++++++++--------------- + dump/test-version.sh | 31 ++++++++++++++++--------------- + fuse/test-version.sh | 31 ++++++++++++++++--------------- + info/test-version.sh | 31 ++++++++++++++++--------------- + sh/test-version.sh | 31 ++++++++++++++++--------------- + 6 files changed, 91 insertions(+), 77 deletions(-) + +diff --git a/common/utils/version.c b/common/utils/version.c +index 554d3056..135c0c75 100644 +--- a/common/utils/version.c ++++ b/common/utils/version.c +@@ -20,6 +20,7 @@ + + #include + #include ++#include + + #include "libnbd.h" + #include "version.h" +@@ -30,9 +31,13 @@ display_version (const char *program_name) + struct nbd_handle *nbd; + const char *package_name = NULL; + const char *version = NULL; ++ const char *version_extra = NULL; + + /* The program name and the version of the binary. */ +- printf ("%s %s\n", program_name, PACKAGE_VERSION); ++ printf ("%s %s", program_name, PACKAGE_VERSION); ++ if (strcmp (LIBNBD_VERSION_EXTRA, "") != 0) ++ printf (" (%s)", LIBNBD_VERSION_EXTRA); ++ printf ("\n"); + + /* Flush to make sure it is printed, even if the code below crashes + * for any reason. +@@ -46,9 +51,13 @@ display_version (const char *program_name) + if (nbd) { + package_name = nbd_get_package_name (nbd); + version = nbd_get_version (nbd); ++ version_extra = nbd_get_version_extra (nbd); + } + if (version) { +- printf ("%s %s\n", package_name ? package_name : PACKAGE_NAME, version); ++ printf ("%s %s", package_name ? package_name : PACKAGE_NAME, version); ++ if (strcmp (version_extra, "") != 0) ++ printf (" (%s)", version_extra); ++ printf ("\n"); + fflush (stdout); + } + nbd_close (nbd); +diff --git a/copy/test-version.sh b/copy/test-version.sh +index f3bd30d4..0738f109 100755 +--- a/copy/test-version.sh ++++ b/copy/test-version.sh +@@ -16,18 +16,19 @@ + # License along with this library; if not, write to the Free Software + # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +-# Test that nbdcopy --version looks sane. +- +-fail=0 +-output=$($VG nbdcopy --version) +-if [ $? != 0 ]; then +- echo "$0: unexpected exit status" +- fail=1 +-fi +-if [ "$output" != "nbdcopy $EXPECTED_VERSION +-libnbd $EXPECTED_VERSION" ]; then +- echo "$0: unexpected output" +- fail=1 +-fi +-echo "$output" +-exit $fail ++# Test that --version looks sane. ++ ++. ../tests/functions.sh ++set -e ++set -x ++ ++tool=nbdcopy ++ ++output=test-$tool.out ++cleanup_fn rm -f $output ++ ++$VG $tool --version > $output ++cat $output ++ ++grep "$tool $EXPECTED_VERSION" $output ++grep "libnbd $EXPECTED_VERSION" $output +diff --git a/dump/test-version.sh b/dump/test-version.sh +index 2ef32e05..8adc0e19 100755 +--- a/dump/test-version.sh ++++ b/dump/test-version.sh +@@ -16,18 +16,19 @@ + # License along with this library; if not, write to the Free Software + # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +-# Test that nbddump --version looks sane. +- +-fail=0 +-output=$($VG nbddump --version) +-if [ $? != 0 ]; then +- echo "$0: unexpected exit status" +- fail=1 +-fi +-if [ "$output" != "nbddump $EXPECTED_VERSION +-libnbd $EXPECTED_VERSION" ]; then +- echo "$0: unexpected output" +- fail=1 +-fi +-echo "$output" +-exit $fail ++# Test that --version looks sane. ++ ++. ../tests/functions.sh ++set -e ++set -x ++ ++tool=nbddump ++ ++output=test-$tool.out ++cleanup_fn rm -f $output ++ ++$VG $tool --version > $output ++cat $output ++ ++grep "$tool $EXPECTED_VERSION" $output ++grep "libnbd $EXPECTED_VERSION" $output +diff --git a/fuse/test-version.sh b/fuse/test-version.sh +index 7b3e9929..18924b1f 100755 +--- a/fuse/test-version.sh ++++ b/fuse/test-version.sh +@@ -16,18 +16,19 @@ + # License along with this library; if not, write to the Free Software + # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +-# Test that nbdfuse --version looks sane. +- +-fail=0 +-output=$($VG nbdfuse --version) +-if [ $? != 0 ]; then +- echo "$0: unexpected exit status" +- fail=1 +-fi +-if [ "$output" != "nbdfuse $EXPECTED_VERSION +-libnbd $EXPECTED_VERSION" ]; then +- echo "$0: unexpected output" +- fail=1 +-fi +-echo "$output" +-exit $fail ++# Test that --version looks sane. ++ ++. ../tests/functions.sh ++set -e ++set -x ++ ++tool=nbdfuse ++ ++output=test-$tool.out ++cleanup_fn rm -f $output ++ ++$VG $tool --version > $output ++cat $output ++ ++grep "$tool $EXPECTED_VERSION" $output ++grep "libnbd $EXPECTED_VERSION" $output +diff --git a/info/test-version.sh b/info/test-version.sh +index 0125479e..35b1eec7 100755 +--- a/info/test-version.sh ++++ b/info/test-version.sh +@@ -16,18 +16,19 @@ + # License along with this library; if not, write to the Free Software + # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +-# Test that nbdinfo --version looks sane. +- +-fail=0 +-output=$($VG nbdinfo --version) +-if [ $? != 0 ]; then +- echo "$0: unexpected exit status" +- fail=1 +-fi +-if [ "$output" != "nbdinfo $EXPECTED_VERSION +-libnbd $EXPECTED_VERSION" ]; then +- echo "$0: unexpected output" +- fail=1 +-fi +-echo "$output" +-exit $fail ++# Test that --version looks sane. ++ ++. ../tests/functions.sh ++set -e ++set -x ++ ++tool=nbdinfo ++ ++output=test-$tool.out ++cleanup_fn rm -f $output ++ ++$VG $tool --version > $output ++cat $output ++ ++grep "$tool $EXPECTED_VERSION" $output ++grep "libnbd $EXPECTED_VERSION" $output +diff --git a/sh/test-version.sh b/sh/test-version.sh +index ef730ea2..5caba42c 100755 +--- a/sh/test-version.sh ++++ b/sh/test-version.sh +@@ -16,18 +16,19 @@ + # License along with this library; if not, write to the Free Software + # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +-# Test that nbdsh --version looks sane. +- +-fail=0 +-output=$($VG nbdsh --version) +-if [ $? != 0 ]; then +- echo "$0: unexpected exit status" +- fail=1 +-fi +-if [ "$output" != "nbdsh $EXPECTED_VERSION +-libnbd $EXPECTED_VERSION" ]; then +- echo "$0: unexpected output" +- fail=1 +-fi +-echo "$output" +-exit $fail ++# Test that --version looks sane. ++ ++. ../tests/functions.sh ++set -e ++set -x ++ ++tool=nbdsh ++ ++output=test-$tool.out ++cleanup_fn rm -f $output ++ ++$VG $tool --version > $output ++cat $output ++ ++grep "$tool $EXPECTED_VERSION" $output ++grep "libnbd $EXPECTED_VERSION" $output +-- +2.47.1 + diff --git a/libnbd.spec b/libnbd.spec index 64cd0d9..7eda2e8 100644 --- a/libnbd.spec +++ b/libnbd.spec @@ -21,7 +21,7 @@ Name: libnbd Version: 1.22.2 -Release: 1%{?dist} +Release: 2%{?dist} Summary: NBD client library in userspace License: LGPL-2.0-or-later AND BSD-3-Clause @@ -41,12 +41,22 @@ Source3: copy-patches.sh # https://gitlab.com/nbdkit/libnbd/-/commits/rhel-10.1/ # Patches. -Patch0001: 0001-copy-Add-blkhash-option.patch -Patch0002: 0002-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch -Patch0003: 0003-copy-Define-block_type-outside-of-block-struct.patch -Patch0004: 0004-copy-Shrink-struct-block.patch -Patch0005: 0005-copy-Enable-zero-optimization-for-allocated-extents.patch -Patch0006: 0006-copy-Fix-corrupted-hash-on-incomplete-read.patch +Patch0001: 0001-rust-Allow-cargo-build-target-RUST_TARGET-to-be-set.patch +#Patch0002: 0002-ci-Disable-cross-builds-of-Rust.patch +Patch0003: 0003-maint-Spelling-fixes.patch +Patch0004: 0004-generator-Avoid-const-correctness-warnings-in-golang.patch +Patch0005: 0005-info-Tolerate-nbdkit-slop-on-large-extents.patch +Patch0006: 0006-todo-Remove-a-couple-of-minor-features-that-have-bee.patch +Patch0007: 0007-ublk-Remove-unused-EXPECTED_VERSION.patch +Patch0008: 0008-copy-Add-blkhash-option.patch +Patch0009: 0009-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch +Patch0010: 0010-copy-Define-block_type-outside-of-block-struct.patch +Patch0011: 0011-copy-Shrink-struct-block.patch +Patch0012: 0012-copy-Enable-zero-optimization-for-allocated-extents.patch +Patch0013: 0013-copy-Fix-corrupted-hash-on-incomplete-read.patch +Patch0014: 0014-build-Add-.-configure-with-extra.patch +Patch0015: 0015-lib-New-API-nbd_get_version_extra.patch +Patch0016: 0016-tools-Add-extra-version-information-in-the-output-of.patch %if 0%{verify_tarball_signature} BuildRequires: gnupg2 @@ -231,6 +241,7 @@ autoreconf -i %build %configure \ --disable-static \ + --with-extra='%{name}-%{version}-%{release}' \ --with-tls-priority=@LIBNBD,SYSTEM \ --with-bash-completions \ PYTHON=%{__python3} \ @@ -387,7 +398,7 @@ make %{?_smp_mflags} check || { %changelog -* Tue Apr 22 2025 Richard W.M. Jones - 1.22.2-1 +* Wed Jul 16 2025 Richard W.M. Jones - 1.22.2-2 - Rebase to libnbd 1.22.2 - Synch spec file with Fedora Rawhide. resolves: RHEL-78831 @@ -395,6 +406,8 @@ make %{?_smp_mflags} check || { resolves: RHEL-7119 - Add nbdcopy --blkhash option resolves: RHEL-85513 +- Log the version of libnbd / nbdcopy in virt-v2v output + resolves: RHEL-104019 * Wed Oct 30 2024 Troy Dawson - 1.20.3-2 - Bump release for October 2024 mass rebuild: