Attach or Remove VM Host Devices

Using the VM [name] page, Cockpit administrators can add host devices or remove them on a VM instance.

Host devices are physical devices connected to the managed host system, such as:

  • SCSI tape drives, disks, and changers
  • PCI NICs, GPUs, and HBAs
  • USB mice, cameras, and disks

What Do You Need?

  • The Cockpit web console must be installed and accessible.

    For details, see these topics: Install and Enable Cockpit and Log in to the Cockpit Web Console.

  • The Cockpit-machines add-on application must be installed in the web console and the Oracle Linux virtualization packages must be installed and enabled on the host system.

    For more information, see Install Cockpit-Machines and Enable Virtualization.

  • One or more virtual machine instances exist on the managed host system and appear in the Virtual machines page.
  • The host device is directly attached and operational on the managed host system.

Steps

Using the Cockpit web console, follow these steps to add or remove a VM host device.

  1. In the Cockpit navigation pane, click Virtual machines.

    The Virtual machines page appears.

  2. In the Virtual machines page, click the name of the virtual machine of interest.

    The Virtual machines [VM name] page appears.

  3. In Virtual machines [VM name] page, navigate to the Host devices section and perform any of the following actions:

    Add host device Perform these steps:
    1. Click Add host device.
    2. In the Add dialog, configure the following properties.
      • Type: Select USB or PCI to populate the Device product list.
      • Device: Select the check box for the host device you want to add.
    3. Click Add. The host device appears in the Host devices section.
    4. Restart the VM instance to detect the newly added host device.

      For details, see Start, Shutdown, Remove, or Interrupt a VM Instance.

      Upon restarting the VM, the newly added device appears in the Host devices section of the VM instance page.

    Troubleshooting: If an operational error appears when restarting the VM, you can fix the error by removing the host device from the virtual machine, or correcting the issues identified in the error message.
    Remove Optional Requirement:
    • Before detaching a host device, consider using the virsh dumpxml command to create a backup of the VM XML configuration file:
      virsh dumpxml VM_name > VM_name.xml
       cat VM_name.xml
      <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
        <name>VM_name</name>
        <uuid>ede29304-fe0c-4ca4-abcd-d246481acd18</uuid>
        [...]

    Perform these steps:

    • Click Remove.
    • In the confirmation dialog, click Remove to detach the host device from the VM instance.
    Troubleshooting:
    • If removing a host device causes the VM instance to become unbootable, use the virsh define utility to restore the backed up XML configuration.
      virsh define VM_name.xml
    • The removal of an attached USB host device might fail because of an incorrect correlation between the device and bus numbers of the USB device. As a workaround, edit VM’s XML configuration file to remove the USB device entry [hostdev]. For example:
      virsh edit VM_name_xml_file