QEMU QemuOpts splits on commas; escape literal commas in the host path as ,, per QEMU convention to prevent option injection and boot failures on paths containing commas. Fix U5: extract b64dec() helper in slim-init.sh Deduplicate the 3-line base64 fallback decode block used by both the slim.mount and slim.cmd handlers into a single b64dec() function. Fix U6: add multi-mount test case test_mount now passes two --mount flags and asserts both slim0 and slim1 9p tags appear, covering the multi-mount tag-generation path.
This commit is contained in:
+9
-3
@@ -109,9 +109,11 @@ test_mount() {
|
||||
work="$(mktemp -d)"
|
||||
img="slim-test-mount"
|
||||
share_dir="$work/share"
|
||||
share_dir2="$work/share2"
|
||||
|
||||
mkdir -p "$share_dir"
|
||||
mkdir -p "$share_dir" "$share_dir2"
|
||||
echo "hello from host" > "$share_dir/testfile.txt"
|
||||
echo "second share" > "$share_dir2/testfile2.txt"
|
||||
|
||||
cat > "$work/Containerfile" <<'EOF'
|
||||
FROM alpine:latest
|
||||
@@ -136,16 +138,20 @@ EOF
|
||||
# The 9p share appears at the same path inside the VM as on the host.
|
||||
# Use --cmd to run the verification snippet with the canonical path.
|
||||
share_canon=$(readlink -f "$share_dir")
|
||||
share_canon2=$(readlink -f "$share_dir2")
|
||||
|
||||
echo "-- Booting VM with --mount $share_dir ..."
|
||||
echo "-- Booting VM with --mount $share_dir --mount $share_dir2 ..."
|
||||
output=$(timeout "$TIMEOUT" "$SLIM_BIN" run "$img" \
|
||||
--mount "$share_dir" \
|
||||
--cmd "echo Available 9p shares:; for f in /sys/bus/virtio/drivers/9pnet_virtio/virtio*/mount_tag; do [ -f \"\$f\" ] && echo \"\$f: \$(tr -d '\\0' < \"\$f\")\"; done; echo Mounts:; mount -v; cat \"${share_canon}/testfile.txt\" 2>/dev/null || echo NO_FILE; echo MOUNT_VERIFY_DONE; poweroff -f" \
|
||||
--mount "$share_dir2" \
|
||||
--cmd "echo Available 9p shares:; for f in /sys/bus/virtio/drivers/9pnet_virtio/virtio*/mount_tag; do [ -f \"\$f\" ] && echo \"\$f: \$(tr -d '\\0' < \"\$f\")\"; done; echo Mounts:; mount -v; cat \"${share_canon}/testfile.txt\" 2>/dev/null || echo NO_FILE; cat \"${share_canon2}/testfile2.txt\" 2>/dev/null || echo NO_FILE2; echo MOUNT_VERIFY_DONE; poweroff -f" \
|
||||
2>&1 || true)
|
||||
|
||||
check_output "$output" "mount_tag: slim0" "--mount 9p share detected"
|
||||
check_output "$output" "mount_tag: slim1" "--mount second 9p share detected"
|
||||
check_output "$output" "type 9p" "--mount 9p filesystem in mount list"
|
||||
check_output "$output" "hello from host" "--mount file accessible in VM"
|
||||
check_output "$output" "second share" "--mount second share file accessible in VM"
|
||||
check_output "$output" "MOUNT_VERIFY_DONE" "--mount VM ran to completion"
|
||||
|
||||
cleanup "$img" "$img"
|
||||
|
||||
Reference in New Issue
Block a user