Re: [RFC PATCH v1 13/15] node_device_udev: Call `nodeDeviceUpdateMediatedDevices` directly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>

On 4/12/24 15:36, Marc Hartmayer wrote:
When an udev event occurs the mdev active config data requires an update via
mdevctl as the udev does not contain all config data. This update needs to occur
immediate and to be finished before the libvirt nodedev event is issued to keep
the API usage reliable.

The only case where a direct `nodeDeviceUpdateMediatedDevices` is not wished is
`mdevctlEventHandleCallback` - see commit 2c57b28191b9 ("nodedev: Refresh mdev
devices when changes are detected") for details, but for this case there are no
nodedev events created so the problem described above does not exist.

`udevAddOneDevice` and `udevRemoveOneDeviceSysPath` are only called by the
worker pool threads therefore it's possible to call the
`nodeDeviceUpdateMediatedDevices` directly without blocking the udev thread.

Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>
---
  src/node_device/node_device_udev.c | 16 +++-------------
  1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 2a252d8fe62b..9282afdd3241 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1520,9 +1520,6 @@ udevGetDeviceDetails(virNodeDeviceDriverState *driver_state, struct udev_device
  }
-static void scheduleMdevctlUpdate(udevEventData *data, bool force);
-
-
  static int
  processNodeDeviceRemoveEvent(virNodeDeviceDriverState *driver_state, const char *path)
  {
@@ -1556,9 +1553,8 @@ processNodeDeviceRemoveEvent(virNodeDeviceDriverState *driver_state, const char
      virNodeDeviceObjEndAPI(&obj);
/* cannot check for mdev_types since they have already been removed */
-    VIR_WITH_OBJECT_LOCK_GUARD(driver->privateData) {
-        scheduleMdevctlUpdate(driver_state->privateData, false);
-    }
+    if (nodeDeviceUpdateMediatedDevices(driver_state) < 0)
+        VIR_WARN("mdevctl failed to update mediated devices");
virObjectEventStateQueue(driver_state->nodeDeviceEventState, event);
      return 0;
@@ -1682,15 +1678,9 @@ processNodeDeviceAddAndChangeEvent(virNodeDeviceDriverState *driver_state, struc
      has_mdev_types = virNodeDeviceObjHasCap(obj, VIR_NODE_DEV_CAP_MDEV_TYPES);
      virNodeDeviceObjEndAPI(&obj);
- if (has_mdev_types) {
-        VIR_WITH_OBJECT_LOCK_GUARD(driver_state->privateData) {
-            scheduleMdevctlUpdate(driver_state->privateData, false);
-        }
-    }
-
      /* The added mdev needs an immediate active config update before
       * the event is issued to allow sane API usage. */
-    if (is_mdev && (nodeDeviceUpdateMediatedDevices(driver_state) < 0)) {
+    if ((is_mdev || has_mdev_types) && (nodeDeviceUpdateMediatedDevices(driver_state) < 0)) {
          VIR_WARN("Update of mediated device %s failed",
                   NULLSTR_EMPTY(sysfs_path));
      }

--
Mit freundlichen Grüßen/Kind regards
   Boris Fiuczynski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux