import virt-manager-3.2.0-11.el9

This commit is contained in:
CentOS Sources 2022-01-11 12:12:06 -05:00 committed by Stepan Oksanichenko
parent 71a0699fb4
commit e8b85402ee
8 changed files with 966 additions and 1 deletions

View File

@ -0,0 +1,112 @@
From 9cb766bec0296720e98101807726dd9a488486c4 Mon Sep 17 00:00:00 2001
From: Jonathon Jongsma <jjongsma@redhat.com>
Date: Tue, 26 Oct 2021 14:18:40 -0500
Subject: [PATCH] Handle new nodedev name for mediated devices
libvirt recently changed the nodedev names for mediated devices due to
the fact that mdevctl supports defining multiple mediated devices with
the same UUID as long as only one is active at a time. This means that
the nodedev name changed from the format 'mdev_$UUID' to the format
'mdev_$UUID_$PARENT'.
Unfortunately, virt-install was parsing the nodedev name to extract the
UUID of a mediated device. This fails with the new name format.
Fortunately, in libvirt 7.3.0, a <uuid> field was added to the xml
schema for mdev devices, so we can simply use this instead, and fall
back to the name parsing if it doesn't exist.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
(cherry picked from commit 0c146b250384ddddcefd2cc0d76b9e808377ebe5)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2023650
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
---
tests/data/testdriver/testdriver.xml | 14 ++++++++++++++
tests/test_nodedev.py | 14 ++++++++++++++
virtinst/nodedev.py | 7 +++++++
3 files changed, 35 insertions(+)
diff --git a/tests/data/testdriver/testdriver.xml b/tests/data/testdriver/testdriver.xml
index 5875732a..e4880936 100644
--- a/tests/data/testdriver/testdriver.xml
+++ b/tests/data/testdriver/testdriver.xml
@@ -3725,4 +3725,18 @@ ba</description>
</capability>
</device>
+<device>
+ <name>mdev_35ceae7f_eea5_4f28_b7f3_7b12a3e62d3c_0000_06_00_0</name>
+ <path>/sys/devices/pci0000:00/0000:00:02.0/35ceae7f-eea5-4f28-b7f3-7b12a3e62d3c</path>
+ <parent>pci_0000_06_00_0</parent>
+ <driver>
+ <name>vfio_mdev</name>
+ </driver>
+ <capability type='mdev'>
+ <type id='nvidia-11'/>
+ <iommuGroup number='12'/>
+ <uuid>35ceae7f-eea5-4f28-b7f3-7b12a3e62d3c</uuid>
+ </capability>
+</device>
+
</node>
diff --git a/tests/test_nodedev.py b/tests/test_nodedev.py
index 79678bc8..41435262 100644
--- a/tests/test_nodedev.py
+++ b/tests/test_nodedev.py
@@ -8,6 +8,7 @@
import os.path
import pytest
+import libvirt
from virtinst import Guest
from virtinst import NodeDevice
@@ -154,6 +155,19 @@ def testPCIMdev():
assert dev.parent == "pci_0000_06_00_0"
assert dev.device_type == "mdev"
assert dev.type_id == "nvidia-11"
+ assert dev.get_mdev_uuid() == "4b20d080-1b54-4048-85b3-a6a62d165c01"
+
+# libvirt <7.3.0 doesn't support <uuid> in the mdev node device xml
+@pytest.mark.skipif(libvirt.getVersion() < 7003000, reason="libvirt version doesn't support new mdev format")
+def testPCIMdevNewFormat():
+ conn = utils.URIs.open_testdriver_cached()
+ devname = "mdev_35ceae7f_eea5_4f28_b7f3_7b12a3e62d3c_0000_06_00_0"
+ 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"
+ assert dev.get_mdev_uuid() == "35ceae7f-eea5-4f28-b7f3-7b12a3e62d3c"
# NodeDevice 2 Device XML tests
diff --git a/virtinst/nodedev.py b/virtinst/nodedev.py
index f54a311c..248723b9 100644
--- a/virtinst/nodedev.py
+++ b/virtinst/nodedev.py
@@ -94,6 +94,12 @@ class NodeDevice(XMLBuilder):
device_type = XMLProperty("./capability/@type")
def get_mdev_uuid(self):
+ # libvirt 7.3.0 added a <uuid> element to the nodedev xml for mdev
+ # types. For older versions, we unfortunately have to parse the nodedev
+ # name, which uses the format "mdev_$UUID_WITH_UNDERSCORES"
+ if self.uuid is not None:
+ return self.uuid
+
return self.name[5:].replace('_', '-')
def compare_to_hostdev(self, hostdev):
@@ -191,6 +197,7 @@ class NodeDevice(XMLBuilder):
# type='mdev' options
type_id = XMLProperty("./capability/type/@id")
+ uuid = XMLProperty("./capability/uuid")
def _AddressStringToHostdev(conn, addrstr):
--
2.31.1

