title: QEMU usb keyboard passthrough difficulties
body: <p>I'm having trouble getting QEMU to recognize my keyboard.
  The host machine is windows 7. The client is solaris 10 SPARC. I'm running commands through cygwin.</p>
  <p>Everything starts up, but when it comes time to input anything, no strokes are captured.</p>
  <p>My keyboard, mouse and monitors are connected to my computer via a physical dell hub which might affect things. But because my computer has few usb slots, the hub is needed.</p>
  <p>However, I can see my usb keyboard and mouse like normal using lsusb:</p>
  <pre><code>$ lsusb
  Bus 002 Device 022: ID 046d:c016 Logitech, Inc. Optical Wheel Mouse
  ...
  Bus 002 Device 029: ID 413c:2107 Dell Computer Corp.
  Bus 002 Device 002: ID 413c:9016 Dell Computer Corp.
  ...
  </code></pre>
  <p>I double checked with -v, and Bus 002, Device 029 is the keyboard</p>
  <pre><code>Bus 002 Device 029: ID 413c:2107 Dell Computer Corp.
  Device Descriptor:
    bLength                18
    bDescriptorType         1
    bcdUSB               1.10
    bDeviceClass            0 (Defined at Interface level)
    bDeviceSubClass         0
    bDeviceProtocol         0
    bMaxPacketSize0         8
    idVendor           0x413c Dell Computer Corp.
    idProduct          0x2107
    bcdDevice            1.15
    iManufacturer           1 Dell
    iProduct                2 Dell USB Entry Keyboard
  </code></pre>
  <p>I can usually get to the choose language dialog but then I either can't input anything or it doesn't take (depending on the options):</p>
  <pre><code>OpenBIOS for Sparc64
  Configuration device id QEMU version 1 machine id 0
  kernel cmdline
  CPUs: 1 x SUNW,UltraSPARC-IIi
  UUID: 00000000-0000-0000-0000-000000000000
  Welcome to OpenBIOS v1.1 built on Feb 15 2019 10:05
    Type 'help' for detailed information
  [Evaling fcode, entry point...]
  SunOS Release 5.10 Version Generic_147147-26 64-bit
  Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.
  could not find debugger-vocabulary-hook&gt;threads:interpret: exception -13 caught
  interpret \ Copyright (c) 1995-1999 by Sun Microsystems, Inc.
  [Some pragma stuff...]
  h# unix-tte:interpret: exception -13 caught
  interpret ' unix-tte is va&gt;tte-data failed with error ffffffffffffffed
  WARNING: consconfig: cannot find driver for screen device /pci@1fe,0/pci@1,1/QEMU,VGA@2
  Configuring devices.
  WARNING: ata_controller[0] - Unsupported Controller
          Vendor 0x9510, Device 0x4606, Revision 0x7
  WARNING: Out of range register specification from device node &lt;fdthree&gt;
  /platform/sun4u/kernel/drv/sparcv9/i8042: undefined symbol 'i_ddi_alloc_ispec'
  WARNING: mod_load: cannot load module 'i8042'
  WARNING: ata_controller[0] - Unsupported Controller
          Vendor 0x9510, Device 0x4606, Revision 0x7
  WARNING: Out of range register specification from device node &lt;fdthree&gt;
  /platform/sun4u/kernel/drv/sparcv9/i8042: undefined symbol 'i_ddi_alloc_ispec'
  WARNING: mod_load: cannot load module 'i8042'
  WARNING: SUNW,hme0 : No transceiver found., SEVERITY_HIGH, XCVR
  
  WARNING: SUNW,hme0 : No transceiver found., SEVERITY_HIGH, XCVR
  
  WARNING: SUNW,hme0 : Failed to initialize hardware/driver, SEVERITY_HIGH, INIT  
  
  Using RPC Bootparams for network configuration information.
  svc:/system/filesystem/local:default: WARNING: /usr/sbin/zfs mount -a failed: one or more file systems failed to mount
  Serial console, reverting to text install
  Beginning system identification...
  Searching for configuration file(s)...
  Search complete.
  Discovering additional network configuration...
  Select a Language
  
     0. English
     1. Brazilian Portuguese
     2. French
     3. German
     4. Italian
     5. Japanese
     6. Korean
     7. Simplified Chinese
     8. Spanish
     9. Swedish
    10. Traditional Chinese
  
  Please make a choice (0 - 10), or press h or ? for help:
  [Cannot input, or if can, doesn't take]
  </code></pre>
  <p>I'm convinced this has to do with proper arguments for usb passthrough, but I'm not sure which ones. For convenience sake, assume all the following commands start with</p>
  <pre><code>&quot;C:\Program Files\qemu\qemu-system-sparc64&quot; -m 2048 -cdrom &quot;sol-10-u11-ga-sparc-dvd.iso&quot; -k en-us -boot d 
  </code></pre>
  <p>Things I've tried:</p>
  <ol>
  <li><p><strong>No additional options</strong></p>
  <p>I get to the select language step but cannot input anything. I have checked that I am 'grabbed' by the qemu window when I try to type.</p>
  </li>
  <li><p><strong>No graphics Mode</strong></p>
  <pre><code> -nographic 
  </code></pre>
  <p>I eventually need graphics (which is going to be another bag of worms), but for now I tried turning it off. This allows me to get to the select language step, but imputing the selection and hitting enter does nothing. Perhaps it has something to do with the failure to initialize hardware driver?</p>
  </li>
  <li><p><strong>Specifying keyboard at high level</strong></p>
  <pre><code>-device usb-kbd
  </code></pre>
  <p>Which gives me</p>
  <pre><code>No 'usb-bus' bus found for device 'usb-kbd'
  </code></pre>
  </li>
  <li><p><strong>Specifying hostbus and address</strong></p>
  <pre><code>-device usb-host,hostbus=2,hostaddr=29
  </code></pre>
  <p>Which also gives me</p>
  <pre><code>No 'usb-bus' bus found for device 'usb-host'
  </code></pre>
  </li>
  <li><p><strong>Specifying vendorid and productid</strong></p>
  <pre><code>-device piix4-usb-uhci,id=usb,bus=pci,addr=0x4 -device usb-host,vendorid=0x413c,productid=0x2107
  </code></pre>
  <p>I can't seem to find a free, non-reserved slot. They all already have a device in them or return something like:</p>
  <pre><code>PCI: slot 4 function 0 not available for piix4-usb-uhci, reserved
  </code></pre>
  <p>I think uhci is usb 1.0, should I have a different specifier in the first device argument? I can see the options with <code>-device help</code> but don't know what I should pick.</p>
  </li>
  <li><p><strong>Different Devices and OS</strong></p>
  <p>I've tried getting QEMU to take input for this solaris client on Windows 7, 10 and Ubuntu 18.04.2 LTE hosts across two different physical computers and this gave the same problem.</p>
  <p>I know the keyboard works, as it is fine on the host OS. I know the keyboard works with other emulated OS because I got an x86 ubuntu client working fine.</p>
  </li>
  <li><p><strong>QEMU Monitor</strong></p>
  <p>I've tried bringing up the QEMU monitor as the VM is running and using <code>sendkey</code>. Didn't work. However,  <code>info</code> says that the VM is running. <code>usb</code> returns no devices.</p>
  </li>
  </ol>
  <p>I've gone through the following links:</p>
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/19665412/mouse-and-keyboard-not-working-in-qemu-emulator">Mouse and Keyboard not working in qemu emulator</a></p>
  <p>I'm not getting the <code>key event queue full</code> error but tried the answers given anyway, namely the simple <code>-device usb-kbd</code> approach and bus/address approaches.</p>
  </li>
  <li><p><a href="https://stackoverflow.com/questions/29620355/qemu-problems-with-mouse-and-keyboard-settings">QEMU: problems with mouse and keyboard settings</a></p>
  <p>Similar sounding but unrelated cause.</p>
  </li>
  <li><p><a href="https://stackoverflow.com/questions/49100056/how-to-passthrough-usb-device-through-qemu-in-windows">How to passthrough USB device through Qemu in Windows?</a></p>
  <p>No answers</p>
  </li>
  <li><p><a href="https://brezular.com/2012/02/17/installation-solaris-2-6-sparc-on-qemu-part2-solaris-installation/" rel="nofollow noreferrer">https://brezular.com/2012/02/17/installation-solaris-2-6-sparc-on-qemu-part2-solaris-installation/</a></p>
  <p>They didn't run into this error.</p>
  </li>
  <li><p><a href="https://superuser.com/questions/1005571/usb-passthrough-for-qemu-gets-error-qemu-could-not-add-usb-device">https://superuser.com/questions/1005571/usb-passthrough-for-qemu-gets-error-qemu-could-not-add-usb-device</a></p>
  <p>This details both the bus/address and vendorid/productid approach, which I tried.</p>
  </li>
  <li><p><a href="https://bugs.launchpad.net/qemu/+bug/685096" rel="nofollow noreferrer">https://bugs.launchpad.net/qemu/+bug/685096</a></p>
  <p>Halfway through thread; also details vendorid/productid approach, which I tried.</p>
  </li>
  <li><p><a href="https://www.linuxquestions.org/questions/slackware-14/qemu-keyboard-does-not-work-523168/" rel="nofollow noreferrer">https://www.linuxquestions.org/questions/slackware-14/qemu-keyboard-does-not-work-523168/</a></p>
  <p>I tried running with <code>-k</code> option to no affect. I'm not running with sudo.</p>
  </li>
  </ul>