Accepting request 946226 from Virtualization

Upstream patches added for jsc#SLE-20855 KVM: Enable vfio-ccw and vfio-ap in virt-* tools.

OBS-URL: https://build.opensuse.org/request/show/946226
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/virt-manager?expand=0&rev=228
This commit is contained in:
Dominique Leuenberger 2022-01-15 20:45:06 +00:00 committed by Git OBS Bridge
commit 1e55bee4d7
8 changed files with 455 additions and 9 deletions

View File

@ -0,0 +1,151 @@
Subject: virt-manager: enable MDEV support
From: Shalini Chellathurai Saroja shalini@linux.ibm.com Mon Jun 7 11:34:21 2021 +0200
Date: Tue Jun 8 09:58:50 2021 -0400:
Git: 0e15cd51dfbdaa09f7d34ed1edce2f5416130361
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 <crobinso@redhat.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
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</description>
</capability>
</device>
+<device>
+ <name>css_0_0_0023</name>
+ <path>/sys/devices/css0/0.0.0023</path>
+ <parent>computer</parent>
+ <driver>
+ <name>vfio_ccw</name>
+ </driver>
+ <capability type='css'>
+ <cssid>0x0</cssid>
+ <ssid>0x0</ssid>
+ <devno>0x0023</devno>
+ <capability type='mdev_types'>
+ <type id='vfio_ccw-io'>
+ <name>I/O subchannel (Non-QDIO)</name>
+ <deviceAPI>vfio-ccw</deviceAPI>
+ <availableInstances>0</availableInstances>
+ </type>
+ </capability>
+ </capability>
+</device>
+
<device>
<name>mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110</name>
<path>/sys/devices/css0/0.0.0023/8e37ee90-2b51-45e3-9b25-bf8283c03110</path>
@@ -3658,6 +3679,24 @@ ba</description>
</capability>
</device>
+<device>
+ <name>ap_matrix</name>
+ <path>/sys/devices/vfio_ap/matrix</path>
+ <parent>computer</parent>
+ <driver>
+ <name>vfio_ap</name>
+ </driver>
+ <capability type='ap_matrix'>
+ <capability type='mdev_types'>
+ <type id='vfio_ap-passthrough'>
+ <name>VFIO AP Passthrough Device</name>
+ <deviceAPI>vfio-ap</deviceAPI>
+ <availableInstances>65536</availableInstances>
+ </type>
+ </capability>
+ </capability>
+</device>
+
<device>
<name>mdev_11f92c9d_b0b0_4016_b306_a8071277f8b9</name>
<path>/sys/devices/vfio_ap/matrix/11f92c9d-b0b0-4016-b306-a8071277f8b9</path>
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

View File

@ -0,0 +1,66 @@
Subject: virt-xml: add support for mediated devices
From: Shalini Chellathurai Saroja shalini@linux.ibm.com Mon May 31 21:54:26 2021 +0200
Date: Tue Jun 1 17:07:36 2021 -0400:
Git: 9363e1e692bb0d01184ecc7991d61c95542f690b
Provide support to add/remove MDEV in a guest domain, which is in
shut-off or running state (hotplug/unplug). Also support update of
already existing MDEV device, when the guest domain is in shut-off
state. Please note that libvirt does not support update of MDEV
device, when the guest domain is in running state.
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
diff --git a/virtinst/nodedev.py b/virtinst/nodedev.py
index 97841794..f54a311c 100644
--- a/virtinst/nodedev.py
+++ b/virtinst/nodedev.py
@@ -5,6 +5,7 @@
# See the COPYING file in the top-level directory.
import os
+import uuid
from .logger import log
from .xmlbuilder import XMLBuilder, XMLProperty, XMLChildProperty
@@ -25,6 +26,16 @@ def _compare_int(nodedev_val, hostdev_val):
return (nodedev_val == hostdev_val or hostdev_val == -1)
+def _compare_uuid(nodedev_val, hostdev_val):
+ try:
+ nodedev_val = uuid.UUID(nodedev_val)
+ hostdev_val = uuid.UUID(hostdev_val)
+ except Exception: # pragma: no cover
+ return -1
+
+ return (nodedev_val == hostdev_val)
+
+
class DevNode(XMLBuilder):
XML_NAME = "devnode"
@@ -82,6 +93,9 @@ class NodeDevice(XMLBuilder):
parent = XMLProperty("./parent")
device_type = XMLProperty("./capability/@type")
+ def get_mdev_uuid(self):
+ return self.name[5:].replace('_', '-')
+
def compare_to_hostdev(self, hostdev):
if self.device_type == "pci":
if hostdev.type != "pci":
@@ -101,6 +115,12 @@ class NodeDevice(XMLBuilder):
_compare_int(self.bus, hostdev.bus) and
_compare_int(self.device, hostdev.device))
+ if self.device_type == "mdev":
+ if hostdev.type != "mdev":
+ return False
+
+ return _compare_uuid(self.get_mdev_uuid(), hostdev.uuid)
+
return False

