[Plugin] USB_Manager


SimonF

Recommended Posts

23 minutes ago, Reid B said:

Sorry I ran that after rebooting the VM where it says its connected, but detaching and re-attaching and then running the command here is the output.
image.png.6f4ed9331deafa8c856ddc16cdbdc9e3.png

can you post diagnostic and I will look at it tomorrow.

Link to comment
15 hours ago, Reid B said:

Did you add this entry to the xml?

 

<hub type="usb">
<address type="usb" bus="0" port="2"/>
</hub>

 

There a lots of errors keep apearing for the Simucube how is it connected, Is there enough power. Bandwidth is only showing as 12mb is that enough?

 

can you send udevadm  info query -a -p /sys/bus/usb/devices/1-11.2

Link to comment

I have not added any entries to the xml manually, should I? I also cant find any information on how much bandwidth it needs, it is a servo motor. This is all I can find in their documentation about USB usage. The device has its own external power supply and I have tried several motherboard USB slots as well as a powered USB hub. I also tested the device on a machine running windows naively and it works fine.
 

Quote

Wheel axis: X axis, Unsigned 16 bit field, 0-65535 value

Y axis: Unsigned 16 bit field. This axis will idle at center position. However, users can map external pedal or handbrake to this axis.

    Do not utilize product X and Y axises for in-game menu browsing!

Pedal/handbrake axises: 6 additional axises, unsigned 16 bit values.

    These can be set by users to inteface with Simucube-compatible pedals or handbrakes, or with (upcoming) analog axises (clutch paddles) from Simucube Wireless Wheels

Buttons: There are 128 buttons.

I have no other peripherals plugged in through the wheel, so I feel like it should just be using the X axis.

Here is the output from the query:

Quote

  looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-11/1-11.2':
    KERNEL=="1-11.2"
    SUBSYSTEM=="usb"
    DRIVER=="usb"
    ATTR{configuration}=="Simucube 2 Pro"
    ATTR{bMaxPacketSize0}=="64"
    ATTR{bDeviceClass}=="00"
    ATTR{bcdDevice}=="0200"
    ATTR{bNumInterfaces}==" 3"
    ATTR{bConfigurationValue}=="1"
    ATTR{manufacturer}=="Granite devices"
    ATTR{bNumConfigurations}=="1"
    ATTR{authorized}=="1"
    ATTR{speed}=="12"
    ATTR{idProduct}=="0d60"
    ATTR{urbnum}=="113"
    ATTR{devnum}=="55"
    ATTR{product}=="Simucube 2 Pro"
    ATTR{maxchild}=="0"
    ATTR{bmAttributes}=="c0"
    ATTR{bDeviceSubClass}=="00"
    ATTR{bMaxPower}=="100mA"
    ATTR{rx_lanes}=="1"
    ATTR{removable}=="unknown"
    ATTR{idVendor}=="16d0"
    ATTR{version}==" 2.00"
    ATTR{avoid_reset_quirk}=="0"
    ATTR{serial}=="206C354E5333"
    ATTR{bDeviceProtocol}=="00"
    ATTR{tx_lanes}=="1"
    ATTR{ltm_capable}=="no"
    ATTR{devpath}=="11.2"
    ATTR{busnum}=="1"
    ATTR{quirks}=="0x0"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-11':
    KERNELS=="1-11"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bcdDevice}=="8536"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{authorized}=="1"
    ATTRS{speed}=="480"
    ATTRS{idProduct}=="0608"
    ATTRS{urbnum}=="986"
    ATTRS{devnum}=="13"
    ATTRS{product}=="USB2.0 Hub"
    ATTRS{maxchild}=="4"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{rx_lanes}=="1"
    ATTRS{removable}=="removable"
    ATTRS{idVendor}=="05e3"
    ATTRS{version}==" 2.00"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{tx_lanes}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{devpath}=="11"
    ATTRS{busnum}=="1"
    ATTRS{quirks}=="0x0"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bcdDevice}=="0601"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{manufacturer}=="Linux 6.1.64-Unraid xhci-hcd"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{authorized}=="1"
    ATTRS{speed}=="480"
    ATTRS{idProduct}=="0002"
    ATTRS{urbnum}=="1242"
    ATTRS{devnum}=="1"
    ATTRS{product}=="xHCI Host Controller"
    ATTRS{maxchild}=="16"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{rx_lanes}=="1"
    ATTRS{removable}=="unknown"
    ATTRS{idVendor}=="1d6b"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{authorized_default}=="1"
    ATTRS{version}==" 2.00"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{serial}=="0000:00:14.0"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{tx_lanes}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{devpath}=="0"
    ATTRS{busnum}=="1"
    ATTRS{quirks}=="0x0"

  looking at parent device '/devices/pci0000:00/0000:00:14.0':
    KERNELS=="0000:00:14.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="xhci_hcd"
    ATTRS{power_state}=="D0"
    ATTRS{broken_parity_status}=="0"
    ATTRS{subsystem_device}=="0x5007"
    ATTRS{dma_mask_bits}=="64"
    ATTRS{vendor}=="0x8086"
    ATTRS{local_cpus}=="ffff"
    ATTRS{class}=="0x0c0330"
    ATTRS{numa_node}=="-1"
    ATTRS{msi_bus}=="1"
    ATTRS{device}=="0x43ed"
    ATTRS{label}=="Onboard - Other"
    ATTRS{index}=="2"
    ATTRS{local_cpulist}=="0-15"
    ATTRS{driver_override}=="(null)"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{irq}=="130"
    ATTRS{revision}=="0x11"
    ATTRS{consistent_dma_mask_bits}=="64"
    ATTRS{ari_enabled}=="0"
    ATTRS{enable}=="1"
    ATTRS{subsystem_vendor}=="0x1458"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{waiting_for_supplier}=="0"

 

