[libvirt] [PATCH] nodedev: udev: Drop udev monitor fd check in udevEventHandleCallback

Erik Skultety eskultet at redhat.com
Mon Jun 26 11:47:04 UTC 2017


We do perform that magical check every time an event is received, but
unless we explicitly unref'd or disconnected the monitor, we should not
get a spurious event from a different source.

Signed-off-by: Erik Skultety <eskultet at redhat.com>
---
This is just a poke patch, since I also checked libudev's source and still fail
to understand why we need that check. Unless entered by *_monitor_unref with
the last reference or with *monitor_disconnect, libudev doesn't change the fd
arbitrarily. So the only reason for us to check for that would be if we
disconnected from our side, but didn't unregister the callback in which case
it was our responsibility to clean up properly and we shouldn't get to the
callback in the first place. Thanks for comments in advance.


 src/node_device/node_device_udev.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 174124a1b..7820c49c4 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1602,24 +1602,15 @@ nodeStateCleanup(void)

 static void
 udevEventHandleCallback(int watch ATTRIBUTE_UNUSED,
-                        int fd,
+                        int fd ATTRIBUTE_UNUSED,
                         int events ATTRIBUTE_UNUSED,
                         void *data ATTRIBUTE_UNUSED)
 {
     struct udev_device *device = NULL;
     struct udev_monitor *udev_monitor = DRV_STATE_UDEV_MONITOR(driver);
     const char *action = NULL;
-    int udev_fd = -1;

     nodeDeviceLock();
-    udev_fd = udev_monitor_get_fd(udev_monitor);
-    if (fd != udev_fd) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("File descriptor returned by udev %d does not "
-                         "match node device file descriptor %d"),
-                       fd, udev_fd);
-        goto cleanup;
-    }

     device = udev_monitor_receive_device(udev_monitor);
     if (device == NULL) {
--
2.13.2




More information about the libvir-list mailing list