Skip to content

fix(minvmd): look in installed paths for data files & gvproxy - #652

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/release
Jul 7, 2026
Merged

fix(minvmd): look in installed paths for data files & gvproxy#652
twitchyliquid64 merged 1 commit into
mainfrom
tom/release

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented Jul 7, 2026

Copy link
Copy Markdown
Member

Should fix the issue with the installed minvmd not being able to find its requisite files with a default install on MacOS

Summary by CodeRabbit

  • New Features

    • Improved image path resolution with clearer fallback behavior for kernel, rootfs, and initramfs files.
    • Added a more specific error when no usable image can be found.
  • Bug Fixes

    • Environment-based image overrides are now treated as authoritative when set.
    • Empty override values are handled as unset, reducing unexpected startup failures.
    • gvproxy lookup now follows a clearer precedence order: explicit override, user-local install, then system default.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a new VmError::MissingImage variant and reworks how kernel, rootfs, initramfs, and gvproxy paths are resolved. Resolution now prefers non-empty environment overrides verbatim, falls back to data-directory defaults only when files exist, and distinguishes MissingEnv from MissingImage failures. Unit tests are rewritten accordingly.

Changes

Image Path Resolution Rework

Layer / File(s) Summary
MissingImage error variant
crates/minvmd/src/error.rs
Adds VmError::MissingImage { var, default }, extends Display formatting, and updates source() to return None for this variant.
Shared resolver helpers and path resolution
crates/minvmd/src/image.rs
Introduces data_dir() and resolve_or_default() helpers; rewrites resolve_kernel_path, resolve_rootfs_path, and resolve_initramfs_path to use override-first, existence-gated default logic, returning MissingEnv or MissingImage accordingly.
Gvproxy tiered resolution
crates/minvmd/src/image.rs
Adds GVPROXY_FILE and installer_bin_dir() helpers; updates resolve_gvproxy_path() to a three-tier strategy: override, user-local installer binary, then system default.
Updated unit tests
crates/minvmd/src/image.rs
Rewrites tests with a serialized ENV_LOCK and env-scoping helpers to validate override, fallback, MissingImage, empty-string, and gvproxy tier precedence behaviors.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant resolve_or_default
  participant data_dir
  participant Filesystem

  Caller->>resolve_or_default: resolve_kernel_path()
  resolve_or_default->>resolve_or_default: check env override
  alt override set and non-empty
    resolve_or_default-->>Caller: return override path verbatim
  else no override
    resolve_or_default->>data_dir: compute data directory
    alt data_dir unresolved
      data_dir-->>Caller: VmError::MissingEnv
    else data_dir resolved
      resolve_or_default->>Filesystem: check default file exists
      alt file exists
        Filesystem-->>Caller: return default path
      else file missing
        Filesystem-->>Caller: VmError::MissingImage
      end
    end
  end
Loading

Possibly related PRs

  • gominimal/minimal#337: Both PRs modify crates/minvmd/src/error.rs and crates/minvmd/src/image.rs around image-path resolution and error variants, with this PR extending the earlier MissingEnv-based logic with new MissingImage behavior.

Suggested reviewers: norrietaylor

Poem

A rabbit hopped through paths unknown,
Where env vars sat, unset, alone.
"No image here?" the rabbit cried,
"MissingImage!" the code replied. 🐇
Now defaults check before they leap,
And gvproxy tiers run clean and deep.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: searching installed paths for data files and gvproxy.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/minvmd/src/error.rs`:
- Around line 91-96: The MissingImage diagnostic in the Error display path only
reports the variable as “unset”, but resolve_or_default() also treats empty
overrides the same way. Update the formatting for Error::MissingImage so the
message clearly mentions empty values alongside unset ones, keeping the wording
consistent with resolve_or_default() and the existing display implementation in
error.rs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2da0ee46-8c9a-4375-beb6-289f56148e84

📥 Commits

Reviewing files that changed from the base of the PR and between b78cd67 and 0bdb239.

📒 Files selected for processing (2)
  • crates/minvmd/src/error.rs
  • crates/minvmd/src/image.rs

Comment on lines +91 to +96
Self::MissingImage { var, default } => {
write!(
f,
"{var} is unset and no file exists at the default location {}",
default.display()
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Include empty overrides in the MissingImage diagnostic.

resolve_or_default() treats empty values as unset, but this message only says “unset”, so MINVMD_*="" reports a misleading cause.

Proposed fix
-                    "{var} is unset and no file exists at the default location {}",
+                    "{var} is unset or empty and no file exists at the default location {}",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Self::MissingImage { var, default } => {
write!(
f,
"{var} is unset and no file exists at the default location {}",
default.display()
)
Self::MissingImage { var, default } => {
write!(
f,
"{var} is unset or empty and no file exists at the default location {}",
default.display()
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/minvmd/src/error.rs` around lines 91 - 96, The MissingImage diagnostic
in the Error display path only reports the variable as “unset”, but
resolve_or_default() also treats empty overrides the same way. Update the
formatting for Error::MissingImage so the message clearly mentions empty values
alongside unset ones, keeping the wording consistent with resolve_or_default()
and the existing display implementation in error.rs.

@twitchyliquid64
twitchyliquid64 merged commit 1769704 into main Jul 7, 2026
72 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/release branch July 7, 2026 20:44
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.

2 participants