How to identify a SCSI tape device's PCI address for KVM PCI passthrough
Environment
- RedHat Enterprise Linux (RHEL) 6.x
- libvirt/libvirt-client 0.10.2
- Tape device attached to a SCSI controller
Issue
When a tape drive is attached to a SCSI controller, it cannot be identified with lspci. When a system has multiple SCSI controllers attached to it, identifying the proper PCI bus controlling the tape drive can be challenging.
Resolution
Trace the SCSI tape drive's PCI bus path from the kernel through libvirt. Determine device name, PCI bus assignment, and the "translated" name assigned to the PCI bus by libvirt.
Refer to the Diagnostic Steps for details on collecting this information.
Root Cause
SCSI-attached devices are not PCI devices, and therefore will not show up by name when running lspci.
Diagnostic Steps
Determine what device name was assigned to the tape drive
Use the dmesg command to list identified SCSI tape drives
# dmesg | grep -i 'scsi tape'
st 11:0:1:0: Attached scsi tape st0
This command confirms that the kernel identified one tape drive and assigned it to st0
Determine the PCI bus of the st0 device
Use the find command to locate the st0 device within the /sys tree
# find /sys -name st0
/sys/devices/pci0000:00/0000:00:02.0/0000:01:00.3/0000:05:05.0/host11/target11:0:1/11:0:1:0/scsi_tape/st0
/sys/class/scsi_tape/st0
This command identifies the PCI bus chain that the st0 device is attached to. All addresses between pci0000:0 and host11 are PCI bus addresses, and the last one, 05:05.0 is the PCI bus we will use when passing the tape drive through using libvirt.
Identify the name of the SCSI controller attached to the PCI bus (optional)
Now that the PCI bus has been identified, lspci -s can be used to get a name for the SCSI controller attached there. This can be useful when using virt-manager to configure PCI passthrough.
# lspci -s 0000:05:05.0
05:05.0 SCSI storage controller: Adaptec AIC-7892A U160/m (rev 02)
Get the "libvirt-translated" bus name for the PCI bus the tape drive is attached to
Libvirt converts : and . to _, and appends pci_ to the bus address.
In our example above, the PCI bus is 0000:05:05.0. So, look for pci_0000_05_05_0 in the following command output.
Use the virsh nodedev-list --tree command to get the translated bus name.
# virsh nodedev-list --tree
...
+- pci_0000_00_02_0
| |
| +- pci_0000_01_00_0
| | |
| | +- pci_0000_02_00_0
| | +- pci_0000_02_01_0
| |
| +- pci_0000_01_00_3
| |
| +- pci_0000_05_05_0
| |
| +- scsi_host11
| | |
| | +- scsi_target11_0_1
| | |
| | +- scsi_11_0_1_0
| | +- scsi_11_0_1_1
...
Based on the information gathered above, here is the pertinent information about the tape drive:
- PCI bus address:
0000:05:05.0 - SCSI controller name:
Adaptec AIC-7892A U160/m - libvirt "translated" PCI bus address:
pci_0000_05_05_0
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
