Attaching a device

You can hotplug devices to a running virtual server, add devices to the persistent virtual server configuration, or both.

Before you begin

  • Ensure that the new device is not already assigned to the virtual server.
    To list the devices that are assigned to a virtual server, you can
    • Display the current libvirt-internal configuration.
    • Use the virsh domblklist command to display a list of currently assigned block devices or the virsh domiflist command to display a list of currently assigned interface devices.
  • You need a device configuration-XML file for the device.

Procedure

  1. Optional:
    If you attach a virtual block device, and the current libvirt-internal configuration does not provide an I/O thread for the device:
    Add an I/O thread dedicated to the device by using the virsh iothreadadd command:
    # virsh iothreadadd <VS> <IOthread-ID>
    <VS>
    Is the name of the virtual server as defined in the domain configuration-XML file.
    <IOthread-ID>
    Is the ID of the I/O thread to be added to the virtual server. Be sure that the I/O thread ID matches the I/O thread ID in the device configuration-XML (see Configuring a DASD, SCSI, or NVMe disk).
  2. Attach the device using the virsh attach-device command.
    # virsh attach-device <VS> <device-configuration-XML-filename> <scope>
    <device-configuration-XML-filename>
    Is the name of the device configuration-XML file.
    <VS>
    Is the name of the virtual server as defined in the domain configuration-XML file.
    <scope>
    Specifies the scope of the command:
    --live
    Hotplugs the device to a running virtual server. This configuration change does not persist across stopping and starting the virtual server.
    --config
    Adds the device to the persistent virtual server configuration. The device becomes available when the virtual server is next started. This configuration change persists across stopping and starting the virtual server.
    --persistent
    Adds the device to the persistent virtual server configuration and hotplugs it if the virtual server is running. This configuration change persists across stopping and starting the virtual server. This option is equivalent to specifying both --live and --config.