On 4/21/23 11:20, Richard W.M. Jones wrote:
> See:
https://github.com/libguestfs/nbdkit/issues/21
>
> Tested by applying the following patch to the example plugin and
> running it with verbose enabled:
>
> --- a/plugins/rust/examples/ramdisk.rs
> +++ b/plugins/rust/examples/ramdisk.rs
> @@ -43,6 +43,12 @@ struct RamDisk {
> }
>
> impl Server for RamDisk {
> + fn after_fork() -> Result<()> {
> + // A place to start background threads.
> + eprintln!("forked");
> + Ok(())
> + }
> +
> fn get_size(&self) -> Result<i64> {
> Ok(DISK.lock().unwrap().len() as i64)
> }
> @@ -76,4 +82,4 @@ impl Server for RamDisk {
> }
> }
>
> -plugin!(RamDisk {thread_model, write_at});
> +plugin!(RamDisk {thread_model, write_at, after_fork});
I *think* diffs embedded in commit messages are best quoted somehow (or
at least indented); I vaguely recall "naked" diffs in the commit message
confusing git-am.
I've not written a line of Rust thus far, so I'll let Alan review the patch.
That patch looks good from first glance. Have you tried running it yet?