Sharing directory with debian/13 VM does not work

Hi,

This does not work with debian/13, while it works with debian/12, or with debian/13 in container (not --vm) mode:

incus launch images:debian/13 debvm --vm
incus config device add debvm debvm_shared disk source=/home/login path=/host

The command outputs Device debvm_shared added to debvm but the directory is not mounted inside the VM. In the VM’s dmesg, one can see:

[    4.572589] virtio-pci 0000:06:00.0: enabling device (0000 -> 0002)
[    4.581917] virtiofs virtio11: virtio_fs_setup_dax: No cache capability
[    4.587197] virtio-fs: tag <incus_debvm_shared> not found

Any ideas?
I’m using the Zabbly packages.

It looks like the CI tests jobs are failing silently:
https://jenkins.linuxcontainers.org/job/test-image/15567/architecture=amd64/console
says:

==> Starting the instances
==> Waiting for instances to start
+-------------------+---------+-------------------------+--------------------------------------------------+-----------------+-----------+
|       NAME        |  STATE  |          IPV4           |                       IPV6                       |      TYPE       | SNAPSHOTS |
+-------------------+---------+-------------------------+--------------------------------------------------+-----------------+-----------+
| test-image-V40Tr2 | RUNNING | 10.127.114.136 (enp5s0) | 2602:fc62:ffff:ffff:1266:6aff:fed2:72b6 (enp5s0) | VIRTUAL-MACHINE | 0         |
+-------------------+---------+-------------------------+--------------------------------------------------+-----------------+-----------+
==> Performing network tests
bin/test-image: 171: Syntax error: "else" unexpected (expecting "fi")
==> Test passed: debian/trixie/default/amd64 (VM)

It looks like “else if” on line 166 should be “elif”:

1 Like

Nice catch! Can you file a pull request for that project to get it fixed?
If you have not setup git for Github, you can do it from the Web interface of git.

Done: test-image: fix typo causing the script to fail silently by lnussbaum · Pull Request #877 · lxc/lxc-ci · GitHub

1 Like

Going back to the original problem (shared folders not working with debian/13 VM):
If I incus shell into the VM and manually mount -t virtiofs incus_debvm_shared /host, it works fine.

I tried to bisect the issue by provisioning debian/12 and upgrading to debian testing snapshots using snapshot.debian.org.
It works with:

deb [check-valid-until=no] https://snapshot.debian.org/archive/debian/20240203T000000Z/ trixie main

but fails with:

deb [check-valid-until=no] https://snapshot.debian.org/archive/debian/20240206T000000Z/ trixie main

(3 days later). The main relevant difference is that the kernel was updated from 6.5.13 to 6.6.13. So it looks caused by a change in Linux 6.6.
I don’t see anything relevant in History for fs/fuse/virtio_fs.c - torvalds/linux · GitHub so it might be outside virtio_fs.c.

However it works with ubuntu/24.04 which uses Linux 6.8, and with ubuntu/24.10 (Linux 6.11)…

Using mountsnoop-bpfcc inside the VM:
A failed device attachment:

COMM             PID     TID     MNT_NS      CALL
mount            657     657     4026531841  fsopen("virtiofs", MS_RDONLY) = 3
mount            657     657     4026531841  fsconfig(3, FSCONFIG_SET_STRING, "source", "incus_debvm_shared", 0) = 0
mount            657     657     4026531841  fsconfig(3, FSCONFIG_CMD_CREATE, "", "", 0) = -EINVAL

A successful one:

mount            664     664     4026531841  fsopen("virtiofs", MS_RDONLY) = 3
mount            664     664     4026531841  fsconfig(3, FSCONFIG_SET_STRING, "source", "incus_debvm_shared", 0) = 0
mount            664     664     4026531841  fsconfig(3, FSCONFIG_CMD_CREATE, "", "", 0) = 0
mount            664     664     4026531841  fsmount(3, MS_RDONLY, 0x0) = 4
mount            664     664     4026531841  move_mount(4, "", AT_FDCWD, "/host", MOVE_MOUNT_F_EMPTY_PATH) = 0

This is consistent with the “tag not found” error message of course.

When it fails, the incus-agent running in debug mode shows:

Apr 01 20:05:31 debvm incus-agent[577]: time="2025-04-01T20:05:31Z" level=debug msg="API Request\n\t{\n\t\t\"metadata\": {\n\t\t\t\"action\": \"added\",\n\t\t\t\"config\": {\n\t\t\t\t\"path\": \"/host\",\n\t\t\t\t\"source\": \"/root\",\n\t\t\t\t\"type\": \"disk\"\n\t\t\t},\n\t\t\t\"name\": \"debvm_shared\"\n\t\t},\n\t\t\"timestamp\": \"2025-04-01T22:05:32.415517711+02:00\",\n\t\t\"type\": \"device\"\n\t}"
Apr 01 20:05:31 debvm incus-agent[577]: time="2025-04-01T20:05:31Z" level=info msg="Failed to mount hotplug \"incus_debvm_shared\" (Type: \"virtiofs\") to \"/host\""

But that error is not propagated to the host (the device is seen as successfully added on the host).

It really smells like a race condition between virtiofsd’s creation of the share, and incusd asking incus-agent to mount it.

After more debug I filed Sharing directory with VM fails randomly with CONFIG_VIRTIO_FS=Y · Issue #1881 · lxc/incus · GitHub

1 Like