Blame SOURCES/virt-manager-virt-manager-enable-MDEV-support.patch

7c1349
From bacab3883858b137f82ab2b3dea308289f65138c Mon Sep 17 00:00:00 2001
7c1349
From: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
7c1349
Date: Mon, 7 Jun 2021 11:34:21 +0200
7c1349
Subject: [PATCH] virt-manager: enable MDEV support
7c1349
7c1349
Enable virt-manager GUI to support add, edit, remove, hot-plug and
7c1349
hot-unplug of mediated devices (like DASDs, APQNs and PCIs) in virtual
7c1349
server.
7c1349
7c1349
It is not possible to edit MDEV when a virtual server is in
7c1349
running state, as this is not supported by libvirt.
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 0e15cd51dfbdaa09f7d34ed1edce2f5416130361)
7c1349
7c1349
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1995125
7c1349
7c1349
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
7c1349
---
7c1349
 tests/data/testdriver/testdriver.xml | 39 ++++++++++++++++++++++++++++
7c1349
 tests/uitests/test_addhardware.py    |  6 +++++
7c1349
 virtManager/addhardware.py           | 19 +++++++++++++-
7c1349
 3 files changed, 63 insertions(+), 1 deletion(-)
7c1349
7c1349
diff --git a/tests/data/testdriver/testdriver.xml b/tests/data/testdriver/testdriver.xml
7c1349
index b8d67bac..5875732a 100644
7c1349
--- a/tests/data/testdriver/testdriver.xml
7c1349
+++ b/tests/data/testdriver/testdriver.xml
7c1349
@@ -3645,6 +3645,27 @@ ba</description>
7c1349
   </capability>
7c1349
 </device>
7c1349
 
7c1349
+<device>
7c1349
+  <name>css_0_0_0023</name>
7c1349
+  <path>/sys/devices/css0/0.0.0023</path>
7c1349
+  <parent>computer</parent>
7c1349
+  <driver>
7c1349
+    <name>vfio_ccw</name>
7c1349
+  </driver>
7c1349
+  <capability type='css'>
7c1349
+    <cssid>0x0</cssid>
7c1349
+    <ssid>0x0</ssid>
7c1349
+    <devno>0x0023</devno>
7c1349
+    <capability type='mdev_types'>
7c1349
+      <type id='vfio_ccw-io'>
7c1349
+        <name>I/O subchannel (Non-QDIO)</name>
7c1349
+        <deviceAPI>vfio-ccw</deviceAPI>
7c1349
+        <availableInstances>0</availableInstances>
7c1349
+      </type>
7c1349
+    </capability>
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
@@ -3658,6 +3679,24 @@ ba</description>
7c1349
   </capability>
7c1349
 </device>
7c1349
 
7c1349
+<device>
7c1349
+  <name>ap_matrix</name>
7c1349
+  <path>/sys/devices/vfio_ap/matrix</path>
7c1349
+  <parent>computer</parent>
7c1349
+  <driver>
7c1349
+    <name>vfio_ap</name>
7c1349
+  </driver>
7c1349
+  <capability type='ap_matrix'>
7c1349
+    <capability type='mdev_types'>
7c1349
+      <type id='vfio_ap-passthrough'>
7c1349
+        <name>VFIO AP Passthrough Device</name>
7c1349
+        <deviceAPI>vfio-ap</deviceAPI>
7c1349
+        <availableInstances>65536</availableInstances>
7c1349
+      </type>
7c1349
+    </capability>
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
diff --git a/tests/uitests/test_addhardware.py b/tests/uitests/test_addhardware.py
7c1349
index ce3da57c..56acc2fa 100644
7c1349
--- a/tests/uitests/test_addhardware.py
7c1349
+++ b/tests/uitests/test_addhardware.py
7c1349
@@ -459,6 +459,12 @@ def testAddHosts(app):
7c1349
     app.click_alert_button("device is already in use by", "Yes")
7c1349
     lib.utils.check(lambda: details.active)
7c1349
 
7c1349
+    # Add MDEV device
7c1349
+    _open_addhw(app, details)
7c1349
+    tab = _select_hw(addhw, "MDEV Host Device", "host-tab")
7c1349
+    tab.find_fuzzy("mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110",
7c1349
+                   "table cell").click()
7c1349
+    _finish(addhw, check=details)
7c1349
 
7c1349
 
7c1349
 def testAddChars(app):
7c1349
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
7c1349
index cbf19f58..13b899c3 100644
7c1349
--- a/virtManager/addhardware.py
7c1349
+++ b/virtManager/addhardware.py
7c1349
@@ -249,6 +249,10 @@ class vmmAddHardware(vmmGObjectUI):
7c1349
         add_hw_option(_("PCI Host Device"), "system-run", PAGE_HOSTDEV,
7c1349
                       nodedev_enabled, nodedev_errstr, "pci")
7c1349
 
7c1349
+        add_hw_option(_("MDEV Host Device"), "system-run", PAGE_HOSTDEV,
7c1349
+                      self.conn.support.conn_nodedev(),
7c1349
+                      _("Connection does not support host device enumeration"),
7c1349
+                      "mdev")
7c1349
         add_hw_option(_("Video"), "video-display", PAGE_VIDEO, True,
7c1349
                       _("Libvirt version does not support video devices."))
7c1349
         add_hw_option(_("Watchdog"), "device_pci", PAGE_WATCHDOG,
7c1349
@@ -656,6 +660,9 @@ class vmmAddHardware(vmmGObjectUI):
7c1349
                       (dehex(hostdev.domain), dehex(hostdev.bus),
7c1349
                        dehex(hostdev.slot), dehex(hostdev.function)))
7c1349
 
7c1349
+        elif hostdev.uuid:
7c1349
+            label += " %s" % (str(hostdev.uuid))
7c1349
+
7c1349
         return label
7c1349
 
7c1349
 
7c1349
@@ -775,6 +782,12 @@ class vmmAddHardware(vmmGObjectUI):
7c1349
                     if dev.xmlobj.name == subdev.xmlobj.parent:
7c1349
                         prettyname += " (%s)" % subdev.pretty_name()
7c1349
 
7c1349
+            if devtype == "mdev":
7c1349
+                for parentdev in self.conn.list_nodedevs():
7c1349
+                    if dev.xmlobj.parent == parentdev.xmlobj.name:
7c1349
+                        prettyname = "%s %s" % (
7c1349
+                                parentdev.pretty_name(), prettyname)
7c1349
+
7c1349
             model.append([dev.xmlobj, prettyname])
7c1349
 
7c1349
         if len(model) == 0:
7c1349
@@ -981,11 +994,13 @@ class vmmAddHardware(vmmGObjectUI):
7c1349
 
7c1349
         if page == PAGE_HOSTDEV:
7c1349
             # Need to do this here, since we share the hostdev page
7c1349
-            # between two different HW options
7c1349
+            # between different HW options
7c1349
             row = self._get_hw_selection()
7c1349
             devtype = "usb_device"
7c1349
             if row and row[5] == "pci":
7c1349
                 devtype = "pci"
7c1349
+            if row and row[5] == "mdev":
7c1349
+                devtype = "mdev"
7c1349
             self._populate_hostdev_model(devtype)
7c1349
 
7c1349
         if page == PAGE_CONTROLLER:
7c1349
@@ -1036,6 +1051,8 @@ class vmmAddHardware(vmmGObjectUI):
7c1349
             row = self._get_hw_selection()
7c1349
             if row and row[5] == "pci":
7c1349
                 return _("PCI Device")
7c1349
+            if row and row[5] == "mdev":
7c1349
+                return _("MDEV Device")
7c1349
             return _("USB Device")
7c1349
 
7c1349
         raise RuntimeError("Unknown page %s" % page)  # pragma: no cover
7c1349
-- 
7c1349
2.31.1
7c1349