Ошибка перенаправления usb

@0xABAB

This needs more information. For example, you are not specifying via which user you are trying to do these things.

@ghost

User is in wheel and libvirtd. I have found the same issue discussed on arch, with some hack changing ownership of the device to group ‘spice’. Also, from same thread, assigning the device manually before starting the VM should work(I havent tested this yet, ongoing)

@ghost

Changing the ownership of /dev/bus/usb to ‘spice’ and adding the user to it works.
It seems the arch ppl were using a newer spice-gtk(0.13.3) than I was(0.13). Im updating now to get the same version and give it a try.

@sjau

I’m facing the same issue with virt-manager. Also I have no group «spice». Can you tell me how you got it to work?

Relevant portions of my configuration.nix:

    # Define a user account. Don't forget to set a password with ‘passwd’.
    users.defaultUserShell = "/var/run/current-system/sw/bin/bash";
    users.extraUsers.${mySecrets.user} = {
        isNormalUser = true;    # creates home, adds to group users, sets default shell
        description = "${mySecrets.user}";
        extraGroups = [ "networkmanager" "vboxusers" "wheel" "audio" "cdrom" "kvm" "libvirtd" ]; # wheel is for the sudo group
        uid = 1000;
        initialHashedPassword = "${mySecrets.hashedpasswd}";
    };


    # Enable libvirtd daemon
    virtualisation.libvirtd = {
        enable = true;
        enableKVM = true;
    };
    services.spice-vdagentd.enable = true;

    environment.systemPackages = with pkgs; [
        ......
        spice
        win-spice
        virtmanager
        virt-viewer
        ......
    ];

@ghost

@bjornfor

I use this brute force udev rule:

  # Access to /dev/bus/usb/* devices. Needed for virt-manager USB
  # redirection.
  SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664", GROUP="wheel"

(Not sure it’s a good idea in general. I’m afraid it may conflict with other more fine grained rules.)

@steveej

I run virt-manager with sudo at the moment to workaround this issue. Not ideal either but at least I don’t have to modify permissions manually.

Another problem I have is that USB auto redirection is not working. Can you confirm this? Manual redirection doesn’t work well when flashing firmware to a device that intermittently reboots with a different device id.

@ghost

I’d probably rather modify perms for a usb device via udev (I think this is actually sort of the generally accepted method) than run it as root. :/

If by auto redirection you mean automatically redirecting when you plug it in, I pleasantly discovered that’s a thing by accident and it does in fact work with the udev solution. Presumably because it does keep it’s ID.

I don’t know why your device changes it’s iD? I thought device IDs were static values….
Ah, unless whatever reflashing you’re doing changes your ID. I think udev maybe has other matching functionality so maybe it can match on name for example? If there is actually anything you could match on, probably https://wiki.archlinux.org/index.php/udev#List_attributes_of_a_device should help find it.

I really don’t know if this is a good idea at all, but maybe it would be possible to just shotgun get access to all usb devices.

It would be nice if the root cause for this could get fixed but I have no idea what the proper fix would be. I guess it’s pretty useless to say this since that’s probably what everyone wants.

@sjau

I also modified it by udev:

    # Make smartcard reader and label printer accessible to everyone, so they can be passed to the VM
    services.udev.extraRules = ''
        SUBSYSTEM=="usb", ATTR{idVendor}=="072f", ATTR{idProduct}=="90cc", GROUP="users", MODE="0777"
        SUBSYSTEM=="usb", ATTR{idVendor}=="04f9", ATTR{idProduct}=="2043", GROUP="users", MODE="0777"
    '';

@ghost

Yes your solution is what I used. :) Lucky google find.

@sjau

@steveej

If by auto redirection you mean automatically redirecting when you plug it in, I pleasantly discovered that’s a thing by accident and it does in fact work with the udev solution. Presumably because it does keep it’s ID.

Nice to hear that it’s not generally broken on NixOS ;-) However, it’s not a permission issue on my end. I have tried both, using sudo and granting access to my user via udev rules.
The issue for me is that virt-manager does not even attempt to redirect automatically, and I have to manually redirect each device.

@xeji
xeji

mentioned this issue

Feb 20, 2018

8 tasks

xeji

