[libnbd PATCH] rust: Add cargo as an optional build dependency in README
by Tage Johansson
This patch adds cargo to the list of optional build dependencies in
top-level README.md.
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index c716661..5ce27bd 100644
--- a/README.md
+++ b/README.md
@@ -106,6 +106,8 @@ ## Building from source
* FUSE 3 to build the nbdfuse program.
* Linux >= 6.0 and ublksrv library to build nbdublk program.
* go and cgo, for compiling the golang bindings and tests.
+* cargo with a recent stable toolchain is required to build
+ the Rust bindings.
* bash-completion >= 1.99 for tab completion.
Optional, only needed to run the test suite:
base-commit: 33a47171653931b7e255e33930697a55eae1493b
prerequisite-patch-id: ff317be8e27608697ee070388502566ecf8546bb
prerequisite-patch-id: 6a68a5da00c78e039972118bfde68cf87d7db6af
prerequisite-patch-id: a6ae1f1d90ca8cb69d17c977428855acadd47608
prerequisite-patch-id: 053dc904d579f2d065228c1c5780109871e9cd66
prerequisite-patch-id: 99eb277dfb04af7930cc827d85fd011fc54bdd4c
prerequisite-patch-id: 0b4159540024f935140d070146d89f95b96576fa
prerequisite-patch-id: f320498a380789b51bf65b603c0627167453352c
prerequisite-patch-id: f9aea5f724ac167744aa72456340c370a43611a2
prerequisite-patch-id: 9ff0b41ad9fd00d5d67de92d574255b46cdf150a
prerequisite-patch-id: 1fd2bcd42012e5d0ab10f63a1849f2ccc706e6d6
prerequisite-patch-id: 7c5b4b59f2765e8c255857a0834805d19cecf65d
prerequisite-patch-id: 4d7bd8e07e4710e3420c1ee71502f0fd0da91ea7
prerequisite-patch-id: 5ed2a56efbc9554261f875cd299dd2b7483c78c8
prerequisite-patch-id: 52d475de3ab033859d6bd87996078ae7b3385695
prerequisite-patch-id: c6a05c89340bed6471de1d74ef95acb5b6ac2c25
prerequisite-patch-id: 097dd7285726e45b02493fc306fd3017748d50e2
prerequisite-patch-id: 359900c28144cf2059e23a2911ea9f9f9ca5db23
prerequisite-patch-id: 4db98f7b211c0de9a4095b300970e1973cf0716c
prerequisite-patch-id: 0bb320af5109c1c21e5b76d44e6ec1e7e685fd9f
prerequisite-patch-id: 205525d8ea09e77ea13f43d0720153ed5904dbcd
prerequisite-patch-id: f76cdc6ceca68268df92341985068388f25291ff
prerequisite-patch-id: 84cb140c8f0dd089ca8e9567cc2117bf38c9e558
prerequisite-patch-id: b2c3285d05fd56a258d3ec47d7d4cdcf06a57014
prerequisite-patch-id: 8938eab7a42f8a7ed82c9372be9bf29c2991787f
prerequisite-patch-id: 7694233787dd758add8c30e69965dfd1ffee7012
prerequisite-patch-id: 770993f2baac576e163abd73c2d4af3d8841b032
prerequisite-patch-id: e85690fa670dce4f6eb84b01c1b16700540789df
prerequisite-patch-id: 72e384aafbe3d1bec34371a2f4a862ff2db0b8ca
prerequisite-patch-id: 45e0dc7a06e0845f7ca992f663afcea8e9bc4ba0
prerequisite-patch-id: 0c3ac3d6f776a2e09e45534f3f74eaeb672dd003
prerequisite-patch-id: 0fc920e92dd6a36d97b4e60a68060031fe274a3b
prerequisite-patch-id: 8467ff99068b5ca29b74813ffefe1cd5689196d1
prerequisite-patch-id: cf92490b4d427b4fb036fdd5cc682a43be82d937
prerequisite-patch-id: 6518b46cd0dcfc9aec830b0532ae1fbfd3f9bbea
prerequisite-patch-id: 8e75ca2543d6e901a472b32a3f0daf81e79c090c
prerequisite-patch-id: 97ec755ec74a802d1b4efeec8be66dcdb9ac739d
prerequisite-patch-id: 95dd4160a43fa2bea8fbf614c912263cd5ad840d
prerequisite-patch-id: f219538637190d9340f30acef9b3d24125d3bb69
prerequisite-patch-id: c11ebccd6db5c175ed40b13916f9b1affd8179d8
prerequisite-patch-id: 6c6ada8eaf72221c82d11778ba6dd05eec60bdb1
prerequisite-patch-id: e1eb6d1aa978f8daeb5caa4281f46a29465e0fc9
prerequisite-patch-id: 39725e9d285db482e5314f4c1e2a19b80906f2ed
prerequisite-patch-id: 01e0ec094775996b95f74898fe5ff9840ca2dc0c
prerequisite-patch-id: a7c24c91cb12dc41a332cf8b820c8548f0d8e850
prerequisite-patch-id: 821c9c061ab5b577483794a635ba5b38dd07fd70
prerequisite-patch-id: b11622efc2554e1a2fae9fc7f0c957cb08d0ff87
prerequisite-patch-id: 1983f74a0c2991333ff04a2099bc2f15509f7444
prerequisite-patch-id: 7e7f28602431481b0817980238039264781e114e
prerequisite-patch-id: 7d662d655ccdd81d3c2e6e7ddd69f527bffdd19b
prerequisite-patch-id: d6bcb838a1875541f3f125b95f346c21a7d614ea
prerequisite-patch-id: 403572023dc08169c3f5052d5602ffe06885e3e8
prerequisite-patch-id: 0a6846e107ecffde51c1436b4b81256c7c459000
prerequisite-patch-id: e42c3f5f2ba4afcc038acd9ac4442dee4a443117
prerequisite-patch-id: 56d2f65eaa08a569286e2cd55b27ac2ca9838952
prerequisite-patch-id: c603d778c9ed6e2eaf211909085f89261d094694
prerequisite-patch-id: 33346c3ac9b34b83c6c310ead5b8b71b08f84af7
prerequisite-patch-id: b75aca15d5568618a38235cc8353bf22c6a340d2
prerequisite-patch-id: 7d7de645a10c4afef98c4408a6c0efe120632e9b
prerequisite-patch-id: ef892445bd153ebadbcde3fea8d42a289f594023
--
2.41.0
1 year, 4 months
[libnbd PATCH] rust: Allow rust compilation without rustfmt
by Eric Blake
Our goal is that rustfmt should be an optional dependency. If
present, we use it to make generated .rs files look nicer in the
tarball created by 'make dist'. But if absent, things should still
compile just fine.
However, the configure test currently rejects cargo as unusable if
'cargo fmt' doesn't work, which is overly strict. Not to mention that
'test ... -a ...' is non-portable (we don't need two conditions, but
if we did, the portable spelling is 'test ... && test ...').
Fixes: b2511d640b ("rust: create basic Rust bindings", v1.17.3)
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushed as b389eaea, as it lets me complete 'make check' with Rust
bindings enabled but rustfmt not installed.
configure.ac | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index b475dccf..d1440688 100644
--- a/configure.ac
+++ b/configure.ac
@@ -627,8 +627,7 @@ AS_IF([test "x$enable_rust" != "xno"],[
AS_IF([ (
cd $srcdir/rust/cargo_test &&
$CARGO test 2>&AS_MESSAGE_LOG_FD 1>&2 &&
- $CARGO doc 2>&AS_MESSAGE_LOG_FD 1>&2 &&
- $CARGO fmt 2>&AS_MESSAGE_LOG_FD 1>&2
+ $CARGO doc 2>&AS_MESSAGE_LOG_FD 1>&2
) ],[
AC_MSG_RESULT([yes])
],[
@@ -638,7 +637,7 @@ AS_IF([test "x$enable_rust" != "xno"],[
])
])
],[CARGO=no])
-AM_CONDITIONAL([HAVE_RUST],[test "x$CARGO" != "xno" -a "x$RUSTFMT" != "xno"])
+AM_CONDITIONAL([HAVE_RUST],[test "x$CARGO" != "xno"])
AC_MSG_CHECKING([for how to mark DSO non-deletable at runtime])
NODELETE=
--
2.41.0
1 year, 4 months
[PATCH libnbd] copy/copy-file-to-qcow2-compressed.sh: Skip test for all zeroes disk
by Richard W.M. Jones
Occasionally this test will choose a random seed which results in an
all-zeroes disk. The test tries to convert this to a compressed qcow2
file, and fails because no compressed clusters are detected in the
resulting file. This happens because qcow2 stores zero clusters with
a special sparse representation, they are never stored compressed, so
a disk with only zeroes in it will never contain compressed clusters.
To fix this, detect an all-zeroes disk and skip.
Reported-by: Eric Blake
---
copy/copy-file-to-qcow2-compressed.sh | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/copy/copy-file-to-qcow2-compressed.sh b/copy/copy-file-to-qcow2-compressed.sh
index 018c8bba2f..2706eadd66 100755
--- a/copy/copy-file-to-qcow2-compressed.sh
+++ b/copy/copy-file-to-qcow2-compressed.sh
@@ -25,6 +25,7 @@ requires $QEMU_NBD --version
requires nbdkit --exit-with-parent --version
requires nbdkit sparse-random --dump-plugin
requires qemu-img --version
+requires nbdinfo --version
#requires stat --version
# Check the compress driver is supported by this qemu-nbd.
@@ -45,6 +46,15 @@ cleanup_fn rm -f $file1 $file2 $out1 $out2
size=1G
seed=$RANDOM
+# Occasionally we will choose a seed which results in a completely
+# empty file. Skip this case.
+if nbdinfo --map --totals -- \
+ [ nbdkit --exit-with-parent sparse-random $size seed=$seed ] |
+ grep -sq '100.0%.*hole,zero'; then
+ echo "$0: bad seed chosen, skipping the test"
+ exit 77
+fi
+
# Create a compressed qcow2 file1.
#
# sparse-random files should compress easily because by default each
--
2.41.0
1 year, 4 months
[libnbd PATCH] golang: Optionally use gofmt on generated .go files
by Eric Blake
Combine my recent work on improving the generated Go output with
Tage's work on using a canonical formatter for Rust. If gofmt is
available during the build, then the generated .go files will now use
TAB indents and have proper columnar alignment; if it is not
available, the project still compiles.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Followup to this earlier series:
https://listman.redhat.com/archives/libguestfs/2023-July/032133.html
I still need to fold in the 'make check' verification of non-generated
.go files, plus Dan's idea of enabling CI coverage...
configure.ac | 1 +
generator/config.mli | 1 +
generator/utils.mli | 1 +
generator/config.ml.in | 3 ++-
generator/generator.ml | 15 ++++++++++-----
generator/utils.ml | 12 +++++++++++-
6 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index 3e8b9142..b475dccf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -596,6 +596,7 @@ AC_ARG_ENABLE([golang],
[enable_golang=yes])
AS_IF([test "x$enable_golang" != "xno"],[
AC_CHECK_PROG([GOLANG],[go],[go],[no])
+ AC_CHECK_PROG([GOFMT],[gofmt],[gofmt],[no])
AS_IF([test "x$GOLANG" != "xno"],[
AC_MSG_CHECKING([if $GOLANG is usable])
AS_IF([ (
diff --git a/generator/config.mli b/generator/config.mli
index 5f1a46a6..22c61dad 100644
--- a/generator/config.mli
+++ b/generator/config.mli
@@ -17,4 +17,5 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)
+val gofmt : string
val rustfmt : string
diff --git a/generator/utils.mli b/generator/utils.mli
index d97d43ac..9f7824b2 100644
--- a/generator/utils.mli
+++ b/generator/utils.mli
@@ -54,6 +54,7 @@ val
(** Type of code formatter. *)
type formatter =
+ | Gofmt
| Rustfmt
(** Redirect stdout to a file. Possibly formatting the code. *)
diff --git a/generator/config.ml.in b/generator/config.ml.in
index 7ac5237c..48d0d4a4 100644
--- a/generator/config.ml.in
+++ b/generator/config.ml.in
@@ -18,4 +18,5 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)
-let rustfmt = "@RUSTFMT@"
+let gofmt = "@GOFMT@"
+let rustfmt = "@RUSTFMT@"
diff --git a/generator/generator.ml b/generator/generator.ml
index c62b0c4f..8c9a585b 100644
--- a/generator/generator.ml
+++ b/generator/generator.ml
@@ -57,10 +57,15 @@ let
output_to "ocaml/NBD.ml" OCaml.generate_ocaml_nbd_ml;
output_to "ocaml/nbd-c.c" OCaml.generate_ocaml_nbd_c;
- output_to "golang/bindings.go" GoLang.generate_golang_bindings_go;
- output_to "golang/closures.go" GoLang.generate_golang_closures_go;
- output_to "golang/wrappers.go" GoLang.generate_golang_wrappers_go;
+ output_to ~formatter:(Some Gofmt) "golang/bindings.go"
+ GoLang.generate_golang_bindings_go;
+ output_to ~formatter:(Some Gofmt) "golang/closures.go"
+ GoLang.generate_golang_closures_go;
+ output_to ~formatter:(Some Gofmt) "golang/wrappers.go"
+ GoLang.generate_golang_wrappers_go;
output_to "golang/wrappers.h" GoLang.generate_golang_wrappers_h;
- output_to ~formatter:(Some Rustfmt) "rust/libnbd-sys/src/generated.rs" RustSys.generate_rust_sys_bindings;
- output_to ~formatter:(Some Rustfmt) "rust/src/bindings.rs" Rust.generate_rust_bindings;
+ output_to ~formatter:(Some Rustfmt) "rust/libnbd-sys/src/generated.rs"
+ RustSys.generate_rust_sys_bindings;
+ output_to ~formatter:(Some Rustfmt) "rust/src/bindings.rs"
+ Rust.generate_rust_bindings;
diff --git a/generator/utils.ml b/generator/utils.ml
index 3302b309..443ac6df 100644
--- a/generator/utils.ml
+++ b/generator/utils.ml
@@ -420,6 +420,7 @@ let
| i -> failwithf "%s: failed with error code %d" cmd i
type formatter =
+ | Gofmt
| Rustfmt
let output_to ?(formatter = None) filename k =
@@ -431,6 +432,15 @@ let
close_out c;
chan := NoOutput;
(match formatter with
+ | Some Gofmt ->
+ if Config.gofmt <> "no" then (
+ let cmd = sprintf "%s -w %s" Config.gofmt filename_new in
+ match system cmd with
+ | WEXITED 0 -> ()
+ | WEXITED i -> failwithf "gofmt failed with exit code %d" i
+ | WSIGNALED i | WSTOPPED i ->
+ failwithf "gofmt was killed or stopped by signal %d" i
+ )
| Some Rustfmt ->
if Config.rustfmt <> "no" then (
let cmd = sprintf "%s %s" Config.rustfmt filename_new in
@@ -439,7 +449,7 @@ let
| WEXITED i -> failwithf "rustfmt failed with exit code %d" i
| WSIGNALED i | WSTOPPED i ->
failwithf "rustfmt was killed or stopped by signal %d" i
- );
+ )
| None -> ());
(* Is the new file different from the current file? *)
if Sys.file_exists filename && files_equal filename filename_new then
--
2.41.0
1 year, 4 months