nodedev: Handle inactive mdevs with the same UUID

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>
This commit is contained in:
Jonathon Jongsma 2021-07-06 13:41:28 -05:00
parent 08d29eb3b1
commit 3bd8181bc5
3 changed files with 7 additions and 6 deletions

View 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);
}

View 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;

View 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'/>