knazarov / homebrew-qemu-virgl

A homebrew tap for qemu with support for 3d accelerated guests
420 stars 68 forks source link

20210725.1 release missing usb-host device #38

Closed molind closed 3 years ago

molind commented 3 years ago

In previous release I had no issues with bridging my printer to qemu. Now it returns an error. Is it issue with

qemu-system-aarch64: -device usb-host,vendorid=0x04e8,productid=0x3301: 'usb-host' is not a valid device model name

knazarov commented 3 years ago

Are you running qemu as root? As far as I remember, it requires root to passthrough the usb. Otherwise it’s strange, because the implementation didn’t really change all that much. We’ll need to probably do some more digging if that’s the case.

molind commented 3 years ago

No I running it from normal user. And when i build formula from 917e219ca0caa41a3dba28192465416a4c449101 it works fine. When I build it from head commit 0bcbb8f590f27738adb757b355c81d30a0e469f5 it returns an error: "'usb-host' is not a valid device model name".

Seems something inside qemu build scripts changed between those two commits.

In your patchV4

diff --git a/configure b/configure
index 85db248ac1..f711778086 100755
--- a/configure
+++ b/configure
@@ -377,6 +377,7 @@ u2f="auto"
 libusb="auto"
 usb_redir="auto"
 opengl="$default_feature"
+egl="no"
 cpuid_h="no"
 avx2_opt="$default_feature"
 capstone="auto"

but in patchV3

diff --git a/configure b/configure
index 4f374b4889..49fb478ac9 100755
--- a/configure
+++ b/configure
@@ -394,6 +394,7 @@ u2f="auto"
 libusb="$default_feature"
 usb_redir="$default_feature"
 opengl="$default_feature"

May be this difference somehow changes number of built qemu modules.

My full command to run it:

qemu-system-aarch64 \
         -machine virt,accel=hvf,highmem=off \
         -cpu cortex-a72 -smp 2 -m 4G \
         -device intel-hda -device hda-output \
         -device virtio-gpu-pci \
         -device virtio-keyboard-pci \
         -device virtio-net-pci,netdev=net \
         -device virtio-mouse-pci \
         -device qemu-xhci \
         -device usb-host,vendorid=0x04e8,productid=0x3301 \
         -display cocoa,gl=es \
         -netdev user,id=net,ipv6=off \
         -drive "if=pflash,format=raw,file=./edk2-aarch64-code.fd,readonly=on" \
         -drive "if=pflash,format=raw,file=./edk2-arm-vars.fd,discard=on" \
         -drive "if=virtio,format=raw,file=./hdd.raw,discard=on"
knazarov commented 3 years ago

This is an interesting finding. Could you please check if usb-host works on unpatched qemu on mac? If it does, we’ll be sure that the virgl patchset breaks something.

You can install it with brew install qemu. But please make sure you uninstall qemu-virgl before trying.

molind commented 3 years ago

It prints lots of qemu-system-aarch64: qemu_mprotect__osdep: mprotect failed: Permission denied and enters into qemu console. But no errors about usb devices.

knazarov commented 3 years ago

Try running it with sudo. Permission denied may be due to the real lack of permissions.

molind commented 3 years ago

No change. It returns the same error.

knazarov commented 3 years ago

OK, I was planning to get myself an arm-based mac today. I’ll try to reproduce the problem and let you know.

knazarov commented 3 years ago

@molind I was able to get my hands on a M1 Mac today, and verified that it really is an upstream problem in qemu that was fixed a few days ago. I'm cherry-picking the fix here: #41

lazevedo commented 2 years ago

Could we get a release with this? Would be much appreciated

knazarov commented 2 years ago

Could we get a release with this? Would be much appreciated

Sure. There’s an updated patchset from the author, so I’ll be working on it around this weekend.