]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nodedev: store mdev UUID in mdev caps
authorJonathon Jongsma <jjongsma@redhat.com>
Thu, 18 Jun 2020 21:05:58 +0000 (16:05 -0500)
committerErik Skultety <eskultet@redhat.com>
Fri, 19 Jun 2020 08:39:55 +0000 (10:39 +0200)
In order to allow libvirt to create and start new mediated devices, we
need to be able to verify that the device has been started. In order to
do this, we'll need to save the UUID of newly-discovered devices within
the virNodeDevCapMdev structure. This allows us to search the device
list by UUID and verify whether the expected device has been started.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/node_device_conf.c
src/conf/node_device_conf.h
src/node_device/node_device_udev.c

index 623a2cb79c3d6814cdb0acc235a1e999eeef6d99..78a537d0ea33ef3531a8b3c9de1a7232f8c991f2 100644 (file)
@@ -2218,6 +2218,7 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
         break;
     case VIR_NODE_DEV_CAP_MDEV:
         VIR_FREE(data->mdev.type);
+        VIR_FREE(data->mdev.uuid);
         for (i = 0; i < data->mdev.nattributes; i++)
             virMediatedDeviceAttrFree(data->mdev.attributes[i]);
         VIR_FREE(data->mdev.attributes);
index e3e1e788d4d3d68256b44614d80178b4e684d552..9b8c7aadea8e189c48ae8a6c4fd6a434c6503e8e 100644 (file)
@@ -141,6 +141,7 @@ typedef virNodeDevCapMdev *virNodeDevCapMdevPtr;
 struct _virNodeDevCapMdev {
     char *type;
     unsigned int iommuGroupNumber;
+    char *uuid;
     virMediatedDeviceAttrPtr *attributes;
     size_t nattributes;
 };
index 386f23ef3a18fddbbbda679c57a264a349d77734..bdf0b03addd37ed09024cab2245bbed15a484270 100644 (file)
@@ -1013,7 +1013,6 @@ udevProcessMediatedDevice(struct udev_device *dev,
                           virNodeDeviceDefPtr def)
 {
     int ret = -1;
-    const char *uuidstr = NULL;
     int iommugrp = -1;
     char *linkpath = NULL;
     char *canonicalpath = NULL;
@@ -1041,8 +1040,8 @@ udevProcessMediatedDevice(struct udev_device *dev,
 
     data->type = g_path_get_basename(canonicalpath);
 
-    uuidstr = udev_device_get_sysname(dev);
-    if ((iommugrp = virMediatedDeviceGetIOMMUGroupNum(uuidstr)) < 0)
+    data->uuid = g_strdup(udev_device_get_sysname(dev));
+    if ((iommugrp = virMediatedDeviceGetIOMMUGroupNum(data->uuid)) < 0)
         goto cleanup;
 
     if (udevGenerateDeviceName(dev, def, NULL) != 0)