]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
avoid using deprecated udev logging functions
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 15 Dec 2014 15:32:13 +0000 (15:32 +0000)
committerEric Blake <eblake@redhat.com>
Wed, 16 Dec 2015 16:00:48 +0000 (09:00 -0700)
In systemd >= 218, the udev_set_log_fn method has been marked
deprecated and turned into a no-op. Nothing in the udev client
library will print to stderr by default anymore, so we can
just stop installing a logging hook for new enough udev.

(cherry picked from commit a93a3b975cd0bad37ccae508d9b7a69aa72b6181)

m4/virt-udev.m4
src/node_device/node_device_udev.c

index 55673bf2071b1cb01e479448c4f33856080e4f72..29ab30a5e861e649a61d4346391907636d6ad382 100644 (file)
@@ -24,6 +24,13 @@ AC_DEFUN([LIBVIRT_CHECK_UDEV],[
   if test "$with_udev" = "yes" && test "$with_pciaccess" != "yes" ; then
     AC_MSG_ERROR([You must install the pciaccess module to build with udev])
   fi
+
+  if test "$with_udev" = "yes" ; then
+     PKG_CHECK_EXISTS([libudev >= 218], [with_udev_logging=no], [with_udev_logging=yes])
+     if test "$with_udev_logging" = "yes" ; then
+        AC_DEFINE_UNQUOTED([HAVE_UDEV_LOGGING], 1, [whether libudev logging can be used])
+     fi
+  fi
 ])
 
 AC_DEFUN([LIBVIRT_RESULT_UDEV],[
index 67fcc58038fc7f5d4f7dcaf609d45dbdb8af090f..ca7f3f356efbe5a5cfe5a8326811e534a793b77a 100644 (file)
@@ -347,7 +347,7 @@ static int udevGenerateDeviceName(struct udev_device *device,
     return ret;
 }
 
-
+#if HAVE_UDEV_LOGGING
 typedef void (*udevLogFunctionPtr)(struct udev *udev,
                                    int priority,
                                    const char *file,
@@ -380,6 +380,7 @@ udevLogFunction(struct udev *udev ATTRIBUTE_UNUSED,
 
     VIR_FREE(format);
 }
+#endif
 
 
 static int udevTranslatePCIIds(unsigned int vendor,
@@ -1711,8 +1712,10 @@ static int nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
      * its return value.
      */
     udev = udev_new();
+#if HAVE_UDEV_LOGGING
     /* cast to get rid of missing-format-attribute warning */
     udev_set_log_fn(udev, (udevLogFunctionPtr) udevLogFunction);
+#endif
 
     priv->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
     if (priv->udev_monitor == NULL) {