View File

@ -0,0 +1,71 @@
From ddedf5e1b34568adbbfed6a052bf96b7d1eda6f1 Mon Sep 17 00:00:00 2001
From: Pavel Hrdina <phrdina@redhat.com>
Date: Tue, 14 Sep 2021 17:08:35 +0200
Subject: [PATCH] cli: introduce --resource fibrechannel.appid option
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 0953e1aea1fd16cd1825c03f3b032c7f12f3322f)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2011328
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
---
tests/data/cli/compare/virt-install-singleton-config-1.xml | 1 +
tests/test_cli.py | 2 +-
virtinst/cli.py | 1 +
virtinst/domain/resource.py | 3 ++-
4 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/tests/data/cli/compare/virt-install-singleton-config-1.xml b/tests/data/cli/compare/virt-install-singleton-config-1.xml
index 518a0099..b50d806e 100644
--- a/tests/data/cli/compare/virt-install-singleton-config-1.xml
+++ b/tests/data/cli/compare/virt-install-singleton-config-1.xml
@@ -19,6 +19,7 @@
</numatune>
<resource>
<partition>/virtualmachines/production</partition>
+ <fibrechannel appid="myapplication"/>
</resource>
<os>
<type arch="x86_64" machine="q35">hvm</type>
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 4b714e3e..aba1fe3c 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -480,7 +480,7 @@ c.add_compare("""
--memorybacking hugepages=on
--features apic=off
--clock offset=localtime
---resource /virtualmachines/production
+--resource /virtualmachines/production,fibrechannel.appid=myapplication
--events on_crash=restart
--metadata genid_enable=yes
--sysinfo host
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 8e5b13cd..e1a988f9 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -1999,6 +1999,7 @@ class ParserResource(VirtCLIParser):
def _init_class(cls, **kwargs):
VirtCLIParser._init_class(**kwargs)
cls.add_arg("partition", "partition")
+ cls.add_arg("fibrechannel.appid", "fibrechannel_appid", can_comma=True)
######################
diff --git a/virtinst/domain/resource.py b/virtinst/domain/resource.py
index d0962db9..8ad3df54 100644
--- a/virtinst/domain/resource.py
+++ b/virtinst/domain/resource.py
@@ -14,6 +14,7 @@ class DomainResource(XMLBuilder):
"""
XML_NAME = "resource"
- _XML_PROP_ORDER = ["partition"]
+ _XML_PROP_ORDER = ["partition", "fibrechannel_appid"]
partition = XMLProperty("./partition")
+ fibrechannel_appid = XMLProperty("./fibrechannel/@appid")
--
2.31.1

View File

@ -0,0 +1,35 @@
From 1bba2d4e7de4a921921f2ae5d0d09589a180b70b Mon Sep 17 00:00:00 2001
From: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Date: Mon, 31 May 2021 21:54:27 +0200
Subject: [PATCH] hostdev: use method get_mdev_uuid()
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>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1995131
(cherry picked from commit f87e96d3d40891f1403601abc389c24800ba1069)
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
---
virtinst/devices/hostdev.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virtinst/devices/hostdev.py b/virtinst/devices/hostdev.py
index e8d0fae2..b3717430 100644
--- 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)
--
2.31.1

View File

@ -0,0 +1,230 @@
From bbf159da53b34060ae8e5f3023a78a541fec333a Mon Sep 17 00:00:00 2001
From: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Date: Mon, 31 May 2021 21:54:28 +0200
Subject: [PATCH] tests: verify MDEV support
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>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1995131
(cherry picked from commit 9d4002ee0f7088c490748ffb3144c006f4e39c68)
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
---
.../virt-xml-add-hostdev-mdev-start.xml | 12 +++++++
.../cli/compare/virt-xml-add-hostdev-mdev.xml | 14 ++++++++
tests/data/cli/compare/virt-xml-edit-all.xml | 7 ++++
.../compare/virt-xml-edit-hostdev-mdev.xml | 11 +++++++
.../compare/virt-xml-edit-simple-redirdev.xml | 2 +-
.../compare/virt-xml-remove-hostdev-mdev.xml | 15 +++++++++
tests/data/testdriver/testsuite.xml | 32 +++++++++++++++++++
tests/test_cli.py | 4 +++
tests/utils.py | 2 +-
9 files changed, 97 insertions(+), 2 deletions(-)
create mode 100644 tests/data/cli/compare/virt-xml-add-hostdev-mdev-start.xml
create mode 100644 tests/data/cli/compare/virt-xml-add-hostdev-mdev.xml
create mode 100644 tests/data/cli/compare/virt-xml-edit-hostdev-mdev.xml
create mode 100644 tests/data/cli/compare/virt-xml-remove-hostdev-mdev.xml
diff --git a/tests/data/cli/compare/virt-xml-add-hostdev-mdev-start.xml b/tests/data/cli/compare/virt-xml-add-hostdev-mdev-start.xml
new file mode 100644
index 00000000..3742d454
--- /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.
diff --git a/tests/data/cli/compare/virt-xml-add-hostdev-mdev.xml b/tests/data/cli/compare/virt-xml-add-hostdev-mdev.xml
new file mode 100644
index 00000000..c2acff8f
--- /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.
diff --git a/tests/data/cli/compare/virt-xml-edit-all.xml b/tests/data/cli/compare/virt-xml-edit-all.xml
index ed09effc..5bdee2aa 100644
--- a/tests/data/cli/compare/virt-xml-edit-all.xml
+++ b/tests/data/cli/compare/virt-xml-edit-all.xml
@@ -8,6 +8,13 @@
<address domain="0x0000" bus="0x00" slot="0x19" function="0x0"/>
</source>
<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">
diff --git a/tests/data/cli/compare/virt-xml-edit-hostdev-mdev.xml b/tests/data/cli/compare/virt-xml-edit-hostdev-mdev.xml
new file mode 100644
index 00000000..ef5523db
--- /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.
diff --git a/tests/data/cli/compare/virt-xml-edit-simple-redirdev.xml b/tests/data/cli/compare/virt-xml-edit-simple-redirdev.xml
index 52ffddfe..f1a0ff6c 100644
--- 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"/>
diff --git a/tests/data/cli/compare/virt-xml-remove-hostdev-mdev.xml b/tests/data/cli/compare/virt-xml-remove-hostdev-mdev.xml
new file mode 100644
index 00000000..d4c33804
--- /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.
diff --git a/tests/data/testdriver/testsuite.xml b/tests/data/testdriver/testsuite.xml
index fd255138..a073cbce 100644
--- 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>
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 092e087a..4b714e3e 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1274,6 +1274,7 @@ c.add_compare("--edit mac=00:11:7f:33:44:55 --network target=nic55", "edit-selec
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 /dev/null", "remove-disk-path")
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 --host-device usb_device_4b3_4485_noserial"
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
diff --git a/tests/utils.py b/tests/utils.py
index 16ba26b4..62443ca8 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -231,7 +231,7 @@ def diff_compare(actual_out, filename=None, expect_out=None):
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)
--
2.31.1

View File

