[libvirt PATCH 6/7] nodedev: Handle inactive mdevs with the same UUID

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Unfortunately, mdevctl supports defining more than one mdev with the
same UUID as long as they have different parent devices. (Only one of
these devices can be active at any given time).

This means that we can't use the UUID alone as a way to uniquely
identify mdev node devices. Append the parent address to ensure
uniqueness. For example:

    Before: mdev_88a6b868_46bd_4015_8e5b_26107f82da38
    After:  mdev_88a6b868_46bd_4015_8e5b_26107f82da38_0000_00_02_0

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1979440

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 src/node_device/node_device_driver.c                   | 3 ++-
 src/node_device/node_device_udev.c                     | 2 +-
 tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml | 8 ++++----
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index d76268285f..4e676bfd56 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -1028,7 +1028,8 @@ nodeDeviceGetMdevctlListCommand(bool defined,
 
 static void mdevGenerateDeviceName(virNodeDeviceDef *dev)
 {
-    nodeDeviceGenerateName(dev, "mdev", dev->caps->data.mdev.uuid, NULL);
+    nodeDeviceGenerateName(dev, "mdev", dev->caps->data.mdev.uuid,
+                           dev->caps->data.mdev.parent_addr);
 }
 
 
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 81037d8139..90a64f16b0 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1067,7 +1067,7 @@ udevProcessMediatedDevice(struct udev_device *dev,
         return -1;
     }
 
-    udevGenerateDeviceName(dev, def, NULL);
+    udevGenerateDeviceName(dev, def, data->parent_addr);
 
     data->iommuGroupNumber = iommugrp;
 
diff --git a/tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml b/tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml
index c23a3130c1..3971898549 100644
--- a/tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml
+++ b/tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml
@@ -1,5 +1,5 @@
 <device>
-  <name>mdev_200f228a_c80a_4d50_bfb7_f5a0e4e34045</name>
+  <name>mdev_200f228a_c80a_4d50_bfb7_f5a0e4e34045_0000_00_02_0</name>
   <parent>pci_0000_00_02_0</parent>
   <capability type='mdev'>
     <type id='i915-GVTg_V5_4'/>
@@ -8,7 +8,7 @@
   </capability>
 </device>
 <device>
-  <name>mdev_de807ffc_1923_4d5f_b6c9_b20ecebc6d4b</name>
+  <name>mdev_de807ffc_1923_4d5f_b6c9_b20ecebc6d4b_0000_00_02_0</name>
   <parent>pci_0000_00_02_0</parent>
   <capability type='mdev'>
     <type id='i915-GVTg_V5_4'/>
@@ -17,7 +17,7 @@
   </capability>
 </device>
 <device>
-  <name>mdev_435722ea_5f43_468a_874f_da34f1217f13</name>
+  <name>mdev_435722ea_5f43_468a_874f_da34f1217f13_0000_00_02_0</name>
   <parent>pci_0000_00_02_0</parent>
   <capability type='mdev'>
     <type id='i915-GVTg_V5_8'/>
@@ -27,7 +27,7 @@
   </capability>
 </device>
 <device>
-  <name>mdev_783e6dbb_ea0e_411f_94e2_717eaad438bf</name>
+  <name>mdev_783e6dbb_ea0e_411f_94e2_717eaad438bf_matrix</name>
   <parent>matrix_matrix</parent>
   <capability type='mdev'>
     <type id='vfio_ap-passthrough'/>
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux