cidata: fix virtiofs mounts with a space in the path#5145
Conversation
4927b53 to
2a59527
Compare
b3ffef4 to
ef7158e
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses a vz + virtiofs mount failure when the host path contains whitespace by repairing cloud-init–generated /etc/fstab entries and ensuring mount points are correctly (un)escaped when remounting under SELinux. It also factors out fstab unescaping into a reusable utility script.
Changes:
- Add
util/escape_fstab.shto octal-escape the mount-point field for affected cloud-configvirtiofsfstab entries, and trigger amount -t virtiofs -apass forvz+virtiofs. - Add
util/unescape_fstab.shand use it where mount points must be decoded before being passed tomount(8). - Update
.ls-lint.ymlignores for the new util scripts.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/cidata/cidata.TEMPLATE.d/util/unescape_fstab.sh | New helper to decode fstab/proc-style octal escapes, with selftest. |
| pkg/cidata/cidata.TEMPLATE.d/util/escape_fstab.sh | New helper to rewrite fstab so virtiofs mount points with whitespace are parseable. |
| pkg/cidata/cidata.TEMPLATE.d/boot.Linux/05-lima-mounts.sh | Repairs fstab and remounts virtiofs; decodes escaped mount points for SELinux remount path. |
| pkg/cidata/cidata.TEMPLATE.d/boot.Linux/04-persistent-data-volume.sh | Reuses unescape_fstab.sh for mount-point decoding from /proc/mounts. |
| .ls-lint.yml | Adds ignores for the newly introduced util scripts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0a2b97d to
decc82e
Compare
|
@AkihiroSuda thanks for the reviews! I think everything is addressed now:
All review threads are resolved and CI is green. Whenever you have a moment, could you take another look? 🙏 |
|
Please squash the commits |
6695408 to
d4242b7
Compare
A vz + virtiofs mount whose host path contains a space (e.g. "/Volumes/External HD") was never mounted in the guest, and no error was reported. cloud-init's cc_mounts writes each mount into /etc/fstab with a bare "\t".join(fields) and does not octal-escape the mount point, so a space/tab in the path makes an unparsable line that mount(8) silently skips via nofail. cc_mounts already creates the directory from the unescaped value, so only the fstab line needs repair. Add two self-tested helpers under cidata.TEMPLATE.d/util/ (compare_version.sh convention): - escape_fstab.sh: octal-escapes the mount-point field of cloud-config virtiofs entries; -F'\t' isolates the field and makes the pass idempotent. - unescape_fstab.sh: the inverse decode, used by the SELinux remount in 05-lima-mounts.sh and (replacing an identical inline sed) by 04-persistent-data-volume.sh. boot.Linux/05-lima-mounts.sh repairs the fstab via escape_fstab.sh, runs mount -t virtiofs -a, and decodes via unescape_fstab.sh before the SELinux remount. No Go/template changes; scoped to vz + virtiofs. Complements, but does not depend on, the upstream cloud-init fix. Fixes: lima-vm#5136 Link: abiosoft/colima#1471 Signed-off-by: Eugene Kalinin <e.v.kalinin@gmail.com>
d4242b7 to
36195f4
Compare
|
@AkihiroSuda sorry to bother you again, could you help me with this problem? |
Problem
A
vz+virtiofsmount whose host path contains a space (e.g./Volumes/External HD,/tmp/lima space test) is never mounted in the guest, and no error is reported — the mount silently does not appear. External drives on macOS commonly contain spaces, so this affects a common setup. Surfaced downstream in Colima (abiosoft/colima#1471).Root cause
cloud-init's
cc_mountswrites each mount into/etc/fstabwith a bare"\t".join(fields)and does not octal-escape the mount point (canonical/cloud-init#3603). A space/tab in the path produces an unparsable fstab line thatmount(8)silently skips because of thenofailoption, so the mount never appears:(
findmnt --verifyreportsparse error at line N -- ignored.)Fix
cc_mountsalready creates the mount-point directory from the unescaped value, so only the fstab line needs repair. The escape/decode logic lives in two small, self-tested helper scripts underpkg/cidata/cidata.TEMPLATE.d/util/, following thecompare_version.shconvention:util/escape_fstab.sh— octal-escapes the mount-point field of cloud-configvirtiofsentries read on stdin. Parsing with-F'\t'isolates the field reliably and makes the pass idempotent (an already-escaped path has no literal space/tab), so it is also forward-compatible with a fixed cloud-init.util/unescape_fstab.sh— the inverse decode, used by the SELinux remount in05-lima-mounts.shand (replacing an identical inlinesed) by04-persistent-data-volume.sh.boot.Linux/05-lima-mounts.shnow repairs the fstab viaescape_fstab.sh, runsmount -t virtiofs -a, and decodes viaunescape_fstab.shbefore the SELinux remount. Both helpers are unit-tested via an embeddedSELFTESTblock (SELFTEST=1 ./util/escape_fstab.sh), likecompare_version.sh;.ls-lint.ymlcarries the snake_case exceptions.No Go/template changes. The fix is scoped to
vz+virtiofs; it complements, but does not depend on, the upstream cloud-init fix canonical/cloud-init#6911 (distros will ship that only years from now).Verified
Built
limactland booted avz+virtiofsinstance mounting/tmp/lima space test:findmnt --verify→0 parse errors(wasparse error at line 4)\040-escaped fstab line, no duplicate\040directory createdSELFTEST=1passes for both helpers, and escape → unescape round-tripsFixes: #5136
Link: abiosoft/colima#1471