qemu/docs/system/s390x/vfio-ccw.rst
<<
>>
Prefs
   1Subchannel passthrough via vfio-ccw
   2===================================
   3
   4vfio-ccw (based upon the mediated vfio device infrastructure) allows to
   5make certain I/O subchannels and their devices available to a guest. The
   6host will not interact with those subchannels/devices any more.
   7
   8Note that while vfio-ccw should work with most non-QDIO devices, only ECKD
   9DASDs have really been tested.
  10
  11Example configuration
  12---------------------
  13
  14Step 1: configure the host device
  15~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  16
  17As every mdev is identified by a uuid, the first step is to obtain one::
  18
  19  [root@host ~]# uuidgen
  20  7e270a25-e163-4922-af60-757fc8ed48c6
  21
  22Note: it is recommended to use the ``mdevctl`` tool for actually configuring
  23the host device.
  24
  25To define the same device as configured below to be started
  26automatically, use
  27
  28::
  29
  30   [root@host ~]# driverctl -b css set-override 0.0.0313 vfio_ccw
  31   [root@host ~]# mdevctl define -u 7e270a25-e163-4922-af60-757fc8ed48c6 \
  32                  -p 0.0.0313 -t vfio_ccw-io -a
  33
  34If using ``mdevctl`` is not possible or wanted, follow the manual procedure
  35below.
  36
  37* Locate the subchannel for the device (in this example, ``0.0.2b09``)::
  38
  39    [root@host ~]# lscss | grep 0.0.2b09 | awk '{print $2}'
  40    0.0.0313
  41
  42* Unbind the subchannel (in this example, ``0.0.0313``) from the standard
  43  I/O subchannel driver and bind it to the vfio-ccw driver::
  44
  45    [root@host ~]# echo 0.0.0313 > /sys/bus/css/devices/0.0.0313/driver/unbind
  46    [root@host ~]# echo 0.0.0313 > /sys/bus/css/drivers/vfio_ccw/bind
  47
  48* Create the mediated device (identified by the uuid)::
  49
  50    [root@host ~]# echo "7e270a25-e163-4922-af60-757fc8ed48c6" > \
  51    /sys/bus/css/devices/0.0.0313/mdev_supported_types/vfio_ccw-io/create
  52
  53Step 2: configure QEMU
  54~~~~~~~~~~~~~~~~~~~~~~
  55
  56* Reference the created mediated device and (optionally) pick a device id to
  57  be presented in the guest (here, ``fe.0.1234``, which will end up visible
  58  in the guest as ``0.0.1234``::
  59
  60    -device vfio-ccw,devno=fe.0.1234,sysfsdev=\
  61    /sys/bus/mdev/devices/7e270a25-e163-4922-af60-757fc8ed48c6
  62
  63* Start the guest. The device (here, ``0.0.1234``) should now be usable::
  64
  65    [root@guest ~]# lscss -d 0.0.1234
  66    Device   Subchan.  DevType CU Type Use  PIM PAM POM  CHPID
  67    ----------------------------------------------------------------------
  68    0.0.1234 0.0.0007  3390/0e 3990/e9      f0  f0  ff   1a2a3a0a 00000000
  69    [root@guest ~]# chccwdev -e 0.0.1234
  70    Setting device 0.0.1234 online
  71    Done
  72    [root@guest ~]# dmesg -t
  73    (...)
  74    dasd-eckd 0.0.1234: A channel path to the device has become operational
  75    dasd-eckd 0.0.1234: New DASD 3390/0E (CU 3990/01) with 10017 cylinders, 15 heads, 224 sectors
  76    dasd-eckd 0.0.1234: DASD with 4 KB/block, 7212240 KB total size, 48 KB/track, compatible disk layout
  77    dasda:VOL1/  0X2B09: dasda1
  78