added a commit
to xeji/nixpkgs
that referenced
this issue

Mar 4, 2018

@xeji

Build with polkit and acl to enable usb redirection
in virt-viewer and virt-manager. Fixes NixOS#27199
usb redirection requires a setuid wrapper, see comment in code.

@theotheroracle

i’m still experiencing this issue
image
i’m using a user-session, if that’s the issue, i do this so i can use gnome-boxes

i tried adding the above rules: SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664", GROUP="wheel"
from #27199 (comment)

and i tried adding

SUBSYSTEM=="usb", GROUP="libvirtd", MODE="0660"
SUBSYSTEM=="usb_device", GROUP="libvirtd", MODE="0660"

from https://bbs.archlinux.org/viewtopic.php?pid=1628757#p1628757

and i still get the same error

openSUSE Forums

Loading

CTX234916


{{tooltipText}}

Article
|


Configuration

|

{{likeCount}} found this helpful
|

Created:
{{articleFormattedCreatedDate}}

|
Modified:
{{articleFormattedModifiedDate}}

Symptoms or Error

Setting a USB device to Generic USB redirection fails.

Redirecting a devices like HID type devices may fail to redirect.  Explicitly setting Citrix XenApp/XenDesktop policies in Studio or AD to allow Client USB deivce redirection and setting Client USB device redirection rules — and is noted that device fails to appear in Desktop Viewer or appears as Policy Restricted.


Solution

Registry setting DeviceRules on the client computer take precedent over Citrix Studio, AD, and Receiver.admx policies.  (The client computer is the computer with Receiver for Windows installed).

Review the registry data on the client computer in the registry setting
DeviceRules.

Path: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Citrix\ICA Client\GenericUSB

Name: DeviceRules

Type: REG_MULTI_SZ

Observe that specific devices classes and subclasses are denied in the DeviceRules setting.

If the device class you are attempting to redirect is listed as Deny in the DeviceRules- then create a new entry above the Deny related to device class or place a # in front of the target class / subclass or delete the entry to remove the device rule that is blocking the redirection.

A walkthrough — How to enable Imprivata HDW-IMP-60 device.

Step 1.  Review the device on the client computer.  Record the class, subclass, VID and PID settings.  Open device manager and find the target USB device.

User-added image

The target device has a Class 03 and SubClass 01.  Note this matches a DENY rule in the client registry DeviceRules.

User-added image

Modify the DeviceRules registry entry on the client computer (highlighted below).  Add an ALLOW rule for the target device above the DENY rule that matches the class and subclass or optionally comment the line with a ‘#’ character …

User-added image

Now create a Client USB device redirection and Client USB device redirection rules policy that applies to the target.

User-added image

Once the policy applies and the client computer registry is modified now the device appears in Device manager as a Generic device.  The device is ready for redirection as a generic device.

User-added image

After selecting the Redirect in the Device manager the device is available in the VDA ICA session.  Open device manager on the VDA and confirm that the Imprivata HID type device appears in the VDA session- by reviewing the VID and PID of the device.

User-added image


Problem Cause

DeviceRules registry setting take precedent over Citrix policies in Studio, AD and Receiver.admx policies on the client computer.


Disclaimer

Caution! Using Registry Editor incorrectly can cause serious problems that might require you to reinstall your operating system. Citrix cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk. Be sure to back up the registry before you edit it.


1

3

Есть USB-ЦАП/АЦП и софтина к нему, под онтопиком ни то, ни другое не работает. Софтина шибко проприетарная, защищена HASP ключом. Я пытаюсь заставить всё это работать в виртуалке.
Собственно, девайсы:

Bus 003 Device 011: ID 0529:0001 Aladdin Knowledge Systems HASP copy protection dongle
Bus 003 Device 010: ID 16b2:1001
ls -l /dev/bus/usb/003
...
crw-rw-r-- 1 root qemu 189, 265 дек 22 18:29 010
crw-rw-rw- 1 root qemu 189, 266 дек 22 18:29 011

Пользователь добавлен в группу qemu.
Команда запуска qemu:

