fix(qemu): drop native mounts with missing host source before VM start - #5134
Open
amanyadav2022 wants to merge 1 commit into
Open
fix(qemu): drop native mounts with missing host source before VM start#5134amanyadav2022 wants to merge 1 commit into
amanyadav2022 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes an issue where a Multipass instance fails to start entirely if a previously-configured native mount's host source directory has since become unavailable (e.g. deleted, or on removable/network storage that's no longer connected).
Root cause
QemuMountHandler's constructor validates that a mount's source directory exists — but only once, when the handler is first constructed.QemuVirtualMachine::mount_argsis persisted as JSON metadata and reloaded on everyQemuVirtualMachineconstruction, so a stale entry can survive across VM stop/start cycles and even full daemon restarts without ever being re-validated.QemuVirtualMachine::initialize_vm_process()passesmount_argsdirectly into the QEMU process spec with no re-check, so a mount whose source has vanished still gets included as a-virtfsargument on every subsequent start — causing the QEMU process itself to fail at launch, rather than the VM simply starting without that one mount.Fix
initialize_vm_process()now filtersmount_argsimmediately before building the QEMU process spec, dropping any entry whose source no longer exists on disk and logging a warning for each removal. The VM then starts normally, minus the invalid mount, instead of failing to boot.As a side effect, on a normal (non-suspended) start, the filtered
mount_argsis what gets persisted back viaupdate_metadata_for, so the stale entry is also cleaned from the daemon's saved metadata after one successful start — not just skipped for a single boot.Related Issue(s)
Closes #4957
Testing
QemuBackend.startRemovesMountsWithMissingSourceintests/unit/qemu/test_qemu_backend.cpp, covering: a mount with a valid source is preserved and reaches the actual QEMU process arguments; a mount with a missing source is dropped with the expected warning logged; the VM starts successfully in both cases.QemuBackendandQemuMountHandlertest suites locally (59 tests) — all pass, no regressions.Known scope / limitations
exists()only, not full accessibility/directory-type, unlike the stricter check in theMountHandlerbase constructor. This covers the reported scenario (source deleted) but not, e.g., a source that still exists but became unreadable or was replaced by a file.update_metadata_for, so the metadata self-cleanup described above only applies to normal starts, not suspend/resume.Additional Notes
This is my first contribution to Multipass. Happy to adjust scope or approach based on feedback if there's a preferred pattern for this I've missed.