Cannot write to MTP Devices in Qemu 6.0.0+
Host environment
- Operating system: NixOS
- OS/kernel version: Linux 5.15.11 #1-NixOS SMP Wed Dec 22 08:32:52 UTC 2021 x86_64 GNU/Linux
- Architecture: x86
- QEMU flavor: qemu-system-x86_64
- QEMU version: 6.1.0 and 6.2.0
- QEMU command line:
qemu-system-x86_64 -M q35 -m 4096 -enable-kvm -hda machine.qcow2 -usb -device usb-mtp,rootdir=/tmp,readonly=false
Emulated/Virtualized environment
- Operating system: NixOS
- OS/kernel version: Linux 5.15.11 #1-NixOS SMP Wed Dec 22 08:32:52 UTC 2021 x86_64 GNU/Linux
- Architecture: x86
Description of problem
QEMU versions above 6.0.0 are no longer able to write to MTP devices, the kernel prints a warning which is unique to versions above 6.0.0:
usb-mtp: file monitoring init failed: File monitoring not available on this platform is just warning
Steps to reproduce
- Launch a QEMU virtual machine with
-usb -device usb-mtp,rootdir=/tmp,readonly=false
using any QEMU version above 6.0.0 - Mount the MTP device using something:
mkdir mtpDevice && jmtpfs mtpDevice
- Try to write to the mtp device:
touch mtpDevice/test
- Observe that you will get an input/output error when trying to write to the device, like this:
vm-test-run-mtp> client: must succeed: /nix/store/xmib7222ybr72iyycra4w386s8p1k4av-jmtpfsTest.sh >&2 vm-test-run-mtp> client # Device 0 (VID=46f4 and PID=0004) is a QEMU Virtual MTP. vm-test-run-mtp> client # qemu-system-x86_64: usb-mtp: file monitoring init failed: File monitoring not available on this platform vm-test-run-mtp> client # /nix/store/xmib7222ybr72iyycra4w386s8p1k4av-jmtpfsTest.sh: line 4: phone/tmp/testFile: Input/output error