13.8. Attaching DASD devices to virtual machines on IBM Z
Using the vfio-ccw
feature, you can assign direct-access storage devices (DASDs) as mediated devices to your virtual machines (VMs) on IBM Z hosts. This for example makes it possible for the VM to access a z/OS dataset, or to provide the assigned DASDs to a z/OS machine.
Conditions préalables
- Your host system is using the IBM Z hardware architecture and supports the FICON protocol.
- The target VM is using a Linux guest operating system.
The driverctl package is installed.
# dnf install driverctl
The necessary kernel modules have been loaded on the host. To verify, use:
# lsmod | grep vfio
The output should contain the following modules:
-
vfio_ccw
-
vfio_mdev
-
vfio_iommu_type1
-
You have a spare DASD device for exclusive use by the VM, and you know the device’s identifier.
This procedure uses
0.0.002c
as an example. When performing the commands, replace0.0.002c
with the identifier of your DASD device.
Procédure
Obtain the subchannel identifier of the DASD device.
# lscss -d 0.0.002c Device Subchan. DevType CU Type Use PIM PAM POM CHPIDs ---------------------------------------------------------------------- 0.0.002c 0.0.29a8 3390/0c 3990/e9 yes f0 f0 ff 02111221 00000000
In this example, the subchannel identifier is detected as
0.0.29a8
. In the following commands of this procedure, replace0.0.29a8
with the detected subchannel identifier of your device.If the
lscss
command in the previous step only displayed the header output and no device information, perform the following steps:Remove the device from the
cio_ignore
list.# cio_ignore -r 0.0.002c
In the guest OS, edit the kernel command line of the VM and add the device identifier with a
!
mark to the line that starts withcio_ignore=
, if it is not present already.cio_ignore=all,!condev,!0.0.002c
- Repeat step 1 on the host to obtain the subchannel identifier.
Bind the subchannel to the
vfio_ccw
passthrough driver.# driverctl -b css set-override 0.0.29a8 vfio_ccw
NoteThis binds the 0.0.29a8 subchannel to
vfio_ccw
persistently, which means the DASD will not be usable on the host. If you need to use the device on the host, you must first remove the automatic binding to 'vfio_ccw' and rebind the subchannel to the default driver:# driverctl -b css unset-override 0.0.29a8
Generate an UUID.
# uuidgen 30820a6f-b1a5-4503-91ca-0c10ba12345a
Define and start the DASD mediated device.
# cat nodedev.xml <device> <parent>css_0_0_29a8</parent> <capability type="mdev"> <type id="vfio_ccw-io"/> <uuid>30820a6f-b1a5-4503-91ca-0c10ba12345a</uuid> </capability> </device> # virsh nodedev-define nodedev.xml Node device 'mdev_30820a6f_b1a5_4503_91ca_0c10ba12345a_0_0_29a8' defined from 'nodedev.xml' # virsh nodedev-start mdev_30820a6f_b1a5_4503_91ca_0c10ba12345a_0_0_29a8 Device mdev_30820a6f_b1a5_4503_91ca_0c10ba12345a_0_0_29a8 started
- Shut down the VM, if it is running.
Attach the mediated device to the VM. To do so, use the
virsh edit
utility to edit the XML configuration of the VM, add the following section to the XML, and replace theuuid
value with the UUID you generated in the previous step.<hostdev mode='subsystem' type='mdev' model='vfio-ccw'> <source> <address uuid="30820a6f-b1a5-4503-91ca-0c10ba12345a"/> </source> </hostdev>
Optional: Configure the mediated device to start automatically on host boot.
# virsh nodedev-autostart mdev_30820a6f_b1a5_4503_91ca_0c10ba12345a_0_0_29a8
Vérification
Ensure that the mediated device is configured correctly.
# virsh nodedev-info mdev_30820a6f_b1a5_4503_91ca_0c10ba12345a_0_0_29a8 Name: mdev_30820a6f_b1a5_4503_91ca_0c10ba12345a_0_0_29a8 Parent: css_0_0_0121 Active: yes Persistent: yes Autostart: yes
Obtain the identifier that
libvirt
assigned to the mediated DASD device. To do so, display the XML configuration of the VM and look for avfio-ccw
device.# virsh dumpxml vm-name <domain> [...] <hostdev mode='subsystem' type='mdev' managed='no' model='vfio-ccw'> <source> <address uuid='10620d2f-ed4d-437b-8aff-beda461541f9'/> </source> <alias name='hostdev0'/> <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0009'/> </hostdev> [...] </domain>
In this example, the assigned identifier of the device is
0.0.0009
.- Start the VM and log in to its guest OS.
In the guest OS, confirm that the DASD device is listed. For example:
# lscss | grep 0.0.0009 0.0.0009 0.0.0007 3390/0c 3990/e9 f0 f0 ff 12212231 00000000
In the guest OS, set the device online. For example:
# chccwdev -e 0.0009 Setting device 0.0.0009 online Done
Ressources supplémentaires