Re: [Libguestfs] [libnbd PATCH v4 08/11] generator: Add `modifies_fd` flag to the [call] structure

2023-08-03 Thread Richard W.M. Jones
On Thu, Aug 03, 2023 at 03:30:36PM +, Tage Johansson wrote: > > On 8/2/2023 6:39 PM, Richard W.M. Jones wrote: > >On Wed, Aug 02, 2023 at 12:40:53PM +, Tage Johansson wrote: > >>Add a flag (`modifies_fd`) to the [call] structure in generator/API.ml > >>which is set to [true] if the handle

Re: [Libguestfs] [libnbd PATCH v4 08/11] generator: Add `modifies_fd` flag to the [call] structure

2023-08-03 Thread Tage Johansson
On 8/2/2023 6:39 PM, Richard W.M. Jones wrote: On Wed, Aug 02, 2023 at 12:40:53PM +, Tage Johansson wrote: Add a flag (`modifies_fd`) to the [call] structure in generator/API.ml which is set to [true] if the handle call may do something with the file descriptor. That is, it is [true] for

[Libguestfs] [libnbd PATCH v5 12/12] rust: async: Add an example

2023-08-03 Thread Tage Johansson
This patch adds an example using the asynchronous Rust bindings. --- rust/Cargo.toml| 1 + rust/examples/concurrent-read-write.rs | 135 + rust/run-tests.sh.in | 2 + 3 files changed, 138 insertions(+) create mode 100644

Re: [Libguestfs] [libnbd PATCH v4 04/11] rust: Use more specific closure traits

2023-08-03 Thread Tage Johansson
On 8/2/2023 6:32 PM, Richard W.M. Jones wrote: On Wed, Aug 02, 2023 at 12:40:49PM +, Tage Johansson wrote: For closures with `cb,count = CBOnce`, `FnOnce` will be used instead of I think there's an extra ',' here. Previous comments about use of markdown apply too. `FnMut`. Moreover,

Re: [Libguestfs] [libnbd PATCH v4 01/11] rust: create basic Rust bindings

2023-08-03 Thread Richard W.M. Jones
On Thu, Aug 03, 2023 at 03:20:04PM +, Tage Johansson wrote: > On 8/2/2023 5:42 PM, Richard W.M. Jones wrote: > >Here we're using markdown, I guess, but ocamldoc comments prefer to > >use [ ... ] instead of ` ... ` (although we don't use ocamldoc really). > > > But should [ ... ] (brackets)

Re: [Libguestfs] [libnbd PATCH v4 11/11] rust: Add some examples

2023-08-03 Thread Tage Johansson
On 8/2/2023 6:53 PM, Richard W.M. Jones wrote: On Wed, Aug 02, 2023 at 12:40:56PM +, Tage Johansson wrote: This patch adds a few examples in rust/examples/. The examples are compiled and run as part of the test suite. --- rust/Makefile.am | 3 +

[Libguestfs] [libnbd PATCH v5 00/12] Rust Bindings for Libnbd

2023-08-03 Thread Tage Johansson
A new version of the Rust bindings for Libnbd. Most changes have been mentioned as replies to the comments I got on v4. But the most significant change is probably that the patches have been reordered. Best regards, Tage Tage Johansson (12): rust: create basic Rust bindings rust: Add a

[Libguestfs] [libnbd PATCH v5 10/12] rust: async: Use the modifies_fd flag to exclude calls

2023-08-03 Thread Tage Johansson
All handle calls which has the modifies_fd flag set to true will be excluded from AsyncHandle (the asynchronous handle in the rust bindings). This is a better approach then listing all calls that should be excluded in Rust.ml explicetly. --- generator/Rust.ml | 60

[Libguestfs] [libnbd PATCH v5 04/12] rust: Add some examples

2023-08-03 Thread Tage Johansson
This patch adds a few examples in rust/examples/. The examples are compiled and run as part of the test suite. --- rust/Cargo.toml | 2 ++ rust/Makefile.am| 3 +++ rust/examples/connect-command.rs| 39 +

[Libguestfs] [libnbd PATCH v5 05/12] generator: Add information about asynchronous handle calls

2023-08-03 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 v5 01/12] rust: create basic Rust bindings

2023-08-03 Thread Tage Johansson
This commit creates basic Rust bindings in the rust directory. The bindings are generated by generator/Rust.ml and generator/RustSys.ml. --- .gitignore | 10 + .ocamlformat | 4 + Makefile.am| 2 + configure.ac | 30 ++

[Libguestfs] [libnbd PATCH v5 02/12] rust: Add a couple of integration tests

2023-08-03 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 | 22 +++ rust/run-tests.sh.in | 4 +-

[Libguestfs] [libnbd PATCH v5 03/12] rust: Make it possible to run tests with Valgrind

2023-08-03 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.in | 6 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/rust/Makefile.am b/rust/Makefile.am index db8fc66..f9830d0 100644 ---

[Libguestfs] [libnbd PATCH v5 06/12] generator: Add information about the lifetime of closures

2023-08-03 Thread Tage Johansson
Add two new fields, cblifetime and cbcount, to the `closure` type in generator/API.ml*. cblifetime tells if the closure may only be used for as long as the command is in flight or if the closure may be used until the handle is destructed. cbcount tells whether the closure may be called many times

[Libguestfs] [libnbd PATCH v5 09/12] generator: Add `modifies_fd` flag to the [call] structure

2023-08-03 Thread Tage Johansson
Add a flag (modifies_fd) to the call structure in generator/API.ml which is set to true if the handle call may do something with the file descriptor. That is, it is true for all calls which are or may call aio_notify_*, including all synchronous commands like nbd_connect or nbd_opt_go. The

[Libguestfs] [libnbd PATCH v5 08/12] rust: async: Create an async friendly handle type

2023-08-03 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 `async`

[Libguestfs] [libnbd PATCH v5 11/12] rust: async: Add a couple of integration tests

2023-08-03 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/Cargo.toml | 1 + rust/tests/test_async_100_handle.rs | 25 +++ rust/tests/test_async_200_connect_command.rs | 33

[Libguestfs] [libnbd PATCH v5 07/12] rust: Use more specific closure traits

2023-08-03 Thread Tage Johansson
For closures with cbcount = CBOnce, FnOnce will be used instead of FnMut. Moreover, closures in synchronous commands with cblifetime = CBCommand will not need to live for the static lifetime. See [here](https://doc.rust-lang.org/std/ops/trait.FnOnce.html) for more information about the advantages