Skip to content

Commit

Permalink
nodedev: Handle inactive mdevs with the same UUID
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jonner committed Aug 6, 2021
1 parent 08d29eb commit 3bd8181
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/node_device/node_device_driver.c
Expand Up @@ -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);
}


Expand Down
2 changes: 1 addition & 1 deletion src/node_device/node_device_udev.c
Expand Up @@ -1067,7 +1067,7 @@ udevProcessMediatedDevice(struct udev_device *dev,
return -1;
}

udevGenerateDeviceName(dev, def, NULL);
udevGenerateDeviceName(dev, def, data->parent_addr);

data->iommuGroupNumber = iommugrp;

Expand Down
8 changes: 4 additions & 4 deletions 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'/>
Expand All @@ -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'/>
Expand All @@ -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'/>
Expand All @@ -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'/>
Expand Down

0 comments on commit 3bd8181

Please sign in to comment.