feat: add virtiofs support for Linux guests#1893
feat: add virtiofs support for Linux guests#1893codemedic wants to merge 9 commits intoquickemu-project:masterfrom
Conversation
Automatically use virtiofsd (vhost-user-fs-pci) instead of 9p when virtiofsd is present on the host and the guest OS is Linux. Falls back silently to 9p when virtiofsd is unavailable. Updates README to document the new capability.
66ed21a to
ff9f386
Compare
Drop the fallback to the QEMU-bundled C virtiofsd (/usr/lib/qemu/virtiofsd) as it uses incompatible CLI syntax and requires root privileges. Only the standalone Rust virtiofsd in PATH is supported. Capture virtiofsd stderr to a temp file rather than the shared VM log to avoid false-positive permission-error matches from stale log entries. Move start_virtiofsd() call inside vm_boot() so the Quickemu banner is printed before any virtiofsd warnings.
Write virtiofsd PID to a file alongside other VM runtime files. Add stop_virtiofsd() which sends SIGTERM and waits up to 1s for a clean exit before falling back to SIGKILL. Call it from kill_vm() and on QEMU startup failure.
There was a problem hiding this comment.
3 issues found across 2 files
Confidence score: 3/5
- There is concrete user-impact risk in
quickemu:stop_virtiofsdmay act on stale PID-file data and signal an unrelated process after PID reuse, which raises operational safety concerns. quickemualso appears to force the virtiofs path oncevirtiofsdstarts without checking QEMU support, so unsupported environments can fail VM startup instead of falling back to 9p.- Given the medium-to-high severities (6–7/10) and strong confidence, this is not merge-blocking by default but carries meaningful regression risk that should be addressed soon.
- Pay close attention to
quickemuandREADME.md- process handling/fallback behavior inquickemu, and documentation accuracy around virtiofs prerequisites inREADME.md.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="README.md">
<violation number="1" location="README.md:50">
P2: README overstates virtiofs auto-preference by omitting that a valid public share directory (`public_dir`/`PUBLIC`) is also required.</violation>
</file>
<file name="quickemu">
<violation number="1" location="quickemu:1688">
P1: `stop_virtiofsd` trusts stale PID-file values and may signal unrelated processes after PID reuse.</violation>
<violation number="2" location="quickemu:2148">
P2: Virtiofs path is selected unconditionally once `virtiofsd` starts, with no QEMU capability check; unsupported setups fail VM startup instead of falling back to 9p.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
The shared-memory NUMA backend required for virtiofs can confuse installers. Fall back to 9p when an ISO is present (install mode).
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="quickemu">
<violation number="1" location="quickemu:2580">
P2: Virtiofs enablement is gated on `iso` before storage boot mode is resolved, so VMs with persistent `iso` config can incorrectly lose virtiofs on normal disk boots.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…allback virtiofsd forks after startup; check socket existence rather than parent PID to detect success, and use pgrep to track the daemon child for cleanup. Move start_virtiofsd() call to after configure_storage() so $iso is correctly cleared before the installer check runs. Clear VIRTIOFSD on early return so configure_file_sharing() falls back to 9p instructions when virtiofsd is not started.
There was a problem hiding this comment.
2 issues found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="quickemu">
<violation number="1" location="quickemu:1660">
P2: virtiofsd readiness check is racy (fixed sleep + socket-only probe), which can mis-detect startup and leak/orphan daemon processes.</violation>
<violation number="2" location="quickemu:1678">
P1: PID capture via `pgrep -f ... | head -1` is unsafe and can persist/kill the wrong process.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- README: clarify virtiofs requires a public directory to be configured - stop_virtiofsd: guard against PID reuse by verifying /proc/<pid>/comm before signalling - start_virtiofsd: replace fixed sleep with poll loop for socket readiness; use fuser (or comm-verified pgrep fallback) for safe PID resolution - vm_boot: check QEMU supports vhost-user-fs-pci before committing to virtiofs; stop virtiofsd and fall back to 9p if unsupported
There was a problem hiding this comment.
3 issues found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="quickemu">
<violation number="1" location="quickemu:1689">
P1: Fallback PID lookup can select an unrelated `virtiofsd` process because it uses a global `pgrep -f "virtiofsd"` instead of matching the VM socket.</violation>
<violation number="2" location="quickemu:1712">
P2: Linux-specific `/proc/<pid>/comm` PID validation is used without host-OS guarding, which can break virtiofsd PID tracking and shutdown on non-Linux hosts.</violation>
<violation number="3" location="quickemu:2179">
P2: QEMU virtiofs capability check can false-positive by matching error text, preventing intended fallback to 9p on unsupported builds.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…bility, QEMU device check - Scope pgrep fallback to the VM socket path to avoid matching unrelated virtiofsd instances - Replace /proc/<pid>/comm checks with portable `ps -p ... -o comm=` in both start and stop - Fix QEMU virtiofs capability check: use `-device help` and match quoted device name to avoid false-positives on error output
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="quickemu">
<violation number="1" location="quickemu:1689">
P2: Unescaped socket path is used as a `pgrep -f` regex pattern, so fallback PID detection can fail/mis-match and break virtiofsd cleanup.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Requires human review: Significant feature addition involving process management and QEMU configuration logic; requires human review for potential impact on VM lifecycle and guest compatibility.
Description
Adds automatic virtiofs support for Linux guests. When the standalone
virtiofsdis installed on the host andpublic_diris set, quickemu will usevhost-user-fs-pci(virtiofs) instead ofvirtio-9p-pci. Falls back silently to 9p ifvirtiofsdis not found or fails to start.Related: #1892
Why
9p performance is poor for metadata-heavy workloads (git, builds, package managers) due to per-syscall round-trip overhead. virtiofs uses a shared memory region (
/dev/shm) instead, giving much lower latency and near-native throughput. No guest changes are needed — virtiofs has been built into the Linux kernel since 5.4.Type of change
Behaviour
No configuration changes needed — fully automatic. When virtiofsd is active, the VM output shows:
If
virtiofsdis absent or fails to start, quickemu falls back to 9p with no user action required.Installing virtiofsd
The standalone Rust virtiofsd is required — the legacy QEMU-bundled C daemon (
/usr/lib/qemu/virtiofsd) uses incompatible CLI syntax and is not supported.Fedora / recent distros: available as a package:
Ubuntu 22.04 (build from source):
Checklist: