9pfs file create with mapped-xattr can fail on overlayfs
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
QEMU |
Expired
|
Undecided
|
Unassigned |
Bug Description
QEMU Version: 3.1.0 as packaged in debian buster, but the code appears to do the same in master.
qemu command-line: qemu-system-x86_64 -m 1G -nographic -nic "user,model=
I'm using CI that runs in a Docker container and runs a qemu VM with code and results shared via virtio 9p.
The 9p fsdev is configured with security_
When the test code attempts to create a log file in an existing directory, open with O_CREAT fails with -ENOENT.
The relevant strace excerpt is:
28791 openat(11, ".", O_RDONLY|
28791 openat(20, "src", O_RDONLY|
28791 fcntl(21, F_SETFL, O_RDONLY|
28791 close(20) = 0
28791 openat(21, "client.log", O_WRONLY|
28791 fcntl(20, F_SETFL, O_WRONLY|
28791 lsetxattr(
My hypothesis for what's going wrong is since the Docker container's overlayfs copies-up on writes, when it opens the file it's created a new version of the `src` directory containing a `client.log`, but this new src directory isn't accessible by file descriptor 20 and the lsetxattr call is instead attempting to set attributes on the path in the old `src` directory.
Looking at the code, a fix would be to change `hw/9pfs/
This reliably happened for me in CI, but I don't have access to the CI host or the time to strip the test down to make a minimal test case, and had difficulty reproducing the error on other machines.
Since the report is about overlayfs being involved, could you please try if
the following patch makes a difference?
https:/ /github. com/gkurz/ qemu/commit/ f7f5a1b01307af1 c7b6c94672f2ce7 5c36f10565
It's not yet on master, but will be soon.