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


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 ключ в гостя поставил, но софтина его всё равно не видит. ЧЯДНТ?

openSUSE Forums

Loading

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

# 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

Manjaro Linux Forum

Loading

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

Понравилась статья? Поделить с друзьями:
  • Qbittorrent ошибка при установке
  • Qbittorrent ошибка при загрузке торрента
  • Qbittorrent ошибка отсутствуют файлы
  • Qbittorrent выдает ошибку при скачивании
  • Python ошибка при установке 0x80072f7d