zoukankan      html  css  js  c++  java
  • spice remote-viewer 连接会话时自动重定向usb设备(记录)

    方法

    1,直接使用以下命令即可自动重定向usb设备(除HID设备)
    remote-viewer --spice-usbredir-redirect-on-connect="0x03,-1,-1,-1,0|-1,-1,-1,-1,1" console.vv

    2,如果使用以下命令,则仅在插拔usb接口才会重定向usb设备:
    remote-viewer --spice-usbredir-auto-redirect-filter="0x03,-1,-1,-1,0|-1,-1,-1,-1,1"



    解释:

    0x03,-1,-1,-1,0 代表过滤此HID(human interface device)设备,即鼠标、键盘、游戏手柄等。
    -1,-1,-1,-1,1 代表允许所有设备连接。

    | 多个规则组合,排前面的优先匹配规则(个人理解,不知道有没有错)

    规则格式:
    <class>,<vendor>,<product>,<version>,<allow>
    <class>,<vendor>,<product>,<version>使用 -1 代表任何值




    spice usb拓展

    以下内容全部来源于:https://www.spice-space.org/usbredir.html

    Using libvirt

    The following libvirt XML will configure a guest with USB2 support and the ability to redirect 3 devices simultaneously:

    <controller type='usb' index='0' model='ich9-ehci1'/>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
    </controller>
    <redirdev bus='usb' type='spicevmc'/>
    <redirdev bus='usb' type='spicevmc'/>
    <redirdev bus='usb' type='spicevmc'/>
    

    For USB3 support, the configuration can be simplified to:

    <controller type='usb' index='0' model='nec-xhci'/>
    <redirdev bus='usb' type='spicevmc'/>
    <redirdev bus='usb' type='spicevmc'/>
    <redirdev bus='usb' type='spicevmc'/>
    

    Using QEMU

    The following qemu options will configure a guest with USB2 support and the ability to redirect 3 devices simultaneously

    -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
    

    For USB3 support, the configuration can be simplified to:

    -device nec-usb-xhci,id=usb 
    -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

    Host Filtering

    Set a string specifying a filter to determine which USB devices are allowed/blocked to redirect USB traffic to the guest.

    Using QEMU

    -device usb-redir,filter='0x03:-1:-1:-1:0|-1:-1:-1:-1:1',chardev=usbredirchardev1,id=usbredirdev1
    

    Note that in a QEMU command, the filter string should use a ':' character as a separator within the rule.

    Using libvirt

    ...
    <devices>
     ...
      <redirfilter>
        <usbdev class='0x08' vendor='0x1234' product='0xbeef' version='2.56' allow='yes'/>
        <usbdev allow='no'/>
      </redirfilter>
    </devices>
    ...
     


  • 相关阅读:
    远程连接ubuntu的MongoDB遇到的坑
    使用google的pprof工具以及在gin中集成pprof
    Erlang垃圾回收机制的二三事
    利用Redis cache优化app查询速度实践
    是财富还是陷阱?如何处理他人的代码
    【译】如何成为一个优秀的开发者
    [译] 你应该升级 MQTT3.1.1 的6个理由
    基于 ANSIBLE 自动化运维实践
    poolboy的坑
    Erlang 内存泄漏分析
  • 原文地址:https://www.cnblogs.com/sealin/p/13477266.html
Copyright © 2011-2022 走看看