[PATCH virt-install v1 0/3] Add mediated device support
Shalini Chellathurai Saroja
shalini at linux.ibm.com
Wed Apr 14 15:18:54 UTC 2021
Add support to install a virtual server with passed-through mediated
device. Also provide support to add, edit, remove, hotplug and hot
unplug mediated device in a guest XML.
Example:
Create a mediated device using a DASD attached to vfio_ccw driver
in the host system.
$ virsh nodedev-list --cap mdev
mdev_1c555d00_6110_42fe_8938_889f777a15a3
mdev_265920cf_4169_46ca_9d42_5844731f0bcd
$ virsh nodedev-dumpxml mdev_1c555d00_6110_42fe_8938_889f777a15a3
<device>
<name>mdev_1c555d00_6110_42fe_8938_889f777a15a3</name>
<path>/sys/devices/css0/0.0.0023/1c555d00-6110-42fe-8938-889f777a15a3</path>
<parent>css_0_0_0023</parent>
<driver>
<name>vfio_mdev</name>
</driver>
<capability type='mdev'>
<type id='vfio_ccw-io'/>
<iommuGroup number='0'/>
</capability>
</device>
2. Install a virtual server by passing this mediated device.
$ virt-install --name vser --hostdev
mdev_1c555d00_6110_42fe_8938_889f777a15a3 --disk
/var/lib/libvirt/images/rhel83.qcow2,bus=virtio,size=8 --location
http://bistro/redhat/s390x/RHEL8.3/DVD
$ virsh dumpxml vser
[...]
<hostdev mode='subsystem' type='mdev' managed='yes' model='vfio-ccw'>
<source>
<address uuid='1c555d00-6110-42fe-8938-889f777a15a3'/>
</source>
<alias name='hostdev0'/>
<address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0002'/>
</hostdev>
[...]
Log into the created virtual server vser:
$ lscss
Device Subchan. DevType CU Type Use PIM PAM POM CHPIDs
----------------------------------------------------------------------
0.0.0003 0.0.0000 0000/00 3832/03 yes 80 80 ff 00000000 00000000
0.0.0000 0.0.0001 0000/00 3832/02 yes 80 80 ff 00000000 00000000
0.0.0001 0.0.0002 0000/00 3832/01 yes 80 80 ff 00000000 00000000
0.0.0002 0.0.0003 3390/0c 3990/ec c0 c0 ff 1c1f0000 00000000
0.0.0004 0.0.0004 0000/00 3832/05 yes 80 80 ff 00000000 00000000
0.0.0005 0.0.0005 0000/00 3832/04 yes 80 80 ff 00000000 00000000
The device 0.0.0002 is the passed mediated device.
Shut off the virtual server and edit the virtual server with the below
commands.
$ virt-xml vser --add-device --hostdev mdev_265920cf_4169_46ca_9d42_5844731f0bcd
Domain 'vser' defined successfully.
Domain XML:
[…]
<hostdev mode='subsystem' type='mdev' managed='no' model='vfio-ccw'>
<source>
<address uuid='265920cf-4169-46ca-9d42-5844731f0bcd'/>
</source>
<address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0004'/>
</hostdev>
[…]
$ virt-xml vser --edit address.devno=0x0004 --hostdev address.devno=0x0008
Domain 'vser' defined successfully.
Domain XML:
[…]
<hostdev mode='subsystem' type='mdev' managed='no' model='vfio-ccw'>
<source>
<address uuid='265920cf-4169-46ca-9d42-5844731f0bcd'/>
</source>
<address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0008'/>
</hostdev>
[…]
$ virt-xml vser --remove-device --hostdev mdev_265920cf_4169_46ca_9d42_5844731f0bcd
Domain 'vser' defined successfully.
$ virsh start vser
Domain 'vser' started
$ virsh list --all
Id Name State
---------------------------------
1 vser running
$ virt-xml vser --update --add-device --hostdev mdev_265920cf_4169_46ca_9d42_5844731f0bcd
Device hotplug successful.
Domain 'vser' defined successfully.
Domain XML:
[…]
<hostdev mode='subsystem' type='mdev' managed='no' model='vfio-ccw'>
<source>
<address uuid='265920cf-4169-46ca-9d42-5844731f0bcd'/>
</source>
<alias name='hostdev0'/>
<address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0004'/>
</hostdev>
[…]
$ virt-xml vser --update --remove-device --hostdev mdev_265920cf_4169_46ca_9d42_5844731f0bcd
Device hotunplug successful.
Domain 'vser' defined successfully.
Shalini Chellathurai Saroja (3):
virt-install: add mediated device
virt-xml: add support for mediated devices
virtxml: prevent defining same hostdev again
.../cli/compare/virt-install-many-devices.xml | 19 ++++++++
.../virt-xml-add-host-device-start.xml | 2 +-
.../cli/compare/virt-xml-add-host-device.xml | 2 +-
.../virt-xml-add-hostdev-mdev-start.xml | 12 +++++
.../cli/compare/virt-xml-add-hostdev-mdev.xml | 14 ++++++
tests/data/cli/compare/virt-xml-edit-all.xml | 7 +++
.../compare/virt-xml-edit-hostdev-mdev.xml | 11 +++++
.../compare/virt-xml-edit-simple-redirdev.xml | 2 +-
.../compare/virt-xml-remove-hostdev-mdev.xml | 15 ++++++
tests/data/testdriver/testdriver.xml | 48 +++++++++++++++++--
tests/data/testdriver/testsuite.xml | 46 ++++++++++++++++++
tests/test_cli.py | 12 ++++-
tests/test_nodedev.py | 30 ++++++++++++
tests/utils.py | 2 +-
virtinst/devices/hostdev.py | 34 ++++++++++++-
virtinst/nodedev.py | 15 ++++++
virtinst/virtxml.py | 7 +++
17 files changed, 267 insertions(+), 11 deletions(-)
create mode 100644 tests/data/cli/compare/virt-xml-add-hostdev-mdev-start.xml
create mode 100644 tests/data/cli/compare/virt-xml-add-hostdev-mdev.xml
create mode 100644 tests/data/cli/compare/virt-xml-edit-hostdev-mdev.xml
create mode 100644 tests/data/cli/compare/virt-xml-remove-hostdev-mdev.xml
--
2.26.2
More information about the virt-tools-list
mailing list