Did you know  45Drives offers free  public and private  webinars ? Click here to learn more  & register! Build & Price

KB450408 – USB controller passthrough to VM’s in Houston

You are here:

Scope/Description

This guide covers how to passthrough a USB controller from your host machine to a VM on top of Houston.

Prerequisites

  • A working Ubuntu install with Houston UI
  • A created VM through Houston UI
  • Access to Houston UI and its CLI
  • A CPU that supports IOMMU groups

Steps

  • Edit the host machines boot loader found in /etc/default/grub and edit the following line:
GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on"
  • Update grub and reboot using the below commands. Make sure to stop any VM’s or services prior to reboot.
update-grub
reboot
  • Once the reboot is completed create a new bash script with the following content. In order to do this, first create a new file called iommu.sh
  • Copy the following data into the new file:
#!/bin/bash
shopt -s nullglob
for g in `find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V`; do
    echo "IOMMU Group ${g##*/}:"
    for d in $g/devices/*; do
        echo -e "\t$(lspci -nns ${d##*/})"
    done;
done;
  • Save the file and quit
  • Make the iommu.sh file executable and then run it
chmod +x iommu.sh
./iommu.sh
  • Running the script should output a series of groups which indicates a successful activation of passthrough. If the output is blank confirm there were no errors in your /etc/default/grub config
  • We now need the identifying information for our USB controller, this can be done by outputting lspci to a text file for easier parsing.
lspci -vmm > temp.txt
  • Open the generated text file and search for “USB”, the format of the output we are looking for is bus:slot.function. An example is shown in the screenshot below. Make sure to keep the slot information as we will need it later.

  • We will now edit the created virtual machines.xml file by issuing the below command
virsh edit
  • In this XML navigate to <devices>, there will be an <emulator> section, under <emulator> add the following lines. Make sure to replace the bus, slot and function output to the numbers you gaterhed above
<hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x14' function='0x0'/>
      </source>
    </hostdev>

  • You can now reboot the VM- once the reboot is finished your USB controller will have been successfully passed through and you should now be able to see any USB devices you plug in

Verification

  • Successful passthrough of the USB controller to the VM can be verified by running lspci -vmm > temp.txt and searching for USB again

Troubleshooting

  • Most errors in this process will occur when editing the XML file as it’s formatting is very particular, some examples of possible format error messages are below. All of these can be solved by making sure to follow the correct format and parsing

Was this article helpful?
Dislike 0
Views: 419
Unboxing Racking Storage Drives Cable Setup Power UPS Sizing Remote Access