Link to comment
2 hours ago, Reid B said:

I have not added any entries to the xml manually, should I?

Not sure as yet, not sure why the hub lines are there not seen that before in a standard xml.

 

can you provide lsusb -vvvvs 001:055

Link to comment

Bus 001 Device 055: ID 16d0:0d60 MCS Simucube 2 Pro
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x16d0 MCS
  idProduct          0x0d60
  bcdDevice            2.00
  iManufacturer           1 Granite devices
  iProduct                2 Simucube 2 Pro
  iSerial                 3 206C354E5333
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x007c
    bNumInterfaces          0
    bConfigurationValue     1
    iConfiguration          2 Simucube 2 Pro
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         1
      bFunctionClass          3 Human Interface Device
      bFunctionSubClass       0
      bFunctionProtocol       0
      iFunction               0
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0001
  Self Powered

Link to comment
2 hours ago, Reid B said:

Bus 001 Device 055: ID 16d0:0d60 MCS Simucube 2 Pro
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x16d0 MCS
  idProduct          0x0d60
  bcdDevice            2.00
  iManufacturer           1 Granite devices
  iProduct                2 Simucube 2 Pro
  iSerial                 3 206C354E5333
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x007c
    bNumInterfaces          0
    bConfigurationValue     1
    iConfiguration          2 Simucube 2 Pro
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         1
      bFunctionClass          3 Human Interface Device
      bFunctionSubClass       0
      bFunctionProtocol       0
      iFunction               0
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0001
  Self Powered

Looks like there is a serial component, try using connect as serial, but his may mean other parts are not mapped as there are 3 interfaces for the USB device. I will have to do some research to see if I can find other solutions if that does not work.

 

Do you have an option for a USB PCI card you can pass thru to the vm and connect the device to that?

Link to comment

Adding in the serial connection option did not get it working.

I do not have any USB PCI cards. I am basically passing every USB device through I can, so I am happy to pass all my devices through on the hubs.

Link to comment
18 hours ago, Reid B said:

Adding in the serial connection option did not get it working.

I do not have any USB PCI cards. I am basically passing every USB device through I can, so I am happy to pass all my devices through on the hubs.

Last idea I have a presentis to see if turning off guest reset helps.

 

create a temp file i.e. nano /tmp/vmaddxml and add the text below. Change device ID to match if not still 055

 

<hostdev mode='subsystem' type='usb'>

  <source guestReset='off'>

    <address bus='001' device='055' />

  </source>

</hostdev>

 

Detach the usb device from VM.

 

Then run from the command line

 

virsh attach-device "Adam Driver" /tmp/vmaddxml

Since 8.6.0, the source element can contain guestReset attribute with the following value:

off

all guest initiated device reset requests are ignored

uninitialized

device request is ignored if device is initialized, otherwise reset is performed

on

device is reset on every guest initiated request

This attribute can be helpful when assigning an USB device with a firmware that crashes on reset.

 

Link to comment

I created and ran the file as instructed, and get this error.

 

Quote

root@Goliath:~# virsh attach-device "Adam Driver" /tmp/vmaddxml
error: Failed to attach device from /tmp/vmaddxml
error: internal error: Did not find USB device bus:1 device:45

 

The device is still listed as device 55 and that's what it is written as in the script, so I'm not sure where the 45 comes from. Although the UI no longer says Virsh error when I attach the device.

image.thumb.png.1ba61b70b57365f00d92fedf93633f2b.png

 

Link to comment
24 minutes ago, Reid B said:

I created and ran the file as instructed, and get this error.

 

 

The device is still listed as device 55 and that's what it is written as in the script, so I'm not sure where the 45 comes from. Although the UI no longer says Virsh error when I attach the device.

image.thumb.png.1ba61b70b57365f00d92fedf93633f2b.png

 

The gui will not show anything except connect outside when connected as the plugin functions are not being used. What does cat /tmp/vmaddxml show

Link to comment