qemu-system-x86_64 
    -enable-kvm 
    -m 2G 
    -device usb-ehci,id=usb,bus=pci.0,addr=0x4 
        --device usb-host,vendorid=0x16b2,productid=0x1001  # USB-девайс, ради которого весь сыр-бор
    -device piix3-usb-uhci,id=usb1,bus=pci.0,addr=0x5 
        --device usb-host,vendorid=0x0529,productid=0x0001  # USB-HASP
    -usbdevice tablet 
    -net nic 
    -net bridge,br=br0 
    -vga qxl 
    -spice port=5930,disable-ticketing 
    -device virtio-serial-pci 
    -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 
    -chardev spicevmc,id=spicechannel0,name=vdagent 
    -drive file=/mnt/data/win-patch.img,if=virtio

Проблема: оба девайса в госте видны, но не работают. ЦАП/АЦП должен определяться как USB носитель, так он и определяется, но как-то не совсем. Дрова на HASP ключ в гостя поставил, но софтина его всё равно не видит. ЧЯДНТ?

To correct the issue, shut down the Windows 10 guest. From Virtual Machine Manager (aka virt-manager), open the properties of the Windows 10 guest. Click the tab «Controller USB 0», change the Model from the default of «USB 2» to «USB 3», and click button «Apply». Start the Windows 10 guest, perform the USB Redirect, read a disc, and verify that the USB resets and disconnects have ceased.

Additionally, after changing «Controller USB 0» to Model «USB 3», read performance increased from 4 MB/s to 13 MB/s.

The host’s USB controller is USB 2.0. The USB to SATA bridge is USB 2.0. From what I’ve read, USB Redirect is limited to USB 2.0. I find it baffling that this minor configuration change has corrected the issue, but after reading discs for weeks without issue, it certainly is fixed.

I spent several weeks troubleshooting this, and I hope it helps others.

———- Current Working Configuration ———-

Host:

Linux Mint 19.1 x64 Cinnamon (Tessa) running QEMU/KVM and Virtual Machine Manager
Supermicro X9SCM system board (C204 USB Enhanced Host Controller (EHCI))
StarTech USB2SATAIDE USB 2.0 to IDE or SATA Adapter Cable (JMicron JM20337 - USB 152d:2338)
Asus BW-16D1HT, LG WH16NS40, Pioneer BDR-209D, and Pioneer BDR-209M

Guest:

Windows 10 x64 version 1909 (no additional Windows updates)
Architecture options:  x86_64
OS type:  Windows
Version:  Microsoft Windows 10
Memory (RAM) MiB:  8192
CPUs:  2
Network selection:  Bridge br0: Host device enoX
NIC:  Device model:  virtio
Chipset:  Q35
Enable boot menu:  <checked>
Hard drives:  Advanced options:  Disk bus:  VirtIO
Optical drives:  Advanced options:  Disk bus:  SATA
Display Spice:  Address:  Localhost only
Channel spice:  spicevmc; virtio; com.redhat.spice.0
Controller USB 0:  USB 3
USB Redirector 1:  Type:  SpiceVMC
USB Redirector 2:  Type:  SpiceVMC
drivers installed from "virtio-win-0.1.173-5.iso" and QEMU Guest Agent "qemu-ga-x86_64.msi" installed
host/guest copy/paste from "spice-guest-tools-0.141.exe"
AnyDVD HD v8.4.2.0
IsoBuster Pro v4.5

I’m not sure why you are getting that error, but you’d barely want to use -usbdevice anyway, since it can only attach a device in «full-speed» mode (12M), even if it is a «high-speed» (480M) device on the host side:

enter image description here

It may not even work at all if you are attaching a «superspeed» (5000M) device (xHCI enabled on the host side):

enter image description here

So instead, you would want the more modern and generic -device usb-host approach, with an emulated host controller of your choice (e.g. -device nec-usb-xhci):

enter image description here

It should also work for «high-speed» (480M) devices:

enter image description here

as well as «full-speed» (12M) devices:

enter image description here

Possbile choices of emulated host controller are:

