From 3bd8181bc5548a0ce81107cbfb480dfdcba5679d Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Tue, 6 Jul 2021 13:41:28 -0500 Subject: [PATCH] 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 Reviewed-by: Michal Privoznik --- 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 5af4a01d735..235c987c634 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 81037d81396..90a64f16b07 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 f6da82b0209..4b558a14644 100644 --- a/tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml +++ b/tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml @@ -1,5 +1,5 @@ - mdev_200f228a_c80a_4d50_bfb7_f5a0e4e34045 + mdev_200f228a_c80a_4d50_bfb7_f5a0e4e34045_0000_00_02_0 pci_0000_00_02_0 @@ -8,7 +8,7 @@ - mdev_de807ffc_1923_4d5f_b6c9_b20ecebc6d4b + mdev_de807ffc_1923_4d5f_b6c9_b20ecebc6d4b_0000_00_02_0 pci_0000_00_02_0 @@ -17,7 +17,7 @@ - mdev_435722ea_5f43_468a_874f_da34f1217f13 + mdev_435722ea_5f43_468a_874f_da34f1217f13_0000_00_02_0 pci_0000_00_02_0 @@ -27,7 +27,7 @@ - mdev_783e6dbb_ea0e_411f_94e2_717eaad438bf + mdev_783e6dbb_ea0e_411f_94e2_717eaad438bf_matrix ap_matrix