Автор Тема: Ошибка qemu при подключении usb-устройства к гостевой машине  (Прочитано 11640 раз)

Оффлайн werk.s

  • Начинающий
  • *
  • Сообщений: 6
Доброго времени суток. Просьба помочь найти решение проблемы с подключением ключевого носителе к гостевой машине. Последовательность действий следующая:
# 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 приводит к такой же ошибке

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

Оффлайн Skull

  • Глобальный модератор
  • *****
  • Сообщений: 19 908
    • Домашняя страница
    • Email
Прокидывать через Spice не вариант? Нам на ВМ надо добавить устройство Spice.
Андрей Черепанов (cas@)

Оффлайн werk.s

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

Оффлайн klark973

  • Завсегдатай
  • *
  • Сообщений: 662
  • Неспящий саппорт
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!

Оффлайн werk.s

  • Начинающий
  • *
  • Сообщений: 6
Цитировать
Добавлять на отключенной машине.
Действительно добавлял при включенной машине. Попытался добавить
<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

Оффлайн klark973

  • Завсегдатай
  • *
  • Сообщений: 662
  • Неспящий саппорт
Это не связанные вещи. Нужно в конфиге менять <cpu mode='host-model'> на <cpu mode='host-passthrough'>.
To moan or to solve -- that is the question!

Оффлайн werk.s

  • Начинающий
  • *
  • Сообщений: 6
Поменял на 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

Оффлайн klark973

  • Завсегдатай
  • *
  • Сообщений: 662
  • Неспящий саппорт
apt-get update && apt-get dist-upgrade давно делался? Какое-то явное несоответствие virsh и qemu.
To moan or to solve -- that is the question!

Оффлайн werk.s

  • Начинающий
  • *
  • Сообщений: 6
Цитировать
apt-get update && apt-get dist-upgrade давно делался? Какое-то явное несоответствие virsh и qemu.
Все последние обновления установлены.
Причина возникающей ошибки была найдена на англоязычных ресурсах - пакет qemu собран без поддержки libusb. Скачал src.rpm, в spec файле действительно disabled libusb. После сборки пакета с удовлетворенными зависимостями и обновления пакета qemu-system свежесобранным, виртуальная машина запустилась без ошибок с проброшенным usb устройством. Вопрос решен.
klark973 спасибо за помощь
 

Оффлайн Skull

  • Глобальный модератор
  • *****
  • Сообщений: 19 908
    • Домашняя страница
    • Email
Багу повешайте, пожалуйста.
Андрей Черепанов (cas@)

Оффлайн werk.s

  • Начинающий
  • *
  • Сообщений: 6
Цитировать
Багу повешайте, пожалуйста.
А это баг или все же незадокументированная особенность сборки 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.