I borrowed a PCI USB card from a friend to try that, Unraid see's it as an extension of the USB network. I cannot seem to pass through the entirety of the PCI card, just the Hub 3-1. Still doesn't seem to work with or without the auto-connect options.
image.thumb.png.66dd59e8b1dbf978cf7b3c086abf52be.png

Link to comment
1 hour ago, Reid B said:

I borrowed a PCI USB card from a friend to try that, Unraid see's it as an extension of the USB network. I cannot seem to pass through the entirety of the PCI card, just the Hub 3-1. Still doesn't seem to work with or without the auto-connect options.
image.thumb.png.66dd59e8b1dbf978cf7b3c086abf52be.png

If you have a PCI card you should passthru that to the VM.

 

In system devices bind that new card to vfio. I dont have a dedicate PCI USB, but like my A770 click the check box next to the card. Then the bind button will allow you to save the setting.

 

image.png

 

You will need to reboot the server for that to take effect.

 

Then in the VM you should see the card. in this section on the VM Template. Other PCI devices. Select the USB card and update. Now when the VM starts the whole card is connected to the VM and any USB devices connected will be on the VM.

 

For devices connected to the card they do not need to be in the VM template and should not even show as the card is not bound to the host but the VM.

 

image.png

Link to comment

That seems to have worked. It is showing up as a USB device in my Windows VM with the correct information under USB View. The control software for it wont see it still, but I don't think that is an Unraid issue. I will look for help from their community for this. Thank you for your help.

Link to comment
On 3/15/2024 at 11:31 AM, SimonF said:

No these scripts need to be set in the sleep plug post and pre scripts. It is to disconnect the devices from the VM as they get renumbered at host resume. The disconnect just removes the attached usb devices from the VM. Is there a option to suspend as part of the sleep. I don't use sleep but these are options I provided to another user with the same issues.

Hi SimonF,
I want to thank you again for great work and support.
I was unable to reply before, and even if I am giving up on unraid as my main working setup,
I want to give feedback to what has worked for me.

I used this in before sleep hook:
 

#!/bin/bash
date >> /boot/logs/sleep.log
echo "Sleeping ..." >> /boot/logs/sleep.log
# Get a list of all VMs that are running
domains=$(virsh list --all | grep running)
# Check if the previous command returned any data - If no VMs are running, the variable 'domains' will be empty
if [ -z "$domains" ] 
then
    # Nothing to do here - exit
    echo "No VMs are running" >> /boot/logs/sleep.log
    exit 0
fi
# 1 or more VMs are running
echo "Found the following VMs running:" >> /boot/logs/sleep.log
echo "$domains" >> /boot/logs/sleep.log
# Get a list of the VM IDs
domains=($(virsh list --all | grep running | awk '{ print $1 }'))
# Issue the suspend command to each VM that is running
for domain in "${domains[@]}"; do
    echo "Issuing the dompmsuspend and USB disconnect command to VM $domain" >> /boot/logs/sleep.log
    virsh dompmsuspend $domain mem
	sleep 5
	rc.usb_manager vm_action $domain disconnect
	sleep 5
done

and the following in after wake-up:
 

#!/bin/bash
date >> /boot/logs/sleep.log
echo "Waking up ..." >> /boot/logs/sleep.log
# Get a list of all VMs that are pmsuspended
domains=$(virsh list --all | grep pmsuspended)
# Check if the previous command returned any data - If no VMs are pmsuspended, the variable 'domains' will be empty
if [ -z "$domains" ] 
then
    # Nothing to do here - exit
    echo "No VMs are pmsuspended" >> /boot/logs/sleep.log 
    exit 0
fi
# 1 or more VMs are pmsuspended
echo "Found the following VMs pmsuspended:" >> /boot/logs/sleep.log
echo "$domains" >> /boot/logs/sleep.log
# Get a list of the VM IDs
domains=($(virsh list --all | grep pmsuspended | awk '{ print $1 }'))
# Issue the resume command to each VM that is pmsuspended
for domain in "${domains[@]}"; do
    echo "Issuing the USB prepare and dompmwakeup command to VM $domain" >> /boot/logs/sleep.log
	rc.usb_manager vm_action $domain prepare
	sleep 5
    virsh dompmwakeup $domain
done

which resulted in following log file:
 

Mon Mar 18 17:21:23 CET 2024
Sleeping ...
Found the following VMs running:
 4    TheMainWindows10   running
Issuing the dompmsuspend and USB disconnect command to VM 4
Mon Mar 18 17:22:06 CET 2024
Waking up ...
Found the following VMs pmsuspended:
 4    TheMainWindows10   pmsuspended
Issuing the USB prepare and dompmwakeup command to VM 4

The scripts can obviously be less verbose, but I needed it for troubleshooting and adjusting sleep fudge factor.

As said I am moving from my idea of one in all system, as cons outweigh the pros, and I will be running one pure Windows machine I need for my work, and another, most likely, unraid (zfs) for backups.
Thanks again, and keep up the good work :)

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.