USB passthrough test reports in 7.5RC1


  • XCP-ng Team

    Can you create an issue asking for this detailed change to be made? We can create a test package with this change, so it won't impact other users 🙂




  • XCP-ng Team

    Thank you, perfect 🙂



  • OK, this is rather amusing. I've got USB passthrough working for my USB 1.0 device.

    [15:28 xcp-ng-bywirlgr log]# diff -u /opt/xensource/libexec/usb_scan.py.orig /opt/xensource/libexec/usb_scan.py
    --- /opt/xensource/libexec/usb_scan.py.orig     2019-11-04 10:03:02.000000000 +0000
    +++ /opt/xensource/libexec/usb_scan.py  2020-03-01 15:20:53.323512746 +0000
    @@ -590,7 +590,8 @@
     
         pusb["path"] = device.get_node()
         # strip the leading space of "version"
    -    pusb["version"] = device[UsbDevice._VERSION].strip()
    +    #pusb["version"] = device[UsbDevice._VERSION].strip()
    +    pusb["version"] = "1.00"
         pusb["vendor-id"] = device[UsbDevice._ID_VENDOR]
         pusb["product-id"] = device[UsbDevice._ID_PRODUCT]
         pusb["vendor-desc"] = device[UsbDevice._DESC_VENDOR]
    

    I do NOT recommend this AT ALL. It is a gross hack. Apparently the xenopsd relies on the version number returned by the device to dictate the USB bus type of the controller it attaches to. I have no idea in what universe that makes sense.

    The above only works for me as that is the only USB device attached to the HV. I guess I could make the code a little smarter by looking for a particular device ID and only over-riding the version then



  • A slightly less hacky work around for USB v1 passthrough based on the issue I created:

    --- /opt/xensource/libexec/usb_scan.py     2019-11-04 10:03:02.000000000 +0000
    +++ /tmp/usb_scan.py    2020-03-01 17:32:29.266317478 +0000
    @@ -152,10 +152,11 @@
         _CLASS = "bDeviceClass"
         _CONF_VALUE = "bConfigurationValue"
         _NUM_INTERFACES = "bNumInterfaces"
    +    _USB_SPEED = "speed"
     
         _PRODUCT_DESC = [_DESC_VENDOR, _DESC_PRODUCT]
         _PRODUCT_DETAILS = [_VERSION, _ID_VENDOR, _ID_PRODUCT, _BCD_DEVICE, _SERIAL,
    -                        _CLASS, _CONF_VALUE, _NUM_INTERFACES]
    +                        _CLASS, _CONF_VALUE, _NUM_INTERFACES, _USB_SPEED]
         _PROPS = _PRODUCT_DESC + _PRODUCT_DETAILS
         _PROPS_NONABLE = _PRODUCT_DESC + [_SERIAL]
     
    @@ -590,7 +591,10 @@
     
         pusb["path"] = device.get_node()
         # strip the leading space of "version"
    -    pusb["version"] = device[UsbDevice._VERSION].strip()
    +    if int(device[UsbDevice._USB_SPEED]) <= 12:
    +        pusb["version"] = "1.00"
    +    else:
    +        pusb["version"] = device[UsbDevice._VERSION].strip()
         pusb["vendor-id"] = device[UsbDevice._ID_VENDOR]
         pusb["product-id"] = device[UsbDevice._ID_PRODUCT]
         pusb["vendor-desc"] = device[UsbDevice._DESC_VENDOR]
    

    in theory any deice which is "low" or "full" speed (i.e. USB1) will have it's version number changed to 1.00 which forces xenopsd to use a USB1 bus. It may have side effects if the driver in the guest relies on the version number so caveat emptor.



  • Good Morning!
    I'm new to xcp-ng, we have two Hyper-V hosts but we needed to add a usb token to a vm, so we decided to migrate a host to xcp-ng for testing, but my host is not giving me the option passthrough usb, my server is a dell T110 II, I have already checked the bios settings and apparently everything is fine.
    I don't know what I could be doing wrong.
    I'm using version 8.1 of xcp-ng and xcp-ng center 20.04.
    I'm sorry if I posted the wrong call!

    XenCenterMain_Tp1dcckyVk.png


  • XCP-ng Team

    Hi. Does https://xcp-ng.org/docs/compute.html#usb-passthrough help in your situation?



  • @stormi
    Good Morning!
    When executing the command xe pusb-list I have no return.

    totermw_rhkrRFJh3F.png



  • @stormi Not at all sadly. The Device never passes though..



  • Let's give it another try to give my host its USB controller back and pass-through just the USB devices. In this case we're going for a virtual machine hosting common USB devices for home domotica.

    The devices we want to pass-through:

    • Future Technology Devices International, Ltd Bridge(I2C/SPI/UART/FIFO)
      Which apparently is technical speak for a RFXtrx433XL USB 433.92MHz Transceiver
    • Prolific Technology, Inc. PL2303 Serial Port
      Which apparently is technical speak for a ZiGate USB-TTL
    • Sigma Designs, Inc. Aeotec Z-Stick Gen5 (ZW090) - UZB

    I'm using XCP-ng Center 20.04.00 to help me out and XCP-NG 8.1 on the host.

    Let's start with a good old:

    [12:56 vmhost ~]# xe pusb-list host-uuid=*****
    uuid ( RO)            : 2ba8de5b-8fe1-0262-f741-35b4ed350ae0
                path ( RO): 1-2
           vendor-id ( RO): 067b
         vendor-desc ( RO): Prolific Technology, Inc.
          product-id ( RO): 2303
        product-desc ( RO): PL2303 Serial Port
              serial ( RO):
             version ( RO): 1.10
         description ( RO): Prolific Technology, Inc._PL2303 Serial Port
    
    
    uuid ( RO)            : 08b23122-e01b-9ab2-e72d-185648ae19d7
                path ( RO): 1-7
           vendor-id ( RO): 0403
         vendor-desc ( RO): Future Technology Devices International, Ltd
          product-id ( RO): 6015
        product-desc ( RO): Bridge(I2C/SPI/UART/FIFO)
              serial ( RO): *******
             version ( RO): 2.00
         description ( RO): Future Technology Devices International, Ltd_Bridge(I2C/SPI/UART/FIFO)_DO2VQGDG
    

    Ok, we have 2 devices already ready to be passthrough. Let's try to make the third one show up!
    Using the follow commands and some reading I could identify the DENY rules in "/etc/xensource/usb-policy.conf", which prevent my Aeotec Z-Stick from showing.

    [13:06 vmhost ~]# /opt/xensource/libexec/usb_scan.py -d
    [13:06 vmhost ~]# cat /var/log/user.log | less
    

    I've adjusted my "/etc/xensource/usb-policy.conf" to the following:

    # When you change this file, run 'xe pusb-scan' to confirm
    # the file can be parsed correctly.
    #
    # Syntax is an ordered list of case insensitive rules where # is line comment
    #  and each rule is (ALLOW | DENY) : ( match )*
    #  and each match is (class|subclass|prot|vid|pid|rel) = hex-number
    # Maximum hex value for class/subclass/prot is FF, and for vid/pid/rel is FFFF
    #
    # USB Hubs (class 09) are always denied, independently of the rules in this file
    DENY: vid=17e9 # All DisplayLink USB displays
    ALLOW:vid=0658 pid=0200 class=02 # Aeotec Z-Stick Gen5 (ZW090) - UZB
    DENY: class=02 # Communications and CDC-Control
    ALLOW:vid=056a pid=0315 class=03 # Wacom Intuos tablet
    ALLOW:vid=056a pid=0314 class=03 # Wacom Intuos tablet
    ALLOW:vid=056a pid=00fb class=03 # Wacom DTU tablet
    DENY: class=03 subclass=01 prot=01 # HID Boot keyboards
    DENY: class=03 subclass=01 prot=02 # HID Boot mice
    ALLOW:vid=0658 pid=0200 class=0a # Aeotec Z-Stick Gen5 (ZW090) - UZB
    DENY: class=0a # CDC-Data
    DENY: class=0b # Smartcard
    DENY: class=e0 # Wireless controller
    DENY: class=ef subclass=04 # Miscellaneous network devices
    ALLOW: # Otherwise allow everything else
    

    but also tried:

    # When you change this file, run 'xe pusb-scan' to confirm
    # the file can be parsed correctly.
    #
    # Syntax is an ordered list of case insensitive rules where # is line comment
    #  and each rule is (ALLOW | DENY) : ( match )*
    #  and each match is (class|subclass|prot|vid|pid|rel) = hex-number
    # Maximum hex value for class/subclass/prot is FF, and for vid/pid/rel is FFFF
    #
    # USB Hubs (class 09) are always denied, independently of the rules in this file
    DENY: vid=17e9 # All DisplayLink USB displays
    ALLOW:vid=0658 pid=0200 # Aeotec Z-Stick Gen5 (ZW090) - UZB
    ALLOW: class=02 # Communications and CDC-Control
    ALLOW:vid=056a pid=0315 class=03 # Wacom Intuos tablet
    ALLOW:vid=056a pid=0314 class=03 # Wacom Intuos tablet
    ALLOW:vid=056a pid=00fb class=03 # Wacom DTU tablet
    DENY: class=03 subclass=01 prot=01 # HID Boot keyboards
    DENY: class=03 subclass=01 prot=02 # HID Boot mice
    ALLOW: class=0a # CDC-Data
    DENY: class=0b # Smartcard
    DENY: class=e0 # Wireless controller
    DENY: class=ef subclass=04 # Miscellaneous network devices
    ALLOW: # Otherwise allow everything else
    

    After some playing around we got:

    [13:14 vmhost ~]# xe pusb-scan host-uuid=*****
    [13:15 vmhost ~]# xe pusb-list host-uuid=*****
    uuid ( RO)            : 0f7d6f12-6c4e-4f71-0c81-f7a7503a75f1
                path ( RO): 1-8
           vendor-id ( RO): 0658
         vendor-desc ( RO): Sigma Designs, Inc.
          product-id ( RO): 0200
        product-desc ( RO): Aeotec Z-Stick Gen5 (ZW090) - UZB
              serial ( RO):
             version ( RO): 2.00
         description ( RO): Sigma Designs, Inc._Aeotec Z-Stick Gen5 (ZW090) - UZB
    
    
    uuid ( RO)            : 2ba8de5b-8fe1-0262-f741-35b4ed350ae0
                path ( RO): 1-2
           vendor-id ( RO): 067b
         vendor-desc ( RO): Prolific Technology, Inc.
          product-id ( RO): 2303
        product-desc ( RO): PL2303 Serial Port
              serial ( RO):
             version ( RO): 1.10
         description ( RO): Prolific Technology, Inc._PL2303 Serial Port
    
    
    uuid ( RO)            : 08b23122-e01b-9ab2-e72d-185648ae19d7
                path ( RO): 1-7
           vendor-id ( RO): 0403
         vendor-desc ( RO): Future Technology Devices International, Ltd
          product-id ( RO): 6015
        product-desc ( RO): Bridge(I2C/SPI/UART/FIFO)
              serial ( RO): *****
             version ( RO): 2.00
         description ( RO): Future Technology Devices International, Ltd_Bridge(I2C/SPI/UART/FIFO)_DO2VQGDG
    

    Well we're ready for some pass-through, right?

    Using XCP-ng Center we can see these 3 devices and "Enable pass-through" for all of these 3 devices. After shutting down the VM, using properties we can attach all 3 USB-devices and start the VM again, but not before running the following command as was recommended:

    xe vm-param-set uuid=**** platform:device-model=qemu-upstream-compat
    

    Let's start and monitor dmesg:

    [  742.309309] block tda: sector-size: 512/512 capacity: 20971520
    [  742.727012] device vif6.0 entered promiscuous mode
    [  742.961272] device tap6.0 entered promiscuous mode
    [  743.068536] usb 1-8: reset full-speed USB device number 4 using xhci_hcd
    [  743.217985] cdc_acm 1-8:1.0: ttyACM0: USB ACM device
    [  743.376482] usb 1-8: reset full-speed USB device number 4 using xhci_hcd
    [  743.525903] cdc_acm 1-8:1.0: ttyACM0: USB ACM device
    [  743.571126] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
    [  743.571136] ftdi_sio 1-7:1.0: device disconnected
    [  743.700284] usb 1-7: reset full-speed USB device number 3 using xhci_hcd
    [  743.851993] ftdi_sio 1-7:1.0: FTDI USB Serial Device converter detected
    [  743.852018] usb 1-7: Detected FT-X
    [  743.852171] usb 1-7: FTDI USB Serial Device converter now attached to ttyUSB0
    [  743.984286] usb 1-8: reset full-speed USB device number 4 using xhci_hcd
    [  744.137611] cdc_acm 1-8:1.0: ttyACM0: USB ACM device
    [  744.138491] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
    [  744.138500] ftdi_sio 1-7:1.0: device disconnected
    [  744.268258] usb 1-7: reset full-speed USB device number 3 using xhci_hcd
    [  744.420007] ftdi_sio 1-7:1.0: FTDI USB Serial Device converter detected
    [  744.420029] usb 1-7: Detected FT-X
    [  744.420464] usb 1-7: FTDI USB Serial Device converter now attached to ttyUSB0
    [  744.465529] pl2303 ttyUSB1: pl2303 converter now disconnected from ttyUSB1
    [  744.465539] pl2303 1-2:1.0: device disconnected
    [  744.592213] usb 1-2: reset full-speed USB device number 2 using xhci_hcd
    [  744.741634] pl2303 1-2:1.0: pl2303 converter detected
    [  744.742254] usb 1-2: pl2303 converter now attached to ttyUSB1
    [  744.876149] usb 1-8: reset full-speed USB device number 4 using xhci_hcd
    [  745.025388] cdc_acm 1-8:1.0: ttyACM0: USB ACM device
    [  745.025629] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
    [  745.025636] ftdi_sio 1-7:1.0: device disconnected
    [  745.156079] usb 1-7: reset full-speed USB device number 3 using xhci_hcd
    [  745.307475] ftdi_sio 1-7:1.0: FTDI USB Serial Device converter detected
    [  745.307495] usb 1-7: Detected FT-X
    [  745.307652] usb 1-7: FTDI USB Serial Device converter now attached to ttyUSB0
    [  745.308046] pl2303 ttyUSB1: pl2303 converter now disconnected from ttyUSB1
    [  745.308054] pl2303 1-2:1.0: device disconnected
    [  747.307309] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
    [  747.307318] ftdi_sio 1-7:1.0: device disconnected
    [  747.435543] usb 1-7: reset full-speed USB device number 3 using xhci_hcd
    [  747.586967] ftdi_sio 1-7:1.0: FTDI USB Serial Device converter detected
    [  747.586987] usb 1-7: Detected FT-X
    [  747.587202] usb 1-7: FTDI USB Serial Device converter now attached to ttyUSB0
    [  756.026324] device tap6.0 left promiscuous mode
    [  756.744069] vif vif-6-0 vif6.0: Guest Rx ready
    [  757.925017] usb 1-2: reset full-speed USB device number 2 using xhci_hcd
    [  758.321147] usb 1-2: reset full-speed USB device number 2 using xhci_hcd
    [  768.745084] pl2303 1-2:1.0: pl2303 converter detected
    [  768.746207] usb 1-2: pl2303 converter now attached to ttyUSB1
    [  769.803089] device vif6.0 left promiscuous mode
    

    And xensource.log as txt file while the VM started and got shutdown.

    Oh and so far everything looked good, right? Everything got attached, the VM booted and the properties of the VM shows that all 3 devices are "Attached".

    On the VM running ubuntu I get the following:

    vm@vm:~$ lsusb -t
    /:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
        |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 12M
            |__ Port 1: Dev 4, If 0, Class=Vendor Specific Class, Driver=pl2303, 12M
        |__ Port 2: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M
    /:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/6p, 480M
    

    My USB 1.1 device (ZiGate) is present! The other 2 devices are USB2.0 and those are magically missing?! Why? How? What did I do wrong!? What can I try to make this work?

    Ah well, time to pci-pass-through my USB controller into that device again, although I would have prefered USB-passthrough! I did also apply scottyXCPNG's workaround, but not allow my USB 2.0 devices to be passed into the VM with those applied.


Log in to reply
 

XCP-ng Pro Support

XCP-ng Pro Support