From d67fb80cd27d8a1d67f1e5850a3cc858b832fdfa Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Fri, 19 Nov 2021 10:19:15 -0600 Subject: [PATCH] virt-manager-3.2.0-11.el9 - Handle new nodedev name for mediated devices (rhbz#2023650) Resolves: rhbz#2023650 --- ...ew-nodedev-name-for-mediated-devices.patch | 112 ++++++++++++++++++ virt-manager.spec | 6 +- 2 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 virt-manager-Handle-new-nodedev-name-for-mediated-devices.patch diff --git a/virt-manager-Handle-new-nodedev-name-for-mediated-devices.patch b/virt-manager-Handle-new-nodedev-name-for-mediated-devices.patch new file mode 100644 index 0000000..f7a2a5a --- /dev/null +++ b/virt-manager-Handle-new-nodedev-name-for-mediated-devices.patch @@ -0,0 +1,112 @@ +From 9cb766bec0296720e98101807726dd9a488486c4 Mon Sep 17 00:00:00 2001 +From: Jonathon Jongsma +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 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 +(cherry picked from commit 0c146b250384ddddcefd2cc0d76b9e808377ebe5) + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2023650 + +Signed-off-by: Jonathon Jongsma +--- + 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 + + + ++ ++ mdev_35ceae7f_eea5_4f28_b7f3_7b12a3e62d3c_0000_06_00_0 ++ /sys/devices/pci0000:00/0000:00:02.0/35ceae7f-eea5-4f28-b7f3-7b12a3e62d3c ++ pci_0000_06_00_0 ++ ++ vfio_mdev ++ ++ ++ ++ ++ 35ceae7f-eea5-4f28-b7f3-7b12a3e62d3c ++ ++ ++ + +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 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 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 + diff --git a/virt-manager.spec b/virt-manager.spec index 43b338c..92ec9ef 100644 --- a/virt-manager.spec +++ b/virt-manager.spec @@ -8,7 +8,7 @@ Name: virt-manager Version: 3.2.0 -Release: 10%{?dist}%{?extra_release} +Release: 11%{?dist}%{?extra_release} %global verrel %{version}-%{release} Summary: Desktop tool for managing virtual machines via libvirt @@ -30,6 +30,7 @@ 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} @@ -187,6 +188,9 @@ done %changelog +* Fri Nov 19 2021 Jonathon Jongsma - 3.2.0-11 +- Handle new nodedev name for mediated devices (rhbz#2023650) + * Thu Nov 11 2021 Jonathon Jongsma - 3.2.0-10 - cli: introduce --resource fibrechannel.appid option (rhbz#2011328)