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