KVM - 使用 virsh/XML 将 USB 传递给客户机失败,但可以通过 virt-manager 进行操作

KVM - 使用 virsh/XML 将 USB 传递给客户机失败,但可以通过 virt-manager 进行操作

在 debian 8.8 jessie 上运行 kvm。我无法将 usb 从主机重定向到客户机(尝试使用 debian jessie 和 windows 2012 作为客户机,问题相同)

libvirt 1.2.9-9+deb8u4

如果我从 virt-manager GUI 重定向 USB 驱动器,则客户机将看到 USB。

如果我尝试使用“virsh connect-device guest-dom”hostdev.xml 进行重定向。客户机可以看到该设备(lsusb 和 windows dev manager),但未检测到块设备(lsblk 看不到该设备)

# cat hostdev.xml
<hostdev mode='subsystem' type='usb'>
  <source>
    <vendor id='0x1976'/>
    <product id='0x6025'/>
  </source>
</hostdev>

以下是客户端运行时的日志(vir-manager 方法)

May 28 17:18:21 deb2 kernel: [  949.120071] usb 4-1: new full-speed USB device number 17 using uhci_hcd
May 28 17:18:21 deb2 kernel: [  949.312416] usb 4-1: New USB device found, idVendor=1976, idProduct=6025
May 28 17:18:21 deb2 kernel: [  949.312421] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
May 28 17:18:21 deb2 kernel: [  949.312423] usb 4-1: Product: USB
May 28 17:18:21 deb2 kernel: [  949.312426] usb 4-1: Manufacturer: ChipsBnk
May 28 17:18:21 deb2 kernel: [  949.312428] usb 4-1: SerialNumber: 088615381351
May 28 17:18:21 deb2 kernel: [  949.315619] usb-storage 4-1:1.0: USB Mass Storage device detected
May 28 17:18:21 deb2 kernel: [  949.315761] scsi16 : usb-storage 4-1:1.0
May 28 17:18:21 deb2 mtp-probe: checking bus 4, device 17: "/sys/devices/pci0000:00/0000:00:05.2/usb4/4-1"
May 28 17:18:21 deb2 mtp-probe: bus: 4, device: 17 was not an MTP device
May 28 17:18:22 deb2 kernel: [  950.320265] scsi 16:0:0:0: Direct-Access     ChipsBnk USB              4.00 PQ: 0 ANSI: 2
May 28 17:18:22 deb2 kernel: [  950.321321] sd 16:0:0:0: Attached scsi generic sg1 type 0
May 28 17:18:22 deb2 kernel: [  950.331807] sd 16:0:0:0: [sda] 258047 512-byte logical blocks: (132 MB/125 MiB)
May 28 17:18:22 deb2 kernel: [  950.338099] sd 16:0:0:0: [sda] Write Protect is off
May 28 17:18:22 deb2 kernel: [  950.338112] sd 16:0:0:0: [sda] Mode Sense: 00 00 00 00
May 28 17:18:22 deb2 kernel: [  950.344426] sd 16:0:0:0: [sda] Asking for cache data failed
May 28 17:18:22 deb2 kernel: [  950.344885] sd 16:0:0:0: [sda] Assuming drive cache: write through
May 28 17:18:22 deb2 kernel: [  950.429158]  sda: sda1
May 28 17:18:22 deb2 kernel: [  950.481252] sd 16:0:0:0: [sda] Attached SCSI removable disk

root@deb2:~# lsusb
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 0409:55aa NEC Corp. Hub
Bus 004 Device 017: ID 1976:6025 Chipsbrand Microelectronics (HK) Co., Ltd. Flash Drive 512 MB
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

root@deb2:~# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    1  126M  0 disk
└─sda1   8:1    1  126M  0 part
sr0     11:0    1 1024M  0 rom
vda    254:0    0   40G  0 disk
├─vda1 254:1    0 38.3G  0 part /
├─vda2 254:2    0    1K  0 part
└─vda5 254:5    0  1.7G  0 part [SWAP]

以下是客户端失败时的日志(virsh ... xml 方法)

May 28 17:21:01 deb2 kernel: [ 1109.816098] usb 4-2.5: new full-speed USB device number 18 using uhci_hcd
May 28 17:21:02 deb2 kernel: [ 1110.093544] usb 4-2.5: New USB device found, idVendor=1976, idProduct=6025
May 28 17:21:02 deb2 kernel: [ 1110.093548] usb 4-2.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
May 28 17:21:02 deb2 kernel: [ 1110.093551] usb 4-2.5: Product: USB
May 28 17:21:02 deb2 kernel: [ 1110.093553] usb 4-2.5: Manufacturer: ChipsBnk
May 28 17:21:02 deb2 kernel: [ 1110.093555] usb 4-2.5: SerialNumber: 088615381351
May 28 17:21:02 deb2 kernel: [ 1110.095995] usb-storage 4-2.5:1.0: USB Mass Storage device detected
May 28 17:21:02 deb2 mtp-probe: checking bus 4, device 18: "/sys/devices/pci0000:00/0000:00:05.2/usb4/4-2/4-2.5"
May 28 17:21:02 deb2 kernel: [ 1110.097109] scsi17 : usb-storage 4-2.5:1.0
May 28 17:21:02 deb2 mtp-probe: bus: 4, device: 18 was not an MTP device

^C
root@deb2:~# lsusb
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 018: ID 1976:6025 Chipsbrand Microelectronics (HK) Co., Ltd. Flash Drive 512 MB
Bus 004 Device 002: ID 0409:55aa NEC Corp. Hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
root@deb2:~#
root@deb2:~# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0     11:0    1 1024M  0 rom
vda    254:0    0   40G  0 disk
├─vda1 254:1    0 38.3G  0 part /
├─vda2 254:2    0    1K  0 part
└─vda5 254:5    0  1.7G  0 part [SWAP]

May 28 17:22:47 deb2 kernel: [ 1215.915327] usb 4-2.5: USB disconnect, device number 22

系统日志消息看起来与“mtp-probe”相同。但失败情况在 mtp-probe 处停止,而成功情况则在检测到 USB 棒阻塞设备后继续。

在 Windows 2012 下,操作系统在开发管理器的 USB 部分中看到新的“大容量存储...”条目,但在“磁盘管理”和 Windows 资源管理器中均未看到磁盘。

我怎样才能使“virsh attachment-device ..XML”工作?

我没有安装 apparmor。

答案1

virsh 附加设备- 居住客户机-dom hostdev.xml

相关内容