[tom@localhost ~]$ qemu-system-x86_64 -device help |& grep usb.*hci
name "ich9-usb-ehci1", bus PCI
name "ich9-usb-ehci2", bus PCI
name "ich9-usb-uhci1", bus PCI
name "ich9-usb-uhci2", bus PCI
name "ich9-usb-uhci3", bus PCI
name "ich9-usb-uhci4", bus PCI
name "ich9-usb-uhci5", bus PCI
name "ich9-usb-uhci6", bus PCI
name "nec-usb-xhci", bus PCI
name "piix3-usb-uhci", bus PCI
name "piix4-usb-uhci", bus PCI
name "usb-ehci", bus PCI
name "vt82c686b-usb-uhci", bus PCI

[tom@localhost ~]$ qemu-system-x86_64 -device help |& grep ohci
name "pci-ohci", bus PCI, desc "Apple USB Controller"
name "sysbus-ohci", bus System, desc "OHCI USB Controller"

nec-usb-xhci should work best and fine in most cases.

Btw, there are also ways other than vendorid+productid to specify which device you want to attach with -device usb-host. For example, hostbus+hostaddr:

enter image description here

Or, hostbus+hostport:

enter image description here

Which are handy when there are multiple devices of the same model in the system.

Ref.: http://git.qemu.org/?p=qemu.git;a=blob_plain;f=docs/usb2.txt;hb=HEAD

Доброго времени суток. Просьба помочь найти решение проблемы с подключением ключевого носителе к гостевой машине. Последовательность действий следующая:

# lsusb
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0557:2221 ATEN International Co., Ltd Winbond Hermon
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 0529:0620 Aladdin Knowledge Systems Token JC
Создал файл usb.xml со следующим содержимым:

<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
<address bus='2' device='3'/>
</source>
</hostdev>
И подключаю устройство к виртуальной машине

virsh attach-device win7 usb.xml
ошибка: Не удалось подключить устройство из usb.xml
ошибка: internal error: unable to execute QEMU command 'device_add': 'usb-host' is not a valid device model name
Получаю

usb-host’ is not a valid device model name

Подключение устройства с помощью virt-manager приводит к такой же ошибке

С чем может быть связана проблема? Двухдневные поиски и чтение документации к просветлению не привели. Заранее спасибо


Записан


Прокидывать через Spice не вариант? Нам на ВМ надо добавить устройство Spice.


Записан

Андрей Черепанов (cas@)


Spice к сожалению не подходит. Пробросить устройство нужно именно от хоста, предполагается постоянное подключение ключевого носителя к машине.


Записан


Bus 002 Device 003: ID 0529:0620 Aladdin Knowledge Systems Token JC[/code]

А если так?

<hostdev mode='subsystem' type='usb' managed='no'>
    <source>
        <vendor id='0x0529'/>
        <product id='0x0620'/>
    </source>
</hostdev>
Добавлять на отключенной машине. Читать документацию.


Записан

To moan or to solve — that is the question!


Добавлять на отключенной машине.

Действительно добавлял при включенной машине. Попытался добавить

<hostdev mode='subsystem' type='usb' managed='no'>
    <source>
        <vendor id='0x0529'/>
        <product id='0x0620'/>
    </source>
</hostdev>
сразу в конфиг виртуальной машины в раздел device через virsh edit, при запуске машины получил ошибку

virsh start win7
ошибка: Не удалось запустить домен win7
ошибка: internal error: qemu unexpectedly closed the monitor: warning: host doesn't support requested feature: CPUID.01H:EDX.ds [bit 21]
warning: host doesn't support requested feature: CPUID.01H:EDX.acpi [bit 22]
warning: host doesn't support requested feature: CPUID.01H:EDX.ht [bit 28]
warning: host doesn't support requested feature: CPUID.01H:EDX.tm [bit 29]
warning: host doesn't support requested feature: CPUID.01H:EDX.pbe [bit 31]
warning: host doesn't support requested feature: CPUID.01H:ECX.dtes64 [bit 2]
warning: host doesn't support requested feature: CPUID.01H:ECX.monitor [bit 3]
warning: host doesn't support requested feature: CPUID.01H:ECX.ds_cpl [bit 4]
warning: host doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]
warning: host doesn't support requested feature: CPUID.01H:ECX.smx [bit 6]
warning: host doesn't support requested feature: CPUID.01H:ECX.est [bit 7]
warning: host doesn't support requested feature: CPUID.01H:ECX.tm2 [bit 8]
warning: host doesn't support requested feature: CPUID.01H:ECX.xtpr [bi


