feat: add multi-distro and custom image support#20
Conversation
- Bump version to 0.3.0 and update documentation link. - Introduce `ImageConfig` to support guest distro, architecture, source, and digest configuration. - Refactor image handling logic to unify built-in distro and custom image creation via the `Image::new()` interface. - Use `tracing-indicatif` to display progress bars during image downloads. - Inject SSH over vhost-vsock startup logic into VMs via cloud-init to improve SSH connection stability. - Improve streaming hash computation performance (set `sha2` crate `opt-level = 3`), removing dependency on external `sha256sum`/`sha512sum` binaries. - Remove kernel/initrd extraction logic; QEMU no longer boots directly from kernel, and the host no longer depends on `guestfish` or `virt-copy-out`. - Clean up other redundant code. Signed-off-by: jl.jiang <jiangjl9807@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8901ec897
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if let Ok(image) = Self::load(&name).await { | ||
| return Ok(image); |
There was a problem hiding this comment.
Validate cache hit against requested source and digest
This early return reuses any cached image for name without verifying it matches the current request, but name is only a filename stem and does not encode the requested source URL/path or digest. If two different images share a basename (or the digest changes for the same basename), Image::new can silently return the wrong cached image and run VMs against unintended contents.
Useful? React with 👍 / 👎.
| if let (Some(src), Some((digest_type, digest_hex))) = (override_source, override_digest) { | ||
| // If source and digest are provided, fetch from source. | ||
| fetch_from_source(&src, &image_path, &digest_hex, digest_type.clone()).await?; | ||
|
|
||
| image_digest = (digest_type, digest_hex); |
There was a problem hiding this comment.
Reject partial image overrides before builtin fallback
ImageConfig::validate() is never invoked, so a config that sets only source or only digest does not fail fast; it falls through to the builtin-image branch. That silently ignores user intent and can produce a different image than requested, making misconfiguration hard to detect and debug.
Useful? React with 👍 / 👎.
ImageConfigto support guest distro, architecture, source, and digest configuration.Image::new()interface.tracing-indicatifto display progress bars during image downloads.sha2crateopt-level = 3), removing dependency on externalsha256sum/sha512sumbinaries.guestfishorvirt-copy-out.