|
|
7c1349 |
From 5245be196682b78c225e67f211c02e3802ca4bd6 Mon Sep 17 00:00:00 2001
|
|
|
7c1349 |
From: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
|
|
|
7c1349 |
Date: Wed, 14 Apr 2021 17:18:55 +0200
|
|
|
7c1349 |
Subject: [PATCH] virt-install: add mediated device
|
|
|
7c1349 |
|
|
|
7c1349 |
Add support to install a virtual server with passed-through mediated
|
|
|
7c1349 |
device. Mediated device can be created using vGPU attached to
|
|
|
7c1349 |
vfio_pci driver or DASD attached to vfio_ccw driver or APQNs attached
|
|
|
7c1349 |
to vfio_ap driver.
|
|
|
7c1349 |
|
|
|
7c1349 |
Reviewed-by: Cole Robinson <crobinso@redhat.com>
|
|
|
7c1349 |
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
|
|
|
7c1349 |
(cherry picked from commit 965480e8bc85caf8a4f36b4a2f07963067b63cf6)
|
|
|
7c1349 |
|
|
|
7c1349 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1995125
|
|
|
7c1349 |
|
|
|
7c1349 |
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
|
|
|
7c1349 |
---
|
|
|
7c1349 |
.../cli/compare/virt-install-many-devices.xml | 19 +++++++++
|
|
|
7c1349 |
tests/data/testdriver/testdriver.xml | 40 +++++++++++++++++++
|
|
|
7c1349 |
tests/test_cli.py | 3 ++
|
|
|
7c1349 |
tests/test_nodedev.py | 30 ++++++++++++++
|
|
|
7c1349 |
virtinst/devices/hostdev.py | 36 ++++++++++++++++-
|
|
|
7c1349 |
virtinst/nodedev.py | 4 ++
|
|
|
7c1349 |
6 files changed, 131 insertions(+), 1 deletion(-)
|
|
|
7c1349 |
|
|
|
7c1349 |
diff --git a/tests/data/cli/compare/virt-install-many-devices.xml b/tests/data/cli/compare/virt-install-many-devices.xml
|
|
|
7c1349 |
index 49e9dcc7..3bd756b3 100644
|
|
|
7c1349 |
--- a/tests/data/cli/compare/virt-install-many-devices.xml
|
|
|
7c1349 |
+++ b/tests/data/cli/compare/virt-install-many-devices.xml
|
|
|
7c1349 |
@@ -592,6 +592,25 @@
|
|
|
7c1349 |
<char>/dev/pty7</char>
|
|
|
7c1349 |
</source>
|
|
|
7c1349 |
</hostdev>
|
|
|
7c1349 |
+ <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ccw">
|
|
|
7c1349 |
+ <address type="ccw" cssid="0xfe" ssid="0x1" devno="0x0008"/>
|
|
|
7c1349 |
+ <source>
|
|
|
7c1349 |
+ <address uuid="8e37ee90-2b51-45e3-9b25-bf8283c03110"/>
|
|
|
7c1349 |
+ </source>
|
|
|
7c1349 |
+ </hostdev>
|
|
|
7c1349 |
+ <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ap">
|
|
|
7c1349 |
+ <source>
|
|
|
7c1349 |
+ <address uuid="11f92c9d-b0b0-4016-b306-a8071277f8b9"/>
|
|
|
7c1349 |
+ </source>
|
|
|
7c1349 |
+ </hostdev>
|
|
|
7c1349 |
+ <hostdev mode="subsystem" type="mdev" managed="yes" model="vfio-pci" display="off" ramfb="off">
|
|
|
7c1349 |
+ <address type="pci" domain="0" bus="1" slot="1" function="0">
|
|
|
7c1349 |
+ <zpci uid="0x0001" fid="0x00000001"/>
|
|
|
7c1349 |
+ </address>
|
|
|
7c1349 |
+ <source>
|
|
|
7c1349 |
+ <address uuid="4b20d080-1b54-4048-85b3-a6a62d165c01"/>
|
|
|
7c1349 |
+ </source>
|
|
|
7c1349 |
+ </hostdev>
|
|
|
7c1349 |
<redirdev bus="usb" type="spicevmc"/>
|
|
|
7c1349 |
<redirdev bus="usb" type="tcp">
|
|
|
7c1349 |
<source host="localhost" service="4000"/>
|
|
|
7c1349 |
diff --git a/tests/data/testdriver/testdriver.xml b/tests/data/testdriver/testdriver.xml
|
|
|
7c1349 |
index ea90f0f7..b8d67bac 100644
|
|
|
7c1349 |
--- a/tests/data/testdriver/testdriver.xml
|
|
|
7c1349 |
+++ b/tests/data/testdriver/testdriver.xml
|
|
|
7c1349 |
@@ -3645,5 +3645,45 @@ ba</description>
|
|
|
7c1349 |
</capability>
|
|
|
7c1349 |
</device>
|
|
|
7c1349 |
|
|
|
7c1349 |
+<device>
|
|
|
7c1349 |
+ <name>mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110</name>
|
|
|
7c1349 |
+ <path>/sys/devices/css0/0.0.0023/8e37ee90-2b51-45e3-9b25-bf8283c03110</path>
|
|
|
7c1349 |
+ <parent>css_0_0_0023</parent>
|
|
|
7c1349 |
+ <driver>
|
|
|
7c1349 |
+ <name>vfio_mdev</name>
|
|
|
7c1349 |
+ </driver>
|
|
|
7c1349 |
+ <capability type='mdev'>
|
|
|
7c1349 |
+ <type id='vfio_ccw-io'/>
|
|
|
7c1349 |
+ <iommuGroup number='0'/>
|
|
|
7c1349 |
+ </capability>
|
|
|
7c1349 |
+</device>
|
|
|
7c1349 |
+
|
|
|
7c1349 |
+<device>
|
|
|
7c1349 |
+ <name>mdev_11f92c9d_b0b0_4016_b306_a8071277f8b9</name>
|
|
|
7c1349 |
+ <path>/sys/devices/vfio_ap/matrix/11f92c9d-b0b0-4016-b306-a8071277f8b9</path>
|
|
|
7c1349 |
+ <parent>ap_matrix</parent>
|
|
|
7c1349 |
+ <driver>
|
|
|
7c1349 |
+ <name>vfio_mdev</name>
|
|
|
7c1349 |
+ </driver>
|
|
|
7c1349 |
+ <capability type='mdev'>
|
|
|
7c1349 |
+ <type id='vfio_ap-passthrough'/>
|
|
|
7c1349 |
+ <iommuGroup number='2'/>
|
|
|
7c1349 |
+ <attr name='assign_adapter' value='1'/>
|
|
|
7c1349 |
+ <attr name='assign_domain' value='2'/>
|
|
|
7c1349 |
+ </capability>
|
|
|
7c1349 |
+</device>
|
|
|
7c1349 |
+
|
|
|
7c1349 |
+<device>
|
|
|
7c1349 |
+ <name>mdev_4b20d080_1b54_4048_85b3_a6a62d165c01</name>
|
|
|
7c1349 |
+ <path>/sys/devices/pci0000:00/0000:00:02.0/4b20d080-1b54-4048-85b3-a6a62d165c01</path>
|
|
|
7c1349 |
+ <parent>pci_0000_06_00_0</parent>
|
|
|
7c1349 |
+ <driver>
|
|
|
7c1349 |
+ <name>vfio_mdev</name>
|
|
|
7c1349 |
+ </driver>
|
|
|
7c1349 |
+ <capability type='mdev'>
|
|
|
7c1349 |
+ <type id='nvidia-11'/>
|
|
|
7c1349 |
+ <iommuGroup number='12'/>
|
|
|
7c1349 |
+ </capability>
|
|
|
7c1349 |
+</device>
|
|
|
7c1349 |
|
|
|
7c1349 |
</node>
|
|
|
7c1349 |
diff --git a/tests/test_cli.py b/tests/test_cli.py
|
|
|
7c1349 |
index 5b174933..5f94e009 100644
|
|
|
7c1349 |
--- a/tests/test_cli.py
|
|
|
7c1349 |
+++ b/tests/test_cli.py
|
|
|
7c1349 |
@@ -675,6 +675,9 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
|
|
|
7c1349 |
--hostdev wlan0,type=net
|
|
|
7c1349 |
--hostdev /dev/vdz,type=storage
|
|
|
7c1349 |
--hostdev /dev/pty7,type=misc
|
|
|
7c1349 |
+--hostdev mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110,address.type=ccw,address.cssid=0xfe,address.ssid=0x1,address.devno=0x0008
|
|
|
7c1349 |
+--hostdev mdev_11f92c9d_b0b0_4016_b306_a8071277f8b9
|
|
|
7c1349 |
+--hostdev mdev_4b20d080_1b54_4048_85b3_a6a62d165c01,address.type=pci,address.domain=0x0000,address.bus=0x01,address.slot=0x01,address.function=0x0,address.zpci.uid=0x0001,address.zpci.fid=0x00000001
|
|
|
7c1349 |
|
|
|
7c1349 |
|
|
|
7c1349 |
--filesystem /source,/target,alias.name=testfsalias,driver.ats=on,driver.iommu=off,driver.packed=on
|
|
|
7c1349 |
diff --git a/tests/test_nodedev.py b/tests/test_nodedev.py
|
|
|
7c1349 |
index 406e321f..79678bc8 100644
|
|
|
7c1349 |
--- a/tests/test_nodedev.py
|
|
|
7c1349 |
+++ b/tests/test_nodedev.py
|
|
|
7c1349 |
@@ -126,6 +126,36 @@ def testDRMDevice():
|
|
|
7c1349 |
assert dev.get_devnode("frob")
|
|
|
7c1349 |
|
|
|
7c1349 |
|
|
|
7c1349 |
+def testDASDMdev():
|
|
|
7c1349 |
+ conn = utils.URIs.open_testdriver_cached()
|
|
|
7c1349 |
+ devname = "mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110"
|
|
|
7c1349 |
+ dev = _nodeDevFromName(conn, devname)
|
|
|
7c1349 |
+ assert dev.name == devname
|
|
|
7c1349 |
+ assert dev.parent == "css_0_0_0023"
|
|
|
7c1349 |
+ assert dev.device_type == "mdev"
|
|
|
7c1349 |
+ assert dev.type_id == "vfio_ccw-io"
|
|
|
7c1349 |
+
|
|
|
7c1349 |
+
|
|
|
7c1349 |
+def testAPQNMdev():
|
|
|
7c1349 |
+ conn = utils.URIs.open_testdriver_cached()
|
|
|
7c1349 |
+ devname = "mdev_11f92c9d_b0b0_4016_b306_a8071277f8b9"
|
|
|
7c1349 |
+ dev = _nodeDevFromName(conn, devname)
|
|
|
7c1349 |
+ assert dev.name == devname
|
|
|
7c1349 |
+ assert dev.parent == "ap_matrix"
|
|
|
7c1349 |
+ assert dev.device_type == "mdev"
|
|
|
7c1349 |
+ assert dev.type_id == "vfio_ap-passthrough"
|
|
|
7c1349 |
+
|
|
|
7c1349 |
+
|
|
|
7c1349 |
+def testPCIMdev():
|
|
|
7c1349 |
+ conn = utils.URIs.open_testdriver_cached()
|
|
|
7c1349 |
+ devname = "mdev_4b20d080_1b54_4048_85b3_a6a62d165c01"
|
|
|
7c1349 |
+ dev = _nodeDevFromName(conn, devname)
|
|
|
7c1349 |
+ assert dev.name == devname
|
|
|
7c1349 |
+ assert dev.parent == "pci_0000_06_00_0"
|
|
|
7c1349 |
+ assert dev.device_type == "mdev"
|
|
|
7c1349 |
+ assert dev.type_id == "nvidia-11"
|
|
|
7c1349 |
+
|
|
|
7c1349 |
+
|
|
|
7c1349 |
# NodeDevice 2 Device XML tests
|
|
|
7c1349 |
|
|
|
7c1349 |
def testNodeDev2USB1():
|
|
|
7c1349 |
diff --git a/virtinst/devices/hostdev.py b/virtinst/devices/hostdev.py
|
|
|
7c1349 |
index 3e9de2ad..e8d0fae2 100644
|
|
|
7c1349 |
--- a/virtinst/devices/hostdev.py
|
|
|
7c1349 |
+++ b/virtinst/devices/hostdev.py
|
|
|
7c1349 |
@@ -4,6 +4,8 @@
|
|
|
7c1349 |
# This work is licensed under the GNU GPLv2 or later.
|
|
|
7c1349 |
# See the COPYING file in the top-level directory.
|
|
|
7c1349 |
|
|
|
7c1349 |
+import re
|
|
|
7c1349 |
+
|
|
|
7c1349 |
from .device import Device
|
|
|
7c1349 |
from ..nodedev import NodeDevice
|
|
|
7c1349 |
from ..xmlbuilder import XMLProperty
|
|
|
7c1349 |
@@ -53,16 +55,45 @@ class DeviceHostdev(Device):
|
|
|
7c1349 |
self.scsi_unit = nodedev.lun
|
|
|
7c1349 |
self.managed = False
|
|
|
7c1349 |
|
|
|
7c1349 |
+ elif nodedev.device_type == nodedev.CAPABILITY_TYPE_MDEV:
|
|
|
7c1349 |
+ self.type = "mdev"
|
|
|
7c1349 |
+
|
|
|
7c1349 |
+ if nodedev.type_id == "vfio_ccw-io":
|
|
|
7c1349 |
+ self.model = "vfio-ccw"
|
|
|
7c1349 |
+ self.managed = "no"
|
|
|
7c1349 |
+
|
|
|
7c1349 |
+ elif nodedev.type_id == "vfio_ap-passthrough":
|
|
|
7c1349 |
+ self.model = "vfio-ap"
|
|
|
7c1349 |
+ self.managed = "no"
|
|
|
7c1349 |
+
|
|
|
7c1349 |
+ elif (re.match("^nvidia-[0-9]{2}", nodedev.type_id) or
|
|
|
7c1349 |
+ re.match("^i915-GVTg_V[0-9]_[0-9]", nodedev.type_id)):
|
|
|
7c1349 |
+ self.model = "vfio-pci"
|
|
|
7c1349 |
+ self.managed = "yes"
|
|
|
7c1349 |
+ self.display = "off"
|
|
|
7c1349 |
+ self.ramfb = "off"
|
|
|
7c1349 |
+
|
|
|
7c1349 |
+ else:
|
|
|
7c1349 |
+ raise ValueError( # pragma: no cover
|
|
|
7c1349 |
+ _("Don't know how to generate nodedev for mdev type id '%s'") %
|
|
|
7c1349 |
+ nodedev.type_id)
|
|
|
7c1349 |
+
|
|
|
7c1349 |
+ self.uuid = nodedev.name[5:].replace('_', '-')
|
|
|
7c1349 |
+
|
|
|
7c1349 |
else:
|
|
|
7c1349 |
raise ValueError(_("Unknown node device type %s") % nodedev)
|
|
|
7c1349 |
|
|
|
7c1349 |
|
|
|
7c1349 |
_XML_PROP_ORDER = ["mode", "type", "managed", "vendor", "product",
|
|
|
7c1349 |
- "domain", "bus", "slot", "function"]
|
|
|
7c1349 |
+ "domain", "bus", "slot", "function", "model",
|
|
|
7c1349 |
+ "display", "ramfb"]
|
|
|
7c1349 |
|
|
|
7c1349 |
mode = XMLProperty("./@mode")
|
|
|
7c1349 |
type = XMLProperty("./@type")
|
|
|
7c1349 |
managed = XMLProperty("./@managed", is_yesno=True)
|
|
|
7c1349 |
+ model = XMLProperty("./@model")
|
|
|
7c1349 |
+ display = XMLProperty("./@display")
|
|
|
7c1349 |
+ ramfb = XMLProperty("./@ramfb")
|
|
|
7c1349 |
|
|
|
7c1349 |
vendor = XMLProperty("./source/vendor/@id")
|
|
|
7c1349 |
product = XMLProperty("./source/product/@id")
|
|
|
7c1349 |
@@ -92,6 +123,9 @@ class DeviceHostdev(Device):
|
|
|
7c1349 |
# type=misc handling
|
|
|
7c1349 |
storage_block = XMLProperty("./source/block")
|
|
|
7c1349 |
|
|
|
7c1349 |
+ # type=mdev
|
|
|
7c1349 |
+ uuid = XMLProperty("./source/address/@uuid")
|
|
|
7c1349 |
+
|
|
|
7c1349 |
|
|
|
7c1349 |
##################
|
|
|
7c1349 |
# Default config #
|
|
|
7c1349 |
diff --git a/virtinst/nodedev.py b/virtinst/nodedev.py
|
|
|
7c1349 |
index 9d2c8f10..97841794 100644
|
|
|
7c1349 |
--- a/virtinst/nodedev.py
|
|
|
7c1349 |
+++ b/virtinst/nodedev.py
|
|
|
7c1349 |
@@ -40,6 +40,7 @@ class NodeDevice(XMLBuilder):
|
|
|
7c1349 |
CAPABILITY_TYPE_SCSIBUS = "scsi_host"
|
|
|
7c1349 |
CAPABILITY_TYPE_SCSIDEV = "scsi"
|
|
|
7c1349 |
CAPABILITY_TYPE_DRM = "drm"
|
|
|
7c1349 |
+ CAPABILITY_TYPE_MDEV = "mdev"
|
|
|
7c1349 |
|
|
|
7c1349 |
@staticmethod
|
|
|
7c1349 |
def lookupNodedevFromString(conn, idstring):
|
|
|
7c1349 |
@@ -168,6 +169,9 @@ class NodeDevice(XMLBuilder):
|
|
|
7c1349 |
if len(self.devnodes) > 0:
|
|
|
7c1349 |
return self.devnodes[0]
|
|
|
7c1349 |
|
|
|
7c1349 |
+ # type='mdev' options
|
|
|
7c1349 |
+ type_id = XMLProperty("./capability/type/@id")
|
|
|
7c1349 |
+
|
|
|
7c1349 |
|
|
|
7c1349 |
def _AddressStringToHostdev(conn, addrstr):
|
|
|
7c1349 |
from .devices import DeviceHostdev
|
|
|
7c1349 |
--
|
|
|
7c1349 |
2.31.1
|
|
|
7c1349 |
|