Записан


Это не связанные вещи. Нужно в конфиге менять <cpu mode=’host-model’> на <cpu mode=’host-passthrough’>.


Записан

To moan or to solve — that is the question!


Поменял на cpu-mode=host-passthrough, но не полегчало. Вот конфиг

<domain type='kvm'>
  <name>win7</name>
  <uuid>bfbf1740-e609-4f22-9abd-f8552180b002</uuid>
  <memory unit='KiB'>2097152</memory>
  <currentMemory unit='KiB'>2097152</currentMemory>
  <vcpu placement='static'>2</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.5'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <cpu mode='host-passthrough'/>
  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/win7.img'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>
    <disk type='file' device='floppy'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/boot/virtio-win-0.1.141_amd64.vfd'/>
      <target dev='fda' bus='fdc'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/boot/Win7.iso'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='fdc' index='0'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:cd:bd:c9'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <input type='tablet' bus='usb'>
      <address type='usb' bus='0' port='1'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0' passwd='******'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='cirrus' vram='16384' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <hostdev mode='subsystem' type='usb' managed='no'>
      <source>
        <vendor id='0x0529'/>
        <product id='0x0620'/>
      </source>
      <address type='usb' bus='0' port='2'/>
    </hostdev>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </memballoon>
  </devices>
</domain>
При старте снова ошибка

# virsh start win7
ошибка: Не удалось запустить домен win7
ошибка: internal error: qemu unexpectedly closed the monitor: 2019-07-12T17:10:15.678298Z qemu-system-x86_64: -device usb-host,hostbus=2,hostaddr=3,id=hostdev0,bus=usb.0,port=2: 'usb-host' is not a valid device model name


Записан


apt-get update && apt-get dist-upgrade давно делался? Какое-то явное несоответствие virsh и qemu.


Записан

To moan or to solve — that is the question!


apt-get update && apt-get dist-upgrade давно делался? Какое-то явное несоответствие virsh и qemu.

Все последние обновления установлены.
Причина возникающей ошибки была найдена на англоязычных ресурсах — пакет qemu собран без поддержки libusb. Скачал src.rpm, в spec файле действительно disabled libusb. После сборки пакета с удовлетворенными зависимостями и обновления пакета qemu-system свежесобранным, виртуальная машина запустилась без ошибок с проброшенным usb устройством. Вопрос решен.
klark973 спасибо за помощь
 


Записан


Багу повешайте, пожалуйста.


Записан

Андрей Черепанов (cas@)


Багу повешайте, пожалуйста.

А это баг или все же незадокументированная особенность сборки qemu? В репозиториях c7 qemu 2.5.1.1 и libusb 1.0.7. При сборке qemu 2.5.1.1 с включенной поддержкой libusb потребовался libusb-devel 1.0.9 и выше, пришлось позаимствовать libusb и libusb-devel из c8.


Записан


I’m not sure why you are getting that error, but you’d barely want to use -usbdevice anyway, since it can only attach a device in «full-speed» mode (12M), even if it is a «high-speed» (480M) device on the host side:

enter image description here

It may not even work at all if you are attaching a «superspeed» (5000M) device (xHCI enabled on the host side):

enter image description here

So instead, you would want the more modern and generic -device usb-host approach, with an emulated host controller of your choice (e.g. -device nec-usb-xhci):

enter image description here

It should also work for «high-speed» (480M) devices:

enter image description here

as well as «full-speed» (12M) devices:

enter image description here

Possbile choices of emulated host controller are:

[tom@localhost ~]$ qemu-system-x86_64 -device help |& grep usb.*hci
name "ich9-usb-ehci1", bus PCI
name "ich9-usb-ehci2", bus PCI
name "ich9-usb-uhci1", bus PCI
name "ich9-usb-uhci2", bus PCI
name "ich9-usb-uhci3", bus PCI
name "ich9-usb-uhci4", bus PCI
name "ich9-usb-uhci5", bus PCI
name "ich9-usb-uhci6", bus PCI
name "nec-usb-xhci", bus PCI
name "piix3-usb-uhci", bus PCI
name "piix4-usb-uhci", bus PCI
name "usb-ehci", bus PCI
name "vt82c686b-usb-uhci", bus PCI

