[libvirt PATCH 3/7] nodedev: cache parent address in mdev caps

Michal Prívozník mprivozn at redhat.com
Mon Jul 26 14:47:06 UTC 2021


On 7/23/21 6:40 PM, Jonathon Jongsma wrote:
> mdevctl can report multiple defined devices with the same UUID
> but different parents, including parents that don't actually exist on
> the host machine. Libvirt sets the parent to the 'computer' device for
> all of the mdevs that have nonexistent parents. Because of this, it's
> possible that there are multiple devices with the same UUID and the same
> 'computer' device as their parent, so the combination of uuid and parent
> 'nodedev name is not guaranteed to be a unique name.
> 
> We need to ensure that each nodedev has a unique name. If we can't use
> the UUID as a unique nodedev name, and we can't use the combination of
> UUID and nodedev parent name, we need to find another solution. By
> caching and using the parent name reported by mdevctl in combination
> with the UUID, we can achieve a unique name. mdevctl guarantees that its
> uuid/parent combination is unique.
> 
> This value will be used to set the mdev nodedev name in a following commit.
> 
> Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
> ---
>  src/conf/node_device_conf.h          |  1 +
>  src/node_device/node_device_driver.c |  1 +
>  src/node_device/node_device_udev.c   | 16 ++++++++++++++++
>  3 files changed, 18 insertions(+)

The following should be squashed in to prevent memleak:

diff --git i/src/conf/node_device_conf.c w/src/conf/node_device_conf.c
index cd1c07092d..80ff0f973f 100644
--- i/src/conf/node_device_conf.c
+++ w/src/conf/node_device_conf.c
@@ -2329,6 +2329,7 @@ virNodeDevCapsDefFree(virNodeDevCapsDef *caps)
         for (i = 0; i < data->mdev.nattributes; i++)
             virMediatedDeviceAttrFree(data->mdev.attributes[i]);
         g_free(data->mdev.attributes);
+        g_free(data->mdev.parent_addr);
         break;
     case VIR_NODE_DEV_CAP_CSS_DEV:
         for (i = 0; i < data->ccw_dev.nmdev_types; i++)

Michal




More information about the libvir-list mailing list