Chinaunix首页 | 论坛 | 博客
  • 博客访问: 118025
  • 博文数量: 27
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 85
  • 用 户 组: 普通用户
  • 注册时间: 2014-08-30 13:49
文章分类
文章存档

2017年(3)

2016年(1)

2015年(3)

2014年(20)

我的朋友

分类: 虚拟化

2017-10-13 16:26:34

上篇说到USB2.0的重定向,但是还是一直想探索一下,如何进行USB3.0的重定向。搜索了一些资料之后,发现一个契机,那就是OHCI、UHCI都是USB1.1的接口标准,而EHCI是对应USB2.0的接口标准,最新的xHCI是USB3.0的接口标准。经过查看命令qemu-system-x86_64和virt-install的相关信息,锁定了选项nec-usb-xhci和qemu-xhci。
查看命令过程为:
qemu-system-x86_64 --help

看到一段如下:
-device driver[,prop[=value][,...]]
                add device (based on driver)
                prop=value,... sets driver properties
                use '-device help' to print all possible drivers
                use '-device driver,help' to print all possible properties
继续查看:
qemu-system-x86_64 -device help
看到一段如下:
USB devices:
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 "pci-ohci", bus PCI, desc "Apple USB Controller"
name "piix3-usb-uhci", bus PCI
name "piix4-usb-uhci", bus PCI
name "qemu-xhci", bus PCI
name "sysbus-ohci", bus System, desc "OHCI USB Controller"
name "usb-ehci", bus PCI
name "vt82c686b-usb-uhci", bus PCI

锁定了两个关键的属性: "nec-usb-xhci"和"qemu-xhci",同时看到了我们比较熟悉的"ich9-usb-ehci1"和"ich9-usb-uhci1"、"ich9-usb-uhci2"、"ich9-usb-uhci3"。
在spice的Reference Manual的里面看到配置USB重定向的命令:
-device ich9-usb-ehci1,id=usb -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,multifunction=on -device ich9-usb-uhci2,masterbus=usb.0,firstport=2 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4 -chardev spicevmc,name=usbredir,id=usbredirchardev1 -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1 -chardev spicevmc,name=usbredir,id=usbredirchardev2 -device usb-redir,chardev=usbredirchardev2,id=usbredirdev2 -chardev spicevmc,name=usbredir,id=usbredirchardev3 -device usb-redir,chardev=usbredirchardev3,id=usbredirdev3
那么对于"nec-usb-xhci"该怎么配置呢?
首先通过命令查看"nec-usb-xhci"有哪些可以配置的属性:qemu-system-x86_64 -device nec-usb-xhci,help
nec-usb-xhci.rombar=uint32
nec-usb-xhci.intrs=uint32
nec-usb-xhci.x-pcie-lnksta-dllla=bool (on/off)
nec-usb-xhci.msix=OnOffAuto (on/off/auto)
nec-usb-xhci.multifunction=bool (on/off)
nec-usb-xhci.msi=OnOffAuto (on/off/auto)
nec-usb-xhci.superspeed-ports-first=bool (on/off)
nec-usb-xhci.streams=bool (on/off)
nec-usb-xhci.romfile=str
nec-usb-xhci.force-pcie-endcap=bool (on/off)
nec-usb-xhci.command_serr_enable=bool (on/off)
nec-usb-xhci.x-pcie-extcap-init=bool (on/off)
nec-usb-xhci.addr=int32 (Slot and optional function number, example: 06.0 or 06)
nec-usb-xhci.p3=uint32
nec-usb-xhci.p2=uint32
nec-usb-xhci.slots=uint32

仿照着写了一下,并不行,后来在一个blog里面发现了用法(http://www.cnblogs.com/fangying7/p/5679033.html)
-device nec-usb-xhci,id=usb2,bus=pci.0,addr=0x8
照搬进去发现可以!!!
以下是具体命令:
qemu-system-x86_64 -m 2048 -smp cpus=2 -enable-kvm /home/annie/spice/test/u2.qcow2 -spice port=5900,disable-ticketing -device ich9-usb-ehci1,id=usb -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,multifunction=on -device ich9-usb-uhci2,masterbus=usb.0,firstport=2 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4  -device nec-usb-xhci,id=usb2,bus=pci.0,addr=0x8 -chardev spicevmc,name=usbredir,id=usbredirchardev1 -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1 -chardev spicevmc,name=usbredir,id=usbredirchardev2 -device usb-redir,chardev=usbredirchardev2,id=usbredirdev2 -chardev spicevmc,name=usbredir,id=usbredirchardev3 -device usb-redir,chardev=usbredirchardev3,id=usbredirdev3
virt-install命令与qemu有一点点不同,经过查看:man virt-install
发现了:
DEVICE OPTIONS
       --controller OPTIONS
           Attach a controller device to the guest. TYPE is one of: ide, fdc, scsi, sata, virtio-serial, or usb.

           Controller also supports the special values usb2 and usb3 to specify which version of the USB controller should be used (version 2 or 3).

           model
               Controller model.  These may vary according to the hypervisor and its version.  Most commonly used models are e.g. auto, virtio-scsi for the scsi controller, ehci or none for the usb
               controller.  For full list and further details on controllers/models, see "".
           address
               Controller address, current PCI of form 'bus:domain:slot.function'.
           index
               A decimal integer describing in which order the bus controller is encountered, and to reference the controller bus.
           master
               Applicable to USB companion controllers, to define the master bus startport. 
           Examples:
                      --controller usb,model=ich9-ehci1,address=0:0:4.0,index=0
                          Adds a ICH9 EHCI1 USB controller on PCI address 0:0:4.0
                      --controller usb,model=ich9-uhci2,address=0:0:4.7,index=0,master=2
                          Adds a ICH9 UHCI2 USB companion controller for the previous master controller, ports start from port number 2.

模仿着写出了,以下是具体命令:
virt-install --virt-type kvm --name u3 --ram 2048 --cdrom=/home/annie/spice/test/ubuntu-14.04.3-desktop-amd64.iso --disk path=/home/annie/spice/test/u3.qcow2,size=20,format=qcow2 --network=default --graphics spice,listen=0.0.0.0 --noautoconsole --os-type=linux --os-variant=ubuntu14.04 --accelerate --controller usb,model=ich9-ehci1,address=0:0:4.0,index=0 --controller usb,model=ich9-uhci1,address=0:0:4.4,index=0,master=0 --controller usb,model=ich9-uhci2,address=0:0:4.5,index=0,master=2 --controller usb,model=ich9-uhci3,address=0:0:4.6,index=0,master=4 --controller usb,model=nec-xhci,address=0:0:4.7,index=1


启动之后,在客户端进行连接,(注意我上篇说到的连接时,需要使用超级权限,以及这个USB3.0的支持是在前面做好的支持USB重定向上做的)
总之,qemu是支持usb3.0的重定向的。(over)



阅读(9560) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~