@ -0,0 +1,256 @@
From 06f12e246c206311bc5d7fcbd24ac02df1e3fff9 Mon Sep 17 00:00:00 2001
From: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Date: Wed, 14 Apr 2021 17:18:55 +0200
Subject: [PATCH] virt-install: add mediated device
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>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1995131
(cherry picked from commit 965480e8bc85caf8a4f36b4a2f07963067b63cf6)
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
---
.../cli/compare/virt-install-many-devices.xml | 19 +++++++++
tests/data/testdriver/testdriver.xml | 40 +++++++++++++++++++
tests/test_cli.py | 3 ++
tests/test_nodedev.py | 30 ++++++++++++++
virtinst/devices/hostdev.py | 36 ++++++++++++++++-
virtinst/nodedev.py | 4 ++
6 files changed, 131 insertions(+), 1 deletion(-)
diff --git a/tests/data/cli/compare/virt-install-many-devices.xml b/tests/data/cli/compare/virt-install-many-devices.xml
index 49e9dcc7..3bd756b3 100644
--- a/tests/data/cli/compare/virt-install-many-devices.xml
+++ b/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"/>
diff --git a/tests/data/testdriver/testdriver.xml b/tests/data/testdriver/testdriver.xml
index ea90f0f7..b8d67bac 100644
--- a/tests/data/testdriver/testdriver.xml
+++ b/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>
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 3534e0e2..092e087a 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -675,6 +675,9 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
--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
diff --git a/tests/test_nodedev.py b/tests/test_nodedev.py
index 406e321f..79678bc8 100644
--- a/tests/test_nodedev.py
+++ b/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():
diff --git a/virtinst/devices/hostdev.py b/virtinst/devices/hostdev.py
index 3e9de2ad..e8d0fae2 100644
--- a/virtinst/devices/hostdev.py
+++ b/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 #
diff --git a/virtinst/nodedev.py b/virtinst/nodedev.py
index 9d2c8f10..97841794 100644
--- a/virtinst/nodedev.py
+++ b/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
--
2.31.1

View File

@ -0,0 +1,164 @@
From fe341d97aee2666dc378f89de4a957bc8ae35a21 Mon Sep 17 00:00:00 2001
From: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
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 <crobinso@redhat.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1995131
(cherry picked from commit 0e15cd51dfbdaa09f7d34ed1edce2f5416130361)
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
---
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</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
--
2.31.1

View File

@ -0,0 +1,77 @@
From d4a11d8f8a0b7990c9d349da2306c7f4103a43e0 Mon Sep 17 00:00:00 2001
From: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Date: Mon, 31 May 2021 21:54:26 +0200
Subject: [PATCH] virt-xml: add support for mediated devices
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>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1995131
(cherry picked from commit 9363e1e692bb0d01184ecc7991d61c95542f690b)
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
---
virtinst/nodedev.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
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
--
2.31.1

View File

@ -8,7 +8,7 @@
Name: virt-manager
Version: 3.2.0
Release: 8%{?dist}%{?extra_release}
Release: 11%{?dist}%{?extra_release}
%global verrel %{version}-%{release}
Summary: Desktop tool for managing virtual machines via libvirt
@ -24,6 +24,13 @@ Patch3: virt-manager-urlfetcher-Factor-out-ISOReader-class.patch
Patch4: virt-manager-urlfetcher-Add-xorriso-ISOReader-implementation.patch
Patch5: virt-manager-urlfetcher-Delete-the-isoinfo-ISOReader.patch
Patch6: virt-manager-urlfetcher-Silence-xorisso-stderr-output.patch
Patch7: virt-manager-virt-install-add-mediated-device.patch
Patch8: virt-manager-virt-xml-add-support-for-mediated-devices.patch
Patch9: virt-manager-hostdev-use-method-get_mdev_uuid.patch
Patch10: virt-manager-tests-verify-MDEV-support.patch
Patch11: virt-manager-virt-manager-enable-MDEV-support.patch
Patch12: virt-manager-cli-introduce-resource-fibrechannel.appid-option.patch
Patch13: virt-manager-Handle-new-nodedev-name-for-mediated-devices.patch
Requires: virt-manager-common = %{verrel}
@ -181,6 +188,19 @@ done
%changelog
* Fri Nov 19 2021 Jonathon Jongsma <jjongsma@redhat.com> - 3.2.0-11
- Handle new nodedev name for mediated devices (rhbz#2023650)
* Thu Nov 11 2021 Jonathon Jongsma <jjongsma@redhat.com> - 3.2.0-10
- cli: introduce --resource fibrechannel.appid option (rhbz#2011328)
* Thu Sep 9 2021 Jonathon Jongsma <jjongsma@redhat.com> - 3.2.0-9
- virt-install: add mediated device (rhbz#1995131)
- virt-xml: add support for mediated devices (rhbz#1995131)
- hostdev: use method get_mdev_uuid() (rhbz#1995131)
- tests: verify MDEV support (rhbz#1995131)
- virt-manager: enable MDEV support (rhbz#1995131)
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 3.2.0-8
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688