From 6f2595cfaab778ed509585aebe2c017bc4e2be46 Mon Sep 17 00:00:00 2001 From: Precious Okwu <32944039+libracoder@users.noreply.github.com> Date: Wed, 25 Nov 2026 19:53:30 +0100 Subject: [PATCH] Guest kernel: enable NFSv3/v4 client for type=nfs volumes and dm-crypt/LUKS (#494) (#961) Co-authored-by: meutex Co-authored-by: Marcin Uliasz --- docs/features.md | 11 ++++++++++- guest/kernel/kiri.config | 25 +++++++++++++++++++++++++ tests/e2e.sh | 3 +++ tests/regressions.tsv | 1 + 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/docs/features.md b/docs/features.md index 868ea0c..6e05d4c 100644 --- a/docs/features.md +++ b/docs/features.md @@ -48,7 +48,11 @@ Apple silicon and Intel Macs (macOS 14+), Windows 10 and 11 (x86-64 and Arm, thr `kiri domains reset` puts back 80 and 443 - **Storage**: named and anonymous volumes, bind mounts of Mac paths (virtiofs), `--tmpfs`, `--mount`, `volume` commands; local volumes that - bind a folder (`driver_opts: {type: none, o: bind, device: /path}`) + bind a folder (`driver_opts: {type: none, o: bind, device: /path}`); + local-driver volumes with `driver_opts` `type=nfs` mount a remote NFS + export — NFSv4 (minorversion 4.0 and 4.1) and NFSv3, honouring `addr=`, + `nfsvers=`, `hard`/`soft`, `timeo`, `retrans`, `ro`/`rw` and `noatime`; + LUKS / `dm-crypt` in the guest kernel (`CONFIG_DM_CRYPT`) - **Images**: `pull` (with `docker login` credentials), `push`, `tag`, `save`, `load`, `history`, `search`, `image prune`, `system df`; **amd64 images run through Rosetta**, `--platform` honoured @@ -246,3 +250,8 @@ To trust a private certificate authority at a Kiri Share edge only, set `KIRI_SH registry-1.docker.io ...`). The builder runs on the default bridge, so check from a container there: `docker run --rm alpine nslookup registry-1.docker.io`. + +- **`type=cifs` (SMB) volumes don't mount yet.** Kiri's guest kernel has no + CIFS client, so a local-driver volume with `driver_opts: {type: cifs}` + fails the same way NFS-backed volumes did before NFS support landed. + SMB support is a separate change. diff --git a/guest/kernel/kiri.config b/guest/kernel/kiri.config index dfb9d00..b41a952 100644 --- a/guest/kernel/kiri.config +++ b/guest/kernel/kiri.config @@ -91,6 +91,20 @@ CONFIG_BLK_DEV_LOOP=y CONFIG_NETDEVICES=y CONFIG_NET_CORE=y +# --- device mapper (dm-crypt, LUKS) ---------------------------------------------- +# dm-crypt for encrypted disk images and LUKS volumes in privileged +# containers. The device-mapper core lives in drivers/md, gated behind the +# MD umbrella config (RAID/LVM core, no RAID personalities enabled). +# DM_CRYPT selects CRC32/CRYPTO/CBC/ESSIV itself; AES+XTS cover LUKS2's +# default aes-xts-plain64 cipher (XTS pulls in ECB) and SHA256 the essiv IV +# hash LUKS1 volumes use. +CONFIG_MD=y +CONFIG_BLK_DEV_DM=y +CONFIG_DM_CRYPT=y +CONFIG_CRYPTO_AES=y +CONFIG_CRYPTO_XTS=y +CONFIG_CRYPTO_SHA256=y + # --- filesystems ---------------------------------------------------------------- CONFIG_PROC_FS=y CONFIG_SYSFS=y @@ -127,6 +141,17 @@ CONFIG_FUSE_FS=y CONFIG_VIRTIO_FS=y CONFIG_FS_POSIX_ACL=y CONFIG_SECURITY=y +# NFS client, so local-driver volumes with type=nfs mount (Compose +# driver_opts). The user space already builds the mount fields; the kernel +# must register the nfs filesystem type or mount(2) fails with ENODEV +# ("no such device"). NFSv3 and NFSv4 (minor 4.0 and 4.1); NFSv2, pNFS, +# Kerberos (sec=krb5*) and NFS swap stay off. NETWORK_FILESYSTEMS is the +# menu gate: without it fs/nfs/Kconfig is not even parsed. +CONFIG_NETWORK_FILESYSTEMS=y +CONFIG_NFS_FS=y +CONFIG_NFS_V3=y +CONFIG_NFS_V4=y +CONFIG_NFS_V4_1=y # --- container primitives ------------------------------------------------------- CONFIG_NAMESPACES=y diff --git a/tests/e2e.sh b/tests/e2e.sh index 4890397..28d3e2e 100755 --- a/tests/e2e.sh +++ b/tests/e2e.sh @@ -1239,6 +1239,9 @@ t inspect-binds "ok" bash -c "$D inspect -f '{{json .HostConfig.Binds}}' hcm | p t inspect-mounts-tmpfs 'ok {"/t2":"size=1m"} {"/anon":{}}' bash -c "m=\$($D inspect -f '{{json .HostConfig.Mounts}}' hcm | python3 -c 'import json, sys; ms = json.load(sys.stdin) or []; ok = len(ms) == 2 and {\"Type\": \"volume\", \"Source\": \"thcmro\", \"Target\": \"/rodata\", \"ReadOnly\": True} in ms and {\"Type\": \"tmpfs\", \"Target\": \"/t\"} in ms; print(\"ok\" if ok else ms)'); echo \"\$m \$($D inspect -f '{{json .HostConfig.Tmpfs}} {{json .Config.Volumes}}' hcm)\"" t inspect-recreate-mounts "code=201 kept|rokept|from the mac|bro=ro|vro=ro|t1=ok|t2=ok|ds=ok|ss=ok anon=fresh" bash -c "a1=\$($D inspect -f '{{range .Mounts}}{{if eq .Destination \"/anon\"}}{{.Name}}{{end}}{{end}}' hcm); b=\$(curl -s --unix-socket '$SOCK' http://d/v1.47/containers/hcm/json | python3 -c 'import json, sys; c = json.load(sys.stdin); print(json.dumps(dict(c[\"Config\"], HostConfig=c[\"HostConfig\"])))'); code=\$(curl -s -o /dev/null -w '%{http_code}' --unix-socket '$SOCK' -X POST -H 'Content-Type: application/json' -d \"\$b\" 'http://d/v1.47/containers/create?name=hcm2'); out=\$($D start -a hcm2); a2=\$($D inspect -f '{{range .Mounts}}{{if eq .Destination \"/anon\"}}{{.Name}}{{end}}{{end}}' hcm2); [ -n \"\$a1\" ] && [ -n \"\$a2\" ] && [ \"\$a1\" != \"\$a2\" ] && an=fresh || an=\"same:\$a1:\$a2\"; echo \"code=\$code \$out anon=\$an\"" $D rm -f -v hcm hcm2 >/dev/null 2>&1; $D volume rm thcm thcmro >/dev/null 2>&1 +# The macOS guest kernel builds in the NFSv3/v4 client (#494) and dm-crypt/LUKS +# device-mapper (#755) in guest/kernel/kiri.config. +only mac t guest-kernel-nfs-dmcrypt "nfs dm" $D run --rm --privileged alpine sh -c 'grep -qw nfs /proc/filesystems && grep -qw device-mapper /proc/devices && test -c /dev/mapper/control && echo "nfs dm"' t anon-from-image "volume:/var/lib/postgresql/data" bash -c "$D run -d --name pgv -e POSTGRES_PASSWORD=x postgres:17-alpine >/dev/null; $D inspect -f '{{range .Mounts}}{{.Type}}:{{.Destination}}{{end}}' pgv" # Waits for the entrypoint's "init process complete" and then a working query, # not for pg_isready: on first start Postgres runs a temporary server to diff --git a/tests/regressions.tsv b/tests/regressions.tsv index b701ce6..619a1cc 100644 --- a/tests/regressions.tsv +++ b/tests/regressions.tsv @@ -355,6 +355,7 @@ bind-chown-chmod #382 chown on a macOS virtiofs bind mount returned 0 while leav crates/kiri/src/vm_cli.rs #473 macOS low ports (<1024) on 127.0.0.1/::1 failed without root instead of falling back to dual-stack with strict loopback peer filtering, and macOS VM had no shared_nat=false option (`kiri vm set --shared-nat off`) to omit VZNATNetworkDeviceAttachment and route egress/DNS over vsock under Cloudflare WARP (#383) or non-DF firewall drops (#350) finder-mount-nobrowse #929 Finder showed an automatic < sidebar entry for the local NFS socket mount guest-kernel-ext2-vfat #934 guest kernel lacked CONFIG_EXT4_USE_FOR_EXT2 and CONFIG_VFAT_FS so loop-mounted ext2 and FAT/EFI disk images failed to mount +guest-kernel-nfs-dmcrypt #494 guest kernel lacked CONFIG_NFS_FS / NFSv3 / NFSv4 client and CONFIG_DM_CRYPT / device-mapper so type=nfs volumes and LUKS dm-crypt devices failed in the macOS VM crates/kiri/src/machine.rs #935 kiri machine create always pulled --image instead of probing local images first, and --systemd machines mounted /tmp and /run with noexec crates/kiri/src/daemon/localtime.rs #938 Kiri WSL lacked /etc/localtime so `-v /etc/localtime:/etc/localtime:ro` created an empty directory there, breaking timezone bind mounts until self-healed and guarded against directory creation crates/kiri-init/src/linux/localtime.rs #938 kiri-init on WSL did not self-heal a missing or empty-directory /etc/localtime on startup and parse_mounts could create a directory at /etc/localtime or /etc/timezone