]> xenbits.xensource.com Git - libvirt.git/commitdiff
nodedev: udev: Remove the udevEventHandleCallback on fatal error
authorErik Skultety <eskultet@redhat.com>
Wed, 28 Jun 2017 13:39:51 +0000 (15:39 +0200)
committerErik Skultety <eskultet@redhat.com>
Thu, 17 Aug 2017 14:50:47 +0000 (16:50 +0200)
So we have a sanity check for the udev monitor fd. Theoretically, it
could happen that the udev monitor fd changes (due to our own wrongdoing,
hence the 'sanity' here) and if that happens it means we are handling an
event from a different entity than we think, thus we should remove the
handle if someone somewhere somehow hits this hypothetical case.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
src/node_device/node_device_udev.c

index 0944b41d76392ed120fcc6559919e7631d7a3f3b..a0e425d515cd8b3adc9f38e69b11ab544e737bb6 100644 (file)
@@ -1611,10 +1611,20 @@ udevEventHandleCallback(int watch ATTRIBUTE_UNUSED,
 
     udev_fd = udev_monitor_get_fd(udev_monitor);
     if (fd != udev_fd) {
+        udevPrivate *priv = driver->privateData;
+
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("File descriptor returned by udev %d does not "
                          "match node device file descriptor %d"),
                        fd, udev_fd);
+
+        /* this is a non-recoverable error, let's remove the handle, so that we
+         * don't get in here again because of some spurious behaviour and report
+         * the same error multiple times
+         */
+        virEventRemoveHandle(priv->watch);
+        priv->watch = -1;
+
         goto cleanup;
     }