9p virtfs device reports error when opening certain files

Bug #1877688 reported by A A
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
QEMU
Fix Released
Undecided
Christian Schoenebeck

Bug Description

Reading certain files on a 9p mounted FS produces this error message:

qemu-system-x86_64: VirtFS reply type 117 needs 12 bytes, buffer has 12, less than minimum

After this error message is generated, further accesses to the 9p FS hangs whatever tries to access it. The Arch Linux guest system is otherwise usable. This happens with QEMU 5.0.0 and guest kernel version 5.6.11, hosted on an Arch Linux distro. I use the following command to launch QEMU:

exec qemu-system-x86_64 -enable-kvm -display gtk -vga virtio -cpu host -m 4G -netdev tap,ifname=vmtap0,id=vn0,script=no,downscript=no -device virtio-net-pci,netdev=vn0 -kernel kernel.img -drive file=file.img,format=raw,if=virtio -virtfs local,path=mnt,mount_tag=host0,security_model=passthrough,id=host0 -append "console=ttyS0 root=/dev/vda rw"

There's nothing relevant in the guest kernel logs as far as I'm aware of with loglevel set to 7.

I tracked down the issue to readv() with a small buffer(<=12 bytes) and then a large buffer(>= 1024 bytes). A C program is provided to trigger this behavior.

Tags: 9p virtfs
A A (c3bacd17)
description: updated
Revision history for this message
A A (c3bacd17) wrote :

Here's a C program to trigger this behavior. I don't think it matters what the contents of "file" or its size is.

description: updated
Revision history for this message
Christian Schoenebeck (schoenebeck) wrote :

Looks like being introduced by this change:
https://patchwork.kernel.org/patch/11319993/

More specifically this one exactly:

- if (buf_size < size) {
+ if (buf_size < P9_IOHDRSZ) {

Revision history for this message
Christian Schoenebeck (schoenebeck) wrote :

The following patch should fix this bug for the kvm backend (not for the XEN backend yet).

Please let me know if it fixes this bug for you.

Changed in qemu:
status: New → In Progress
assignee: nobody → Christian Schoenebeck (schoenebeck)
Revision history for this message
A A (c3bacd17) wrote :

Thanks, it works.

Revision history for this message
Christian Schoenebeck (schoenebeck) wrote :

Fix is now committed on master as SHA-1 cf45183b718f02b1369e18c795dc51bc1821245d, which actually just reverted the mentioned commit that was leading to this broken behavior:
https://github.com/qemu/qemu/commit/cf45183b718f02b1369e18c795dc51bc1821245d

The original Xen transport bug that motivated that change, was now fixed differently by handling that Xen issue solely on Xen transport driver side:
https://github.com/qemu/qemu/commit/a4c4d462729466c4756bac8a0a8d77eb63b21ef7

Changed in qemu:
status: In Progress → Fix Committed
Revision history for this message
Christian Schoenebeck (schoenebeck) wrote :

Fixed in QEMU 5.1 release.

Changed in qemu:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.