]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nodedev: Handle inactive mdevs with the same UUID
authorJonathon Jongsma <jjongsma@redhat.com>
Tue, 6 Jul 2021 18:41:28 +0000 (13:41 -0500)
committerJonathon Jongsma <jjongsma@redhat.com>
Fri, 6 Aug 2021 20:02:38 +0000 (15:02 -0500)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/node_device/node_device_driver.c
src/node_device/node_device_udev.c
tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml

index 5af4a01d735493c2d6fcf454ccca4fc4c4352a0f..235c987c6343a93fbefa750d2cf49788f941dbaa 100644 (file)
@@ -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);
 }
 
 
index 81037d81396fbe295f57ed941497930ffccb5bf9..90a64f16b076ce29b9f7e63fb03d10b4f12f8ad3 100644 (file)
@@ -1067,7 +1067,7 @@ udevProcessMediatedDevice(struct udev_device *dev,
         return -1;
     }
 
-    udevGenerateDeviceName(dev, def, NULL);
+    udevGenerateDeviceName(dev, def, data->parent_addr);
 
     data->iommuGroupNumber = iommugrp;
 
index f6da82b020959e989a964770ae7191a0af4533e0..4b558a146441ffeaf7745539c18680690a1257ef 100644 (file)
@@ -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>ap_matrix</parent>
   <capability type='mdev'>
     <type id='vfio_ap-passthrough'/>