From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Marusich Subject: QEMU USB pass-through Date: Sat, 19 Oct 2019 13:13:14 -0700 Message-ID: <87v9skcx45.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:49816) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLv6G-0005zJ-Rm for help-guix@gnu.org; Sat, 19 Oct 2019 16:13:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLv6F-0004ZG-7w for help-guix@gnu.org; Sat, 19 Oct 2019 16:13:20 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:40874) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLv6F-0004Yr-01 for help-guix@gnu.org; Sat, 19 Oct 2019 16:13:19 -0400 Received: by mail-pf1-x443.google.com with SMTP id x127so5892072pfb.7 for ; Sat, 19 Oct 2019 13:13:18 -0700 (PDT) Received: from garuda.local ([2601:601:9d80:25b2::f11]) by smtp.gmail.com with ESMTPSA id 13sm11052543pgm.76.2019.10.19.13.13.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2019 13:13:16 -0700 (PDT) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: help-guix@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, I recently tried to pass through a USB flash drive to a VM using QEMU, and I couldn't get it working. Has anyone successfully used QEMU's USB pass-through feature on a Guix system? When I plug a USB flash drive into my Guix system using GNOME, GNOME automatically mounts it for me. So I unmounted by running "umount" as root. It didn't seem to get automatically re-mounted, which is good, and by running "lsblk -f" I verified that it remained unmounted. Based on the output of "lsusb", this flash drive uses bus address 001, and device address 006. I tried launching the VM like this: qemu-system-x86_64 \ -net user,hostfwd=3Dtcp:127.0.0.1:2222-:22 \ -net nic,model=3Dvirtio \ -enable-kvm \ -m 512 \ -smp 1 \ -device virtio-blk,drive=3Dmyhd \ -drive if=3Dnone,file=3Ddebian,id=3Dmyhd \ -vga std \ -usb \ -device usb-host,hostbus=3D1,hostaddr=3D8 \ -monitor stdio Note that for QEMU to launch without errors, I had to give myself read/write permissions on the USB device node: $ sudo setfacl -m u:marusich:rw /dev/bus/usb/001/008 QEMU launches the VM launches without errors. Within it, I can see a block device at /dev/sda (the virtual hard drive "myhd" shows up as /dev/vda). However, when I try to read from it, it doesn't work: marusich@debian:~$ sudo head --bytes=3D512 /dev/sda | hexdump -C [sudo] password for marusich:=20 head: error reading '/dev/sda': Input/output error Meanwhile, in the host, dmesg says stuff like this. First, right after I launch the VM: [169152.893485] udevd[215]: specified group 'plugdev' unknown [169152.973558] sd 4:0:0:0: [sdb] Synchronizing SCSI cache [169153.306104] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169155.074112] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169155.374116] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169167.054727] kvm [22097]: vcpu0, guest rIP: 0xffffffff9565db48 disable= d perfctr wrmsr: 0xc2 data 0xffff [169167.265174] udevd[215]: specified group 'plugdev' unknown [169167.394116] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169170.006107] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169170.605105] udevd[215]: specified group 'plugdev' unknown [169170.718133] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169171.146116] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169176.759220] udevd[215]: specified group 'plugdev' unknown [169176.870112] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169178.838435] udevd[215]: specified group 'plugdev' unknown [169178.966118] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169180.438119] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169181.650113] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169183.564845] udevd[215]: specified group 'plugdev' unknown [169184.066115] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169185.446110] usb 1-1: reset high-speed USB device number 9 using ehci-= pci Even after I shut down the VM, the messages continue: [169186.776158] udevd[215]: specified group 'plugdev' unknown [169186.894128] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169187.594122] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169188.442126] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169189.194114] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169189.933640] udevd[215]: specified group 'plugdev' unknown [169190.058150] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169190.746120] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169191.566121] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169192.290112] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169193.158971] udevd[215]: specified group 'plugdev' unknown [169193.282121] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169193.706136] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169194.530116] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169194.954115] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169195.774120] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169196.194117] usb 1-1: reset high-speed USB device number 9 using ehci-= pci But eventually, the USB device stops getting reset, and it shows up automatically in my host system again (GNOME proceeds to auto-mount it, too): [169324.539442] udevd[215]: specified group 'plugdev' unknown [169324.654115] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169325.086114] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169325.898113] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169326.326106] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169327.142098] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169327.574131] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169327.754133] udevd[215]: specified group 'plugdev' unknown [169328.126102] usb 1-1: reset high-speed USB device number 9 using ehci-= pci [169328.466887] usb-storage 1-1:1.0: USB Mass Storage device detected [169328.485130] scsi host4: usb-storage 1-1:1.0 [169329.846284] scsi 4:0:0:0: Direct-Access SMI USB DISK = 1100 PQ: 0 ANSI: 6 [169329.847241] sd 4:0:0:0: Attached scsi generic sg1 type 0 [169329.848630] sd 4:0:0:0: [sdb] 61440000 512-byte logical blocks: (31.5= GB/29.3 GiB) [169329.852458] sd 4:0:0:0: [sdb] Write Protect is off [169329.852460] sd 4:0:0:0: [sdb] Mode Sense: 43 00 00 00 [169329.853665] sd 4:0:0:0: [sdb] Write cache: enabled, read cache: enabl= ed, doesn't support DPO or FUA [169329.860891] sdb: sdb1 sdb2 [169329.865264] sd 4:0:0:0: [sdb] Attached SCSI removable disk This is pretty weird. I tried all of the following, but I saw the same results every time: * Run QEMU as root. * Unbind the ehci-pci driver (so Linux will use uhci_hcd instead) * Pass additional -device options for the other USB devices, including a hub that shows up on the same bus. * Try a different USB port. * Try a different USB storage device. If anyone has gotten USB pass-through working with QEMU on a Guix system, please let me know what I'm doing wrong! Thank you, =2D-=20 Chris --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEy/WXVcvn5+/vGD+x3UCaFdgiRp0FAl2rbloACgkQ3UCaFdgi Rp0I2g//Y1NUd5kaULHgYEpr/VAI3F/jOm6tEjteQ5jAhxRgjkEO12fmFJQtoyI7 6puFrCjzjmhcjaU+w/QZ0sMQ7uequ5yAmY5yVjLmJc8gZk5pj7kYcTu219tFkRZI COsVr87xSlvJmFjBcpifGE8UsBBtULKpGIV+xwmqPb0sD0pegeM4nD0DmEB58wo8 fJErS86SwhbXW209Q5fsgaQJ7xdP+5x1BJW4Q+M573io5ATyyVSDpwBOhdFKrtjM BX0e6KEobZUbOpwQFCUokdFhOKGHlknONgytVXdFJBTivqytZW9UgSRrJighxMGD xyltLPGfC0ujUUtg1uZz8Ax4lqNfslfeU4qEg5deLsCJG1eSpLrAocsRbzDXK/q8 N9QsqHjnICByg4blrwu7xjyXLdzOn6AdTsEiU1daoPOmHYdwzXrw/rb//wsEh2UX Q4/yOIBMmdrDSYXmGA/iLQlUAnjiejEZtZCP3W2mnEJ7CKjCfe4MXGf/DMZ778LU XNaW7KbAkHXGCsVxek+bKfiTpogZ+O//prbjp0yM5+Yb3vBZc201QxnRlJvIbhuc VoptumHls2ylCwDb9DLwrqoATw+TCR35AEwrIpNfSiFJ1AHkS3mGCQNumlYirmtZ w8Ve0VA5meL/aK7fKOE4ed8NNR1vl5kbqpUa4iXWD4eOoVK+DDY= =Dl3n -----END PGP SIGNATURE----- --=-=-=--