[tom@localhost ~]$ qemu-system-x86_64 -device help |& grep ohci
name "pci-ohci", bus PCI, desc "Apple USB Controller"
name "sysbus-ohci", bus System, desc "OHCI USB Controller"

nec-usb-xhci should work best and fine in most cases.

Btw, there are also ways other than vendorid+productid to specify which device you want to attach with -device usb-host. For example, hostbus+hostaddr:

enter image description here

Or, hostbus+hostport:

enter image description here

Which are handy when there are multiple devices of the same model in the system.

Ref.: http://git.qemu.org/?p=qemu.git;a=blob_plain;f=docs/usb2.txt;hb=HEAD

To correct the issue, shut down the Windows 10 guest. From Virtual Machine Manager (aka virt-manager), open the properties of the Windows 10 guest. Click the tab «Controller USB 0», change the Model from the default of «USB 2» to «USB 3», and click button «Apply». Start the Windows 10 guest, perform the USB Redirect, read a disc, and verify that the USB resets and disconnects have ceased.

Additionally, after changing «Controller USB 0» to Model «USB 3», read performance increased from 4 MB/s to 13 MB/s.

The host’s USB controller is USB 2.0. The USB to SATA bridge is USB 2.0. From what I’ve read, USB Redirect is limited to USB 2.0. I find it baffling that this minor configuration change has corrected the issue, but after reading discs for weeks without issue, it certainly is fixed.

I spent several weeks troubleshooting this, and I hope it helps others.

———- Current Working Configuration ———-

Host:

Linux Mint 19.1 x64 Cinnamon (Tessa) running QEMU/KVM and Virtual Machine Manager
Supermicro X9SCM system board (C204 USB Enhanced Host Controller (EHCI))
StarTech USB2SATAIDE USB 2.0 to IDE or SATA Adapter Cable (JMicron JM20337 - USB 152d:2338)
Asus BW-16D1HT, LG WH16NS40, Pioneer BDR-209D, and Pioneer BDR-209M

Guest:

Windows 10 x64 version 1909 (no additional Windows updates)
Architecture options:  x86_64
OS type:  Windows
Version:  Microsoft Windows 10
Memory (RAM) MiB:  8192
CPUs:  2
Network selection:  Bridge br0: Host device enoX
NIC:  Device model:  virtio
Chipset:  Q35
Enable boot menu:  <checked>
Hard drives:  Advanced options:  Disk bus:  VirtIO
Optical drives:  Advanced options:  Disk bus:  SATA
Display Spice:  Address:  Localhost only
Channel spice:  spicevmc; virtio; com.redhat.spice.0
Controller USB 0:  USB 3
USB Redirector 1:  Type:  SpiceVMC
USB Redirector 2:  Type:  SpiceVMC
drivers installed from "virtio-win-0.1.173-5.iso" and QEMU Guest Agent "qemu-ga-x86_64.msi" installed
host/guest copy/paste from "spice-guest-tools-0.141.exe"
AnyDVD HD v8.4.2.0
IsoBuster Pro v4.5
  • Index
  • » Newbie Corner
  • » [SOLVED] Unable to Pass USB Device (flash drive) to QEMU Guest

Pages: 1

#1 2016-03-07 11:55:57

tony5429
Member
Registered: 2006-03-28
Posts: 1,000

[SOLVED] Unable to Pass USB Device (flash drive) to QEMU Guest

I’m having trouble passing a USB device (a flash drive) to a Windows 7 QEMU guest…

[tony@laptop ~]$ lsusb | grep Kingston
Bus 003 Device 002: ID 0930:6545 Toshiba Corp. Kingston DataTraveler 102/2.0 / HEMA Flash Drive 2 GB / PNY Attache 4GB Stick
[tony@laptop ~]$ qemu-system-x86_64 -enable-kvm -m 2G -drive file=win7.img,format=raw -device usb-host,hostbus=3,hostaddr=2
qemu-system-x86_64: -device usb-host,hostbus=3,hostaddr=2: No 'usb-bus' bus found for device 'usb-host'

Any ideas?

Last edited by tony5429 (2016-03-08 12:04:23)