View File

@ -0,0 +1,185 @@
Subject: tests: verify MDEV support
From: Shalini Chellathurai Saroja shalini@linux.ibm.com Mon May 31 21:54:28 2021 +0200
Date: Tue Jun 1 17:07:36 2021 -0400:
Git: 9d4002ee0f7088c490748ffb3144c006f4e39c68
Add tests to verify add, edit and remove features of mediated
devices.
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
--- /dev/null
+++ b/tests/data/cli/compare/virt-xml-add-hostdev-mdev-start.xml
@@ -0,0 +1,12 @@
+ <model type="cirrus" vram="16384" heads="1" primary="yes"/>
+ </video>
+ <memballoon model="virtio"/>
++ <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ccw">
++ <source>
++ <address uuid="8e37ee90-2b51-45e3-9b25-bf8283c03110"/>
++ </source>
++ </hostdev>
+ </devices>
+ </domain>
+
+Domain 'test-state-shutoff' started successfully.
--- /dev/null
+++ b/tests/data/cli/compare/virt-xml-add-hostdev-mdev.xml
@@ -0,0 +1,14 @@
+ <vsock model="virtio">
+ <cid auto="no" address="5"/>
+ </vsock>
++ <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ccw">
++ <source>
++ <address uuid="8e37ee90-2b51-45e3-9b25-bf8283c03110"/>
++ </source>
++ </hostdev>
+ </devices>
+ <seclabel type="dynamic" model="selinux" relabel="yes"/>
+ <keywrap>
+
+Domain 'test-for-virtxml' defined successfully.
+Changes will take effect after the domain is fully powered off.
--- a/tests/data/cli/compare/virt-xml-edit-all.xml
+++ b/tests/data/cli/compare/virt-xml-edit-all.xml
@@ -10,6 +10,13 @@
<rom bar="off"/>
+ <driver name="vfio"/>
</hostdev>
+ <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ccw">
+ <source>
+ <address uuid="b1ae8bf6-38b0-4c81-9d44-78ce3f520496"/>
+ </source>
+ <address type="ccw" cssid="0xfe" ssid="0x0" devno="0x0002"/>
++ <driver name="vfio"/>
+ </hostdev>
<redirdev bus="usb" type="tcp">
<source mode="connect" host="localhost" service="4000"/>
--- /dev/null
+++ b/tests/data/cli/compare/virt-xml-edit-hostdev-mdev.xml
@@ -0,0 +1,11 @@
+ <source>
+ <address uuid="b1ae8bf6-38b0-4c81-9d44-78ce3f520496"/>
+ </source>
+- <address type="ccw" cssid="0xfe" ssid="0x0" devno="0x0002"/>
++ <address type="ccw" cssid="0xfe" ssid="0x0" devno="0x0008"/>
+ </hostdev>
+ <redirdev bus="usb" type="tcp">
+ <source mode="connect" host="localhost" service="4000"/>
+
+Domain 'test-for-virtxml' defined successfully.
+Changes will take effect after the domain is fully powered off.
--- a/tests/data/cli/compare/virt-xml-edit-simple-redirdev.xml
+++ b/tests/data/cli/compare/virt-xml-edit-simple-redirdev.xml
@@ -1,5 +1,5 @@
</source>
- <rom bar="off"/>
+ <address type="ccw" cssid="0xfe" ssid="0x0" devno="0x0002"/>
</hostdev>
- <redirdev bus="usb" type="tcp">
- <source mode="connect" host="localhost" service="4000"/>
--- /dev/null
+++ b/tests/data/cli/compare/virt-xml-remove-hostdev-mdev.xml
@@ -0,0 +1,15 @@
+ </source>
+ <rom bar="off"/>
+ </hostdev>
+- <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ccw">
+- <source>
+- <address uuid="b1ae8bf6-38b0-4c81-9d44-78ce3f520496"/>
+- </source>
+- <address type="ccw" cssid="0xfe" ssid="0x0" devno="0x0002"/>
+- </hostdev>
+ <redirdev bus="usb" type="tcp">
+ <source mode="connect" host="localhost" service="4000"/>
+ <protocol type="raw"/>
+
+Domain 'test-for-virtxml' defined successfully.
+Changes will take effect after the domain is fully powered off.
--- a/tests/data/testdriver/testsuite.xml
+++ b/tests/data/testdriver/testsuite.xml
@@ -259,6 +259,12 @@
</source>
<rom bar='off'/>
</hostdev>
+ <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-ccw">
+ <source>
+ <address uuid="b1ae8bf6-38b0-4c81-9d44-78ce3f520496"/>
+ </source>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0002'/>
+ </hostdev>
<serial type='null'/>
@@ -737,5 +743,31 @@
</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_b1ae8bf6_38b0_4c81_9d44_78ce3f520496</name>
+ <path>/sys/devices/css0/0.0.0023/b1ae8bf6-38b0-4c81-9d44-78ce3f520496</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>
+
</node>
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1274,6 +1274,7 @@ c.add_compare("--edit mac=00:11:7f:33:44
c.add_compare("--edit target=hda --disk boot_order=1", "edit-select-disk-bootorder")
c.add_compare("--edit path=/dev/null --disk path=,target=fdb,boot_order=12", "edit-disk-unset") # --disk matching, using empty value to unset path
c.add_compare("--edit --memballoon none", "edit-disable-memballoon")
+c.add_compare("--edit address.devno=0x0002 --hostdev address.devno=0x0008", "edit-hostdev-mdev")
c = vixml.add_category("edit and start selection", "test-state-shutoff --print-diff --start")
c.add_compare("--define --edit target=vda --disk boot_order=1", "start-select-disk-bootorder")
@@ -1308,6 +1309,8 @@ c.add_compare("--remove-device --disk /d
c.add_compare("--remove-device --video all", "remove-video-all")
c.add_compare("--remove-device --host-device 0x04b3:0x4485", "remove-hostdev-name")
c.add_compare("--remove-device --memballoon all", "remove-memballoon")
+c.add_compare("--add-device --hostdev mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110", "add-hostdev-mdev")
+c.add_compare("--remove-device --hostdev mdev_b1ae8bf6_38b0_4c81_9d44_78ce3f520496", "remove-hostdev-mdev")
c = vixml.add_category("add/rm devices and start", "test-state-shutoff --print-diff --start")
c.add_invalid("--add-device --pm suspend_to_disk=yes") # --add-device without a device
@@ -1318,6 +1321,7 @@ c.add_compare("--define --add-device --h
c.add_compare("--add-device --disk %(EXISTIMG1)s,bus=virtio,target=vdf", "add-disk-basic-start")
c.add_compare("--add-device --disk %(NEWIMG1)s,size=.01", "add-disk-create-storage-start")
c.add_compare("--remove-device --disk /dev/null", "remove-disk-path-start")
+c.add_compare("--add-device --hostdev mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110", "add-hostdev-mdev-start")
c = vixml.add_category("add/rm devices OS KVM", "--connect %(URI-KVM)s test --print-diff --define")
c.add_compare("--add-device --disk %(EXISTIMG1)s", "kvm-add-disk-os-from-xml") # Guest OS (none) from XML
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -231,7 +231,7 @@ def diff_compare(actual_out, filename=No
open(filename, "w").write(actual_out)
expect_out = open(filename).read()
- diff = xmlutil.diff(expect_out, actual_out,
+ diff = xmlutil.diff(expect_out.rstrip(), actual_out.rstrip(),
filename or '', "Generated output")
if diff:
raise AssertionError("Conversion outputs did not match.\n%s" % diff)

View File

@ -0,0 +1,22 @@
Subject: hostdev: use method get_mdev_uuid()
From: Shalini Chellathurai Saroja shalini@linux.ibm.com Mon May 31 21:54:27 2021 +0200
Date: Tue Jun 1 17:07:36 2021 -0400:
Git: f87e96d3d40891f1403601abc389c24800ba1069
Use method get_mdev_uuid() to retrieve the UUID of MDEV node device
object.
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
--- a/virtinst/devices/hostdev.py
+++ b/virtinst/devices/hostdev.py
@@ -78,7 +78,7 @@ class DeviceHostdev(Device):
_("Don't know how to generate nodedev for mdev type id '%s'") %
nodedev.type_id)
- self.uuid = nodedev.name[5:].replace('_', '-')
+ self.uuid = nodedev.get_mdev_uuid()
else:
raise ValueError(_("Unknown node device type %s") % nodedev)

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Thu Jan 13 13:33:50 MST 2022 - carnold@suse.com
- jsc#SLE-20855 KVM: Enable vfio-ccw and vfio-ap in virt-* tools
965480e8-virt-install-add-mediated-device.patch
f87e96d3-hostdev-use-method-get_mdev_uuid.patch
9d4002ee-tests-verify-MDEV-support.patch
9363e1e6-virt-xml-add-support-for-mediated-devices.patch
0e15cd51-virt-manager-enable-MDEV-support.patch
-------------------------------------------------------------------
Tue Nov 23 10:11:44 MST 2021 - carnold@suse.com

View File

@ -1,7 +1,7 @@
#
# spec file for package virt-manager
#
# Copyright (c) 2021 SUSE LLC
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -40,6 +40,10 @@ Patch5: 143c6bef-virtinst-fix-error-message-format-string.patch
Patch6: fe8722e7-createnet-Remove-some-unnecessary-max_length-annotations.patch
Patch7: d9b5090e-Fix-forgetting-password-from-keyring.patch
Patch8: 965480e8-virt-install-add-mediated-device.patch
Patch9: 9363e1e6-virt-xml-add-support-for-mediated-devices.patch
Patch10: f87e96d3-hostdev-use-method-get_mdev_uuid.patch
Patch11: 9d4002ee-tests-verify-MDEV-support.patch
Patch12: 0e15cd51-virt-manager-enable-MDEV-support.patch
# SUSE Only
Patch70: virtman-desktop.patch
Patch71: virtman-kvm.patch
@ -176,6 +180,10 @@ machine).
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
# SUSE Only
%patch70 -p1
%patch71 -p1

View File

@ -1,8 +1,10 @@
References: bsc#1192238, jsc#SLE-17764
--- virt-manager-3.2.0/virtinst/install/urldetect.py.orig 2021-11-23 15:06:47.451081946 -0700
+++ virt-manager-3.2.0/virtinst/install/urldetect.py 2021-11-23 15:07:43.539083283 -0700
@@ -723,6 +723,24 @@ class _OESDistro(_SuseDistro):
Index: virt-manager-3.2.0/virtinst/install/urldetect.py
===================================================================
--- virt-manager-3.2.0.orig/virtinst/install/urldetect.py
+++ virt-manager-3.2.0/virtinst/install/urldetect.py
@@ -723,6 +723,26 @@ class _OESDistro(_SuseDistro):
famregex = ".*Open Enterprise Server.*"
@ -19,7 +21,9 @@ References: bsc#1192238, jsc#SLE-17764
+
+ def _detect_version(self):
+ if self.cache.treeinfo_version: # pragma: no cover
+ olname = self._variant_prefix + self.cache.treeinfo_version
+ version, update = self.cache.split_version()
+ # Beginning with oracle 8 they add an extra '.0' which we ignore
+ olname = self._variant_prefix + str(version) + "." + str(update)
+ if OSDB.lookup_os(olname):
+ return olname
+
@ -27,7 +31,7 @@ References: bsc#1192238, jsc#SLE-17764
class _DebianDistro(_DistroTree):
# ex. http://ftp.egr.msu.edu/debian/dists/sarge/main/installer-i386/
# daily builds: https://d-i.debian.org/daily-images/amd64/
@@ -949,6 +967,7 @@ def _build_distro_list(osobj):
@@ -949,6 +969,7 @@ def _build_distro_list(osobj):
_FedoraDistro,
_RHELDistro,
_CentOSDistro,

View File

@ -8,7 +8,7 @@ Index: virt-manager-3.2.0/virtManager/addhardware.py
===================================================================
--- virt-manager-3.2.0.orig/virtManager/addhardware.py
+++ virt-manager-3.2.0/virtManager/addhardware.py
@@ -480,6 +480,9 @@ class vmmAddHardware(vmmGObjectUI):
@@ -484,6 +484,9 @@ class vmmAddHardware(vmmGObjectUI):
buses = domcaps.devices.disk.get_enum("bus").get_values()
else:
buses = vmmAddHardware.disk_old_recommended_buses(guest)
@ -18,7 +18,7 @@ Index: virt-manager-3.2.0/virtManager/addhardware.py
bus_map = {
"disk": ["ide", "sata", "scsi", "sd", "usb", "virtio", "xen"],
@@ -499,6 +502,7 @@ class vmmAddHardware(vmmGObjectUI):
@@ -503,6 +506,7 @@ class vmmAddHardware(vmmGObjectUI):
"usb": _("USB"),
"virtio": _("VirtIO"),
"xen": _("Xen"),
@ -26,7 +26,7 @@ Index: virt-manager-3.2.0/virtManager/addhardware.py
}
return bus_mappings.get(bus, bus)
@@ -680,8 +684,9 @@ class vmmAddHardware(vmmGObjectUI):
@@ -687,8 +691,9 @@ class vmmAddHardware(vmmGObjectUI):
"drive-harddisk", _("Disk device")])
target_model.append([DeviceDisk.DEVICE_CDROM,
"media-optical", _("CDROM device")])