[Libguestfs] [libnbd PATCH 03/10] generator: Add information about asynchronous handle calls

2023-07-19 Thread Tage Johansson
A new field `async_kind` is added to the `call` data type in generator/API.ml*. The purpose is to tell if a certain handle call is an asynchronous command and if so how one can know when it is completed. The motivation for this is that all asynchronous commands on the `AsyncHandle` in the Rust

[Libguestfs] [libnbd PATCH 04/10] generator: Add information about the lifetime of closures

2023-07-19 Thread Tage Johansson
Add a new field `cbkind` to the `closure` type in generator/API.ml*. It tells how many times the closure may be invoked and for how long time it might be used. More specifically, it can take any of these values: - `CBOnceCommand`: The closure may only be called once and shall not be called after

Re: [Libguestfs] [libnbd PATCH 01/10] generator: Add copyright argument to `generate_header`

2023-07-19 Thread Richard W.M. Jones
I pushed patch 1/10, thanks. 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)

Re: [Libguestfs] [libnbd PATCH 04/10] generator: Add information about the lifetime of closures

2023-07-19 Thread Richard W.M. Jones
On Wed, Jul 19, 2023 at 09:09:48AM +, Tage Johansson wrote: > Add a new field `cbkind` to the `closure` type in generator/API.ml*. > It tells how many times the closure may be invoked and for how long time > it might be used. More specifically, it can take any of these values: > -

Re: [Libguestfs] [libnbd PATCH 02/10] rust: create basic Rust bindings

2023-07-19 Thread Richard W.M. Jones
On Wed, Jul 19, 2023 at 09:09:46AM +, Tage Johansson wrote: > diff --git a/rust/Makefile.am b/rust/Makefile.am > new file mode 100644 > index 000..cb8d7c9 > --- /dev/null > +++ b/rust/Makefile.am ... > +all-local: $(source_files) > + rm -f libnbd-sys/libnbd_version.t > +

Re: [Libguestfs] [libnbd PATCH 07/10] rust: Add a couple of integration tests

2023-07-19 Thread Richard W.M. Jones
On Wed, Jul 19, 2023 at 09:09:51AM +, Tage Johansson wrote: > +fn test_connect_command() { > +let nbd = libnbd::Handle::new().unwrap(); > +nbd.connect_command(&[ > +c_str!("nbdkit"), > +c_str!("-s"), > +c_str!("--exit-with-parent"), > +c_str!("-v"), > +

Re: [Libguestfs] [libnbd PATCH 09/10] rust: async: Create an async friendly handle type

2023-07-19 Thread Richard W.M. Jones
On Wed, Jul 19, 2023 at 09:09:53AM +, Tage Johansson wrote: > Create another handle type: `AsyncHandle`, which makes use of Rust's > builtin asynchronous functions (see > ) and runs on top of > the Tokio runtime (see ).

Re: [Libguestfs] [libnbd PATCH 02/10] rust: create basic Rust bindings

2023-07-19 Thread Richard W.M. Jones
On Wed, Jul 19, 2023 at 03:28:59PM +0100, Richard W.M. Jones wrote: > On Wed, Jul 19, 2023 at 09:09:46AM +, Tage Johansson wrote: > > diff --git a/rust/Makefile.am b/rust/Makefile.am > > new file mode 100644 > > index 000..cb8d7c9 > > --- /dev/null > > +++ b/rust/Makefile.am > ... > >

Re: [Libguestfs] [PATCH v4 09/24] nbd: Replace bool structured_reply with mode enum

2023-07-19 Thread Eric Blake
On Mon, Jun 12, 2023 at 02:24:52PM -0500, Eric Blake wrote: > On Mon, Jun 12, 2023 at 06:07:59PM +0300, Vladimir Sementsov-Ogievskiy wrote: > > On 08.06.23 16:56, Eric Blake wrote: > > > The upcoming patches for 64-bit extensions requires various points in > > > the protocol to make decisions

[Libguestfs] [libnbd PATCH 00/10] Rust bindings

2023-07-19 Thread Tage Johansson
Hello, This is a, compared to last time, much more complete implementation of Rust bindings for Libnbd. There is still no documentation and no examples. And one does still need LLVM to build the bindings due to [rust-bindgen](https://github.com/rust-lang/rust-bindgen). But the overall

[Libguestfs] [libnbd PATCH 01/10] generator: Add copyright argument to `generate_header`

2023-07-19 Thread Tage Johansson
Add an optional argument: `?(copyright = "Red Hat")`, to `generate_header` in generator/utils.ml and generator/utils.mli. Makes it possible for authors to license generated code under their own name or organization. --- generator/utils.ml | 5 +++-- generator/utils.mli | 3 ++- 2 files changed,

[Libguestfs] [libnbd PATCH 07/10] rust: Add a couple of integration tests

2023-07-19 Thread Tage Johansson
A couple of integration tests are added in rust/tests. They are mostly ported from the OCaml tests. --- rust/Cargo.toml | 4 + rust/Makefile.am | 1 + rust/run-tests.sh| 6 +-

[Libguestfs] [libnbd PATCH 08/10] rust: Make it possible to run tests with Valgrind

2023-07-19 Thread Tage Johansson
Make it possible to run Rust tests with Valgrind with `make check-valgrind` in the rust directory. --- rust/Makefile.am | 3 +++ rust/run-tests.sh | 6 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/rust/Makefile.am b/rust/Makefile.am index 9ff0779..5dc14e9 100644 ---

[Libguestfs] [libnbd PATCH 09/10] rust: async: Create an async friendly handle type

2023-07-19 Thread Tage Johansson
Create another handle type: `AsyncHandle`, which makes use of Rust's builtin asynchronous functions (see ) and runs on top of the Tokio runtime (see ). For every asynchronous command, like `aio_connect()`, a corresponding

[Libguestfs] [libnbd PATCH 05/10] rust: Use FnOnce for callbacks which only will be used once

2023-07-19 Thread Tage Johansson
For closures with `cbkind = CBOnceCommand` an `FnOnce` instead of an `FnMut` is required. (See [here](https://doc.rust-lang.org/std/ops/trait.FnOnce.html) for more information about `FnOnce.) This makes the API more ergonomic since the user can provide a closure which may only be called once

[Libguestfs] [libnbd PATCH 06/10] rust: Don't enforce 'static lifetimes on some closures

2023-07-19 Thread Tage Johansson
For closure arguments to synchronous commands which has `cbkind` `CBOnceCommand` or `CBManyCommand`, the requirement of the `'static` lifetime is removed. This greatly simplifies the API for the user as the user might otherwise have to use both an `Arc` and a `Mutex` when calling for instance

[Libguestfs] [libnbd PATCH 10/10] rust: async: Add a couple of integration tests

2023-07-19 Thread Tage Johansson
Add a couple of integration tests as rust/tests/test_async_*.rs. They are very similar to the tests for the synchronous API. --- rust/tests/test_async_100_handle.rs | 25 +++ rust/tests/test_async_200_connect_command.rs | 34 rust/tests/test_async_210_opt_abort.rs| 40