Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add "persist" feature #149

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Conversation

loheagn
Copy link
Contributor

@loheagn loheagn commented Sep 4, 2023

This patch add a new sub module persist for the fuse_backend_rs::api::vfs module.

The persist module export two functions to help to save and restore the Vfs state:

  • save_to_bytes, which save the mete data of the Vfs struct into a byte array;
  • restore_from_bytes, which restore the meta data of the Vfs struct from a byte array.

As the two above functions only save and restore the vfs meta data, but don't save and restore the backend file systems,
this patch also provides a method named restore_mount to re-mount the backend file system into the Vfs using the same index as before.

For more information and usage, please refer to the doc of the save_to_bytes and restore_from_bytes functions.

@loheagn
Copy link
Contributor Author

loheagn commented Sep 26, 2023

Here's a an example dragonflyoss/nydus#1434 which shows how to use this feature.

@loheagn loheagn marked this pull request as ready for review September 26, 2023 09:42
Cargo.toml Outdated
@@ -20,10 +20,11 @@ build = "build.rs"
arc-swap = "1.5"
async-trait = { version = "0.1.42", optional = true }
bitflags = "1.1"
snapshot = { git = "https://github.com/firecracker-microvm/firecracker", tag = "v1.4.1", optional = true }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a published crate here, otherwise we can't publish fuse-backend-rs anymore.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a published version of snapshot?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bergwolf no, I cannnot find the crate on crates.io .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I've created firecracker-microvm/firecracker#4162. Let's see what the firecracker maintainers think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have https://crates.io/crates/dbs-snapshot, could you use the published one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'll update it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'll update it later.

done.

Copy link
Contributor

@bergwolf bergwolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally lgtm, thanks!

This patch add a new sub module `persist` for the `fuse_backend_rs::api::vfs` module.

The `persist` module export two functions to help to save and restore the `Vfs` state:
- `save_to_bytes`, which save the mete data of the `Vfs` struct into a byte array;
- `restore_from_bytes`, which restore the meta data of the `Vfs` struct from a byte array.

As the two above functions only save and restore the vfs meta data, but don't save and restore the backend file systems,
this patch also provides a method named `restore_mount` to re-mount the backend file system into the `Vfs` using the same index as before.

For more information and usage, please refer to the doc of the `save_to_bytes` and `restore_from_bytes` functions.

Signed-off-by: Nan Li <[email protected]>
@jiangliu jiangliu merged commit 6708951 into cloud-hypervisor:master Oct 27, 2023
4 checks passed
@loheagn loheagn deleted the vfs-persist branch October 27, 2023 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants