KVM通过qemu实现USB重定向
KVM是通過qemu來支持USB設備的,可以在啟動的時候就指定需要連接的USB設備,也可以系統啟動后動態的添加刪除.通過qemu的help可知,使用qemu的usb_add host:xxx:xxx來添加usb設備,那么如何知道對應的host:xxx:xxx呢,有2種方法:
1)在host主機ubuntu中執行lsusb得到這些信息
比如在我機器上usb的信息如下:
1 Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub 2 Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub 3 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub 4 Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub 5 Bus 001 Device 003: ID 0461:4d80 Primax Electronics, Ltd 6 Bus 001 Device 006: ID 0951:1665 Kingston Technology 7 Bus 001 Device 004: ID 058f:b002 Alcor Micro Corp. 8 Bus 002 Device 003: ID 0489:e010 Foxconn / Hon Hai
0951:1665就是我們需要的了。
2)進入服務端虛擬機后,通過ctrl+alt+2調出qemu控制臺,輸入info usb來列出相關已經加載的USB信息。如果顯示:
(qemu): usb support not enabled
If you see 'USB support not enabled', confirm to use option -usb at startup.
-usb This option adds pseudo USB mouse device to a guest OS. -usbdevice tablet When a guest OS has a driver for USB tablet, a mouse doesn't need to click in the guest OS windows to capture. -usbdevice host:xxxx:yyyy A USB device xxxx:yyyy on a host OS can be used from a guest OS.
3.)Press Ctrl-Alt-2 and check USB device ID of host OS in QEMU monotor.
Then connect USB device (0951:1665) to the guest OS. 0951 is a vender ID and 1665 is a product ID.
(qemu) usb_add host:0951:1665
Finally, PnP manager of WindowsXP guest recognizes USB mouse and a device driver is installed.
4.)When you want to remove the USB device, remove USB device in guest OS. For example, right click on task bar and select remove the device. The mouse doesn't need to do this. Then check a number of USB bus and address in QEMU monitor.
Use usb_del in QEMU monitor. 0.3 means that the bus number is 0 and the address of USB device is 3.
(qemu) usb_del 0.3
Then remove USB device in host OS. For example, right click on the task bar and remove the USB device as in guest OS. The mouse doesn't need to do this.
After that, unplug the USB device on your machine.
總結
以上是生活随笔為你收集整理的KVM通过qemu实现USB重定向的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 额头祛痘(额头长痘什么原因你知道吗?)
- 下一篇: 购买陶瓷浴室柜的小技巧