443cf65c8c
965480e8-virt-install-add-mediated-device.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/virt-manager?expand=0&rev=547
241 lines
8.6 KiB
Diff
241 lines
8.6 KiB
Diff
Subject: virt-install: add mediated device
|
|
From: Shalini Chellathurai Saroja shalini@linux.ibm.com Wed Apr 14 17:18:55 2021 +0200
|
|
Date: Tue May 18 18:36:03 2021 -0400:
|
|
Git: 965480e8bc85caf8a4f36b4a2f07963067b63cf6
|
|
|
|
Add support to install a virtual server with passed-through mediated
|
|
device. Mediated device can be created using vGPU attached to
|
|
vfio_pci driver or DASD attached to vfio_ccw driver or APQNs attached
|
|
to vfio_ap driver.
|
|
|
|
Reviewed-by: Cole Robinson <crobinso@redhat.com>
|
|
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
|
|
|
|
Index: virt-manager-3.2.0/tests/data/cli/compare/virt-install-many-devices.xml
|
|
===================================================================
|
|
--- virt-manager-3.2.0.orig/tests/data/cli/compare/virt-install-many-devices.xml
|
|
+++ virt-manager-3.2.0/tests/data/cli/compare/virt-install-many-devices.xml
|
|
@@ -592,6 +592,25 @@
|
|
<char>/dev/pty7</char>
|
|
</source>
|
|
</hostdev>
|
|
+ <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ccw">
|
|
+ <address type="ccw" cssid="0xfe" ssid="0x1" devno="0x0008"/>
|
|
+ <source>
|
|
+ <address uuid="8e37ee90-2b51-45e3-9b25-bf8283c03110"/>
|
|
+ </source>
|
|
+ </hostdev>
|
|
+ <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ap">
|
|
+ <source>
|
|
+ <address uuid="11f92c9d-b0b0-4016-b306-a8071277f8b9"/>
|
|
+ </source>
|
|
+ </hostdev>
|
|
+ <hostdev mode="subsystem" type="mdev" managed="yes" model="vfio-pci" display="off" ramfb="off">
|
|
+ <address type="pci" domain="0" bus="1" slot="1" function="0">
|
|
+ <zpci uid="0x0001" fid="0x00000001"/>
|
|
+ </address>
|
|
+ <source>
|
|
+ <address uuid="4b20d080-1b54-4048-85b3-a6a62d165c01"/>
|
|
+ </source>
|
|
+ </hostdev>
|
|
<redirdev bus="usb" type="spicevmc"/>
|
|
<redirdev bus="usb" type="tcp">
|
|
<source host="localhost" service="4000"/>
|
|
Index: virt-manager-3.2.0/tests/data/testdriver/testdriver.xml
|
|
===================================================================
|
|
--- virt-manager-3.2.0.orig/tests/data/testdriver/testdriver.xml
|
|
+++ virt-manager-3.2.0/tests/data/testdriver/testdriver.xml
|
|
@@ -3645,5 +3645,45 @@ ba</description>
|
|
</capability>
|
|
</device>
|
|
|
|
+<device>
|
|
+ <name>mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110</name>
|
|
+ <path>/sys/devices/css0/0.0.0023/8e37ee90-2b51-45e3-9b25-bf8283c03110</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>
|
|
+
|
|
+<device>
|
|
+ <name>mdev_11f92c9d_b0b0_4016_b306_a8071277f8b9</name>
|
|
+ <path>/sys/devices/vfio_ap/matrix/11f92c9d-b0b0-4016-b306-a8071277f8b9</path>
|
|
+ <parent>ap_matrix</parent>
|
|
+ <driver>
|
|
+ <name>vfio_mdev</name>
|
|
+ </driver>
|
|
+ <capability type='mdev'>
|
|
+ <type id='vfio_ap-passthrough'/>
|
|
+ <iommuGroup number='2'/>
|
|
+ <attr name='assign_adapter' value='1'/>
|
|
+ <attr name='assign_domain' value='2'/>
|
|
+ </capability>
|
|
+</device>
|
|
+
|
|
+<device>
|
|
+ <name>mdev_4b20d080_1b54_4048_85b3_a6a62d165c01</name>
|
|
+ <path>/sys/devices/pci0000:00/0000:00:02.0/4b20d080-1b54-4048-85b3-a6a62d165c01</path>
|
|
+ <parent>pci_0000_06_00_0</parent>
|
|
+ <driver>
|
|
+ <name>vfio_mdev</name>
|
|
+ </driver>
|
|
+ <capability type='mdev'>
|
|
+ <type id='nvidia-11'/>
|
|
+ <iommuGroup number='12'/>
|
|
+ </capability>
|
|
+</device>
|
|
|
|
</node>
|
|
Index: virt-manager-3.2.0/tests/test_cli.py
|
|
===================================================================
|
|
--- virt-manager-3.2.0.orig/tests/test_cli.py
|
|
+++ virt-manager-3.2.0/tests/test_cli.py
|
|
@@ -675,6 +675,9 @@ source.reservations.managed=no,source.re
|
|
--hostdev wlan0,type=net
|
|
--hostdev /dev/vdz,type=storage
|
|
--hostdev /dev/pty7,type=misc
|
|
+--hostdev mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110,address.type=ccw,address.cssid=0xfe,address.ssid=0x1,address.devno=0x0008
|
|
+--hostdev mdev_11f92c9d_b0b0_4016_b306_a8071277f8b9
|
|
+--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
|
|
|
|
|
|
--filesystem /source,/target,alias.name=testfsalias,driver.ats=on,driver.iommu=off,driver.packed=on
|
|
Index: virt-manager-3.2.0/tests/test_nodedev.py
|
|
===================================================================
|
|
--- virt-manager-3.2.0.orig/tests/test_nodedev.py
|
|
+++ virt-manager-3.2.0/tests/test_nodedev.py
|
|
@@ -126,6 +126,36 @@ def testDRMDevice():
|
|
assert dev.get_devnode("frob")
|
|
|
|
|
|
+def testDASDMdev():
|
|
+ conn = utils.URIs.open_testdriver_cached()
|
|
+ devname = "mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110"
|
|
+ dev = _nodeDevFromName(conn, devname)
|
|
+ assert dev.name == devname
|
|
+ assert dev.parent == "css_0_0_0023"
|
|
+ assert dev.device_type == "mdev"
|
|
+ assert dev.type_id == "vfio_ccw-io"
|
|
+
|
|
+
|
|
+def testAPQNMdev():
|
|
+ conn = utils.URIs.open_testdriver_cached()
|
|
+ devname = "mdev_11f92c9d_b0b0_4016_b306_a8071277f8b9"
|
|
+ dev = _nodeDevFromName(conn, devname)
|
|
+ assert dev.name == devname
|
|
+ assert dev.parent == "ap_matrix"
|
|
+ assert dev.device_type == "mdev"
|
|
+ assert dev.type_id == "vfio_ap-passthrough"
|
|
+
|
|
+
|
|
+def testPCIMdev():
|
|
+ conn = utils.URIs.open_testdriver_cached()
|
|
+ devname = "mdev_4b20d080_1b54_4048_85b3_a6a62d165c01"
|
|
+ dev = _nodeDevFromName(conn, devname)
|
|
+ assert dev.name == devname
|
|
+ assert dev.parent == "pci_0000_06_00_0"
|
|
+ assert dev.device_type == "mdev"
|
|
+ assert dev.type_id == "nvidia-11"
|
|
+
|
|
+
|
|
# NodeDevice 2 Device XML tests
|
|
|
|
def testNodeDev2USB1():
|
|
Index: virt-manager-3.2.0/virtinst/devices/hostdev.py
|
|
===================================================================
|
|
--- virt-manager-3.2.0.orig/virtinst/devices/hostdev.py
|
|
+++ virt-manager-3.2.0/virtinst/devices/hostdev.py
|
|
@@ -4,6 +4,8 @@
|
|
# This work is licensed under the GNU GPLv2 or later.
|
|
# See the COPYING file in the top-level directory.
|
|
|
|
+import re
|
|
+
|
|
from .device import Device
|
|
from ..nodedev import NodeDevice
|
|
from ..xmlbuilder import XMLProperty
|
|
@@ -53,16 +55,45 @@ class DeviceHostdev(Device):
|
|
self.scsi_unit = nodedev.lun
|
|
self.managed = False
|
|
|
|
+ elif nodedev.device_type == nodedev.CAPABILITY_TYPE_MDEV:
|
|
+ self.type = "mdev"
|
|
+
|
|
+ if nodedev.type_id == "vfio_ccw-io":
|
|
+ self.model = "vfio-ccw"
|
|
+ self.managed = "no"
|
|
+
|
|
+ elif nodedev.type_id == "vfio_ap-passthrough":
|
|
+ self.model = "vfio-ap"
|
|
+ self.managed = "no"
|
|
+
|
|
+ elif (re.match("^nvidia-[0-9]{2}", nodedev.type_id) or
|
|
+ re.match("^i915-GVTg_V[0-9]_[0-9]", nodedev.type_id)):
|
|
+ self.model = "vfio-pci"
|
|
+ self.managed = "yes"
|
|
+ self.display = "off"
|
|
+ self.ramfb = "off"
|
|
+
|
|
+ else:
|
|
+ raise ValueError( # pragma: no cover
|
|
+ _("Don't know how to generate nodedev for mdev type id '%s'") %
|
|
+ nodedev.type_id)
|
|
+
|
|
+ self.uuid = nodedev.name[5:].replace('_', '-')
|
|
+
|
|
else:
|
|
raise ValueError(_("Unknown node device type %s") % nodedev)
|
|
|
|
|
|
_XML_PROP_ORDER = ["mode", "type", "managed", "vendor", "product",
|
|
- "domain", "bus", "slot", "function"]
|
|
+ "domain", "bus", "slot", "function", "model",
|
|
+ "display", "ramfb"]
|
|
|
|
mode = XMLProperty("./@mode")
|
|
type = XMLProperty("./@type")
|
|
managed = XMLProperty("./@managed", is_yesno=True)
|
|
+ model = XMLProperty("./@model")
|
|
+ display = XMLProperty("./@display")
|
|
+ ramfb = XMLProperty("./@ramfb")
|
|
|
|
vendor = XMLProperty("./source/vendor/@id")
|
|
product = XMLProperty("./source/product/@id")
|
|
@@ -92,6 +123,9 @@ class DeviceHostdev(Device):
|
|
# type=misc handling
|
|
storage_block = XMLProperty("./source/block")
|
|
|
|
+ # type=mdev
|
|
+ uuid = XMLProperty("./source/address/@uuid")
|
|
+
|
|
|
|
##################
|
|
# Default config #
|
|
Index: virt-manager-3.2.0/virtinst/nodedev.py
|
|
===================================================================
|
|
--- virt-manager-3.2.0.orig/virtinst/nodedev.py
|
|
+++ virt-manager-3.2.0/virtinst/nodedev.py
|
|
@@ -40,6 +40,7 @@ class NodeDevice(XMLBuilder):
|
|
CAPABILITY_TYPE_SCSIBUS = "scsi_host"
|
|
CAPABILITY_TYPE_SCSIDEV = "scsi"
|
|
CAPABILITY_TYPE_DRM = "drm"
|
|
+ CAPABILITY_TYPE_MDEV = "mdev"
|
|
|
|
@staticmethod
|
|
def lookupNodedevFromString(conn, idstring):
|
|
@@ -168,6 +169,9 @@ class NodeDevice(XMLBuilder):
|
|
if len(self.devnodes) > 0:
|
|
return self.devnodes[0]
|
|
|
|
+ # type='mdev' options
|
|
+ type_id = XMLProperty("./capability/type/@id")
|
|
+
|
|
|
|
def _AddressStringToHostdev(conn, addrstr):
|
|
from .devices import DeviceHostdev
|