#2 2016-03-08 01:58:47

tony5429
Member
Registered: 2006-03-28
Posts: 1,000

Re: [SOLVED] Unable to Pass USB Device (flash drive) to QEMU Guest

Whoops — I realized I had forgotten the «-usb» option. Now, with the command below, Windows loads and attempts to use the flash drive, but returns error «code 10» — «this device cannot start.»

qemu-system-x86_64 -enable-kvm -m 2G -drive file=win7.img,format=raw -usb -device usb-host,hostbus=3,hostaddr=2

Here are screenshots…

http://i.imgur.com/bhOLrLA.png
http://i.imgur.com/85iDObm.png

#3 2016-03-08 12:08:17

tony5429
Member
Registered: 2006-03-28
Posts: 1,000

Re: [SOLVED] Unable to Pass USB Device (flash drive) to QEMU Guest

Looks like I needed to use «-device usb-ehci…» rather than «-usb». It works perfectly now big_smile

qemu-system-x86_64 -enable-kvm -m 2G -drive file=win7.img,format=raw -device usb-ehci,id=usb,bus=pci.0,addr=0x4 -device usb-host,hostbus=3,hostaddr=2

Last edited by tony5429 (2016-03-08 14:14:15)

Voron-Orel

#
5 лет, 9 месяцев назад

Темы:

3

Сообщения:

6

Участник с: 24 марта 2017

Имел ли кто здесь дело с Qemu + virt-manager? суть в том, что не могу пробросить usb устройство, при запуска выскакивает ошибка: » Ошибка запуска : конфигурация не поддерживается: host doesn’t support VFIO PCI interface»

indeviral

#
5 лет, 9 месяцев назад

Участник с: 10 августа 2013

тут.

Ошибки в тексте-неповторимый стиль автора©

Я не уверен, почему вы получаете эту ошибку, но вы все равно вряд ли захотите использовать -usbdevice так как он может подключать устройство только в «полноскоростном» режиме (12M), даже если это «высокая скорость». скорость «(480M) на стороне хоста:

Это может даже не работать вообще, если вы подключаете «сверхскоростное» (5000M) устройство (xHCI включен на стороне хоста):

Поэтому вместо этого вам нужен более современный и универсальный подход -device usb-host с эмулируемым хост-контроллером по вашему выбору (например, -device nec-usb-xhci):

Он также должен работать для «высокоскоростных» (480М) устройств:

а также «полноскоростные» (12М) устройства:

Возможные варианты эмулируемого хост-контроллера:

[tom@localhost ~]$ qemu-system-x86_64 -device help |& grep usb.*hci
name "ich9-usb-ehci1", bus PCI
name "ich9-usb-ehci2", bus PCI
name "ich9-usb-uhci1", bus PCI
name "ich9-usb-uhci2", bus PCI
name "ich9-usb-uhci3", bus PCI
name "ich9-usb-uhci4", bus PCI
name "ich9-usb-uhci5", bus PCI
name "ich9-usb-uhci6", bus PCI
name "nec-usb-xhci", bus PCI
name "piix3-usb-uhci", bus PCI
name "piix4-usb-uhci", bus PCI
name "usb-ehci", bus PCI
name "vt82c686b-usb-uhci", bus PCI

[tom@localhost ~]$ qemu-system-x86_64 -device help |& grep ohci
name "pci-ohci", bus PCI, desc "Apple USB Controller"
name "sysbus-ohci", bus System, desc "OHCI USB Controller"

nec-usb-xhci должен работать лучше и лучше в большинстве случаев.

Между прочим, кроме vendorid+productid , есть и другие способы указать, какое устройство вы хотите подключить с помощью -device usb-host . Например, hostbus+hostaddr:

Или, hostbus+hostport:

Это удобно, когда в системе несколько устройств одной модели.

Ссылка: http://git.qemu.org/?p=qemu.git;a=blob_plain;f=docs/usb2.txt;hb=HEAD

Понравилась статья? Поделить с друзьями:
  • Ошибка перемонтирования total commander android
  • Ошибка повторная транзакция
  • Ошибка переназначенные сектора как исправить
  • Ошибка повторная регистрация первичного документа что значит
  • Ошибка передачи 101 kyocera