博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
KVM通过qemu实现USB重定向
阅读量:5173 次
发布时间:2019-06-13

本文共 2064 字,大约阅读时间需要 6 分钟。

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 Hub2 Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub3 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub4 Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub5 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.

-usbThis option adds pseudo USB mouse device to a guest OS.-usbdevice tabletWhen 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:yyyyA 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.

转载于:https://www.cnblogs.com/fuleying/p/3622908.html

你可能感兴趣的文章
poj题目分类
查看>>
idea 配置mybatis Generator 不显示的解决方案 和 配置MBG
查看>>
英语生疏了,每日至少一句吧
查看>>
创建打不开文件夹
查看>>
12 for循环
查看>>
redis(hash篇)
查看>>
Scala实战高手****第12课:Scala函数式编程进阶(匿名函数、高阶函数、函数类型推断、Currying)与Spark源码鉴赏...
查看>>
Hibernate一对多关联
查看>>
python 把函数作为参数 ---高阶函数
查看>>
jQuery + ashx 实现图片按比例预览、异步上传及显示
查看>>
android 代码中使用textAppearance
查看>>
【iOS】UITableViewDelegate 方法没有调用
查看>>
解决code::blocks 17.12不能debug的方法
查看>>
bzoj2961&&bzoj4140 共点圆
查看>>
96:经典实例,判断那一条是闰年:
查看>>
upsource初探
查看>>
让SVN自动更新代码注释中的版本号
查看>>
java中base64
查看>>
常用的mysql操作命令
查看>>
Unity3D的菜单及编辑器扩展
查看>>