fix(minimald): re-establish the 8 MiB guest vsock receive window - #932
Conversation
This reverts commit 1efde29.
📝 WalkthroughWalkthroughLinux microVM startup now requests an 8 MiB AF_VSOCK receive window, applies the required socket options, reads back the effective size, and logs success, clamping, or failure. ChangesAF_VSOCK receive-window tuning
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
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/minimald/src/main.rs`:
- Around line 740-759: Guard the entire microVM/vsock startup branch with
#[cfg(target_os = "linux")], including the minimald::guest import and the
set_vsock_rx_window listener setup. Ensure all guest and vsock symbols remain
inside this Linux-only configuration so non-Linux builds compile when --vsock is
unused.
🪄 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: b2c31a26-7fdd-4b21-a706-0920bed28e50
📒 Files selected for processing (1)
crates/minimald/src/main.rs
| // Widen the receive window before anything connects: `__vsock_create` | ||
| // copies `buffer_size` from the listening socket onto every socket it | ||
| // accepts, so this one call covers every session. Best effort — a | ||
| // daemon with the default window is the old, buggy behaviour, not a | ||
| // reason to refuse to boot. | ||
| match set_vsock_rx_window(&listener, VSOCK_RX_WINDOW_BYTES) { | ||
| Ok(effective) if effective >= VSOCK_RX_WINDOW_BYTES => { | ||
| tracing::debug!(bytes = effective, "raised the vsock receive window"); | ||
| } | ||
| Ok(effective) => tracing::warn!( | ||
| requested = VSOCK_RX_WINDOW_BYTES, | ||
| effective, | ||
| "vsock receive window clamped below the requested size; large uploads may still \ | ||
| fail with ENOBUFS" | ||
| ), | ||
| Err(e) => tracing::warn!( | ||
| error = %e, | ||
| "could not raise the vsock receive window; large uploads may fail with ENOBUFS" | ||
| ), | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the relevant file and the cfg-gated definitions.
git ls-files crates/minimald/src/main.rs
printf '\n--- outline: crates/minimald/src/main.rs ---\n'
ast-grep outline crates/minimald/src/main.rs --view expanded || true
printf '\n--- search for set_vsock_rx_window and VSOCK_RX_WINDOW_BYTES ---\n'
rg -n "set_vsock_rx_window|VSOCK_RX_WINDOW_BYTES|target_os = \"linux\"|vsock" crates/minimald/src/main.rs crates/minimald/src -g '!target' || trueRepository: gominimal/minimal
Length of output: 20473
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Show the local region around the cited lines with numbers.
sed -n '700,790p' crates/minimald/src/main.rs | cat -nRepository: gominimal/minimal
Length of output: 4864
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- outline: crates/minimald/src/main.rs ---'
ast-grep outline crates/minimald/src/main.rs --view expanded || true
printf '\n%s\n' '--- surrounding lines 700-790 ---'
sed -n '700,790p' crates/minimald/src/main.rs | cat -n
printf '\n%s\n' '--- occurrences of relevant symbols ---'
rg -n "set_vsock_rx_window|VSOCK_RX_WINDOW_BYTES|target_os = \"linux\"|vsock" crates/minimald/src/main.rs crates/minimald/src -g '!target' || trueRepository: gominimal/minimal
Length of output: 25163
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- os-specific cfg usages in crates/minimald/src/main.rs ---'
rg -n "#\\[cfg\\(|cfg!\\(" crates/minimald/src/main.rs
printf '\n%s\n' '--- declaration search across crate ---\n'
rg -n "pub const VSOCK_RX_WINDOW_BYTES|fn set_vsock_rx_window|struct .*listener|Vsock" crates/minimald/src -g '!target' || trueRepository: gominimal/minimal
Length of output: 2506
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- lines 240-290 ---'
sed -n '240,290p' crates/minimald/src/main.rs | cat -n
printf '\n%s\n' '--- lines 620-690 ---'
sed -n '620,690p' crates/minimald/src/main.rs | cat -n
printf '\n%s\n' '--- lines 690-770 ---'
sed -n '690,770p' crates/minimald/src/main.rs | cat -nRepository: gominimal/minimal
Length of output: 11537
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- lines 374-430 ---'
sed -n '374,430p' crates/minimald/src/main.rs | cat -n
printf '\n%s\n' '--- lines 430-520 ---'
sed -n '430,520p' crates/minimald/src/main.rs | cat -nRepository: gominimal/minimal
Length of output: 8516
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- Cargo.toml entries for minimald ---'
rg -n "minimald|target_os|tokio_vsock|sandbox2|rustls|minimal" Cargo.toml crates/minimald/Cargo.toml . -g 'Cargo.toml' -g 'crates/minimald/Cargo.toml' || true
printf '\n%s\n' '--- crates/minimald/src/lib.rs ---'
cat -n crates/minimald/src/lib.rs
printf '\n%s\n' '--- crates/minimald/Cargo.toml (if present) ---'
if [ -f crates/minimald/Cargo.toml ]; then cat -n crates/minimald/Cargo.toml; fiRepository: gominimal/minimal
Length of output: 12434
Guard the Linux-only microVM/vsock path.
Wrap the whole branch here, including use minimald::guest;, in #[cfg(target_os = "linux")]; otherwise non-Linux builds still fail to resolve the guest and vsock symbols even when --vsock is never used.
🤖 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/minimald/src/main.rs` around lines 740 - 759, Guard the entire
microVM/vsock startup branch with #[cfg(target_os = "linux")], including the
minimald::guest import and the set_vsock_rx_window listener setup. Ensure all
guest and vsock symbols remain inside this Linux-only configuration so non-Linux
builds compile when --vsock is unused.
Source: Coding guidelines
Fixes: #886
This reverts commit 1efde29.
With libkrun/libkrun#795, we believe the guts of the
ENOBUFS/ file-transfer error is now well understood, with the root cause fixed by #926. This PR re-establishes a reasonable vsock buffer in the guest, without which is was almost impossible to reproduce this bug.Note
Re-establish 8 MiB guest vsock receive window in
minimaldAdds a
set_vsock_rx_windowhelper in main.rs that setsSO_VM_SOCKETS_BUFFER_MAX_SIZEandSO_VM_SOCKETS_BUFFER_SIZEon the vsock listener socket, then reads back the effective size viagetsockopt. In the vsock path ofasync_main, this is called immediately after binding the listener, logging the effective size or a warning if the window is smaller than requested or the call fails.Macroscope summarized 4fd9765.
Summary by CodeRabbit