[libvirt] [PATCH] udev: Fix build on older platforms

Erik Skultety posted 1 patch 6 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/696bec0d22b919dba69bead307e258b9a50a1396.1496225963.git.eskultet@redhat.com
configure.ac                       | 2 +-
src/node_device/node_device_udev.c | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
[libvirt] [PATCH] udev: Fix build on older platforms
Posted by Erik Skultety 6 years, 10 months ago
Caused by commit @d1eea6c1 due to the missing symbol on older platforms.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
---
Despite falling under build-breaker category, I'd like to get a proper review,
since I'm not really familiar with autoconf and there might be a better fix.

Erik

 configure.ac                       | 2 +-
 src/node_device/node_device_udev.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 246f4e077..b78c8b790 100644
--- a/configure.ac
+++ b/configure.ac
@@ -322,7 +322,7 @@ AC_CHECK_FUNCS_ONCE([cfmakeraw fallocate geteuid getgid getgrnam_r \
   getmntent_r getpwuid_r getrlimit getuid if_indextoname kill mmap \
   newlocale posix_fallocate posix_memalign prlimit regexec \
   sched_getaffinity setgroups setns setrlimit symlink sysctlbyname \
-  getifaddrs sched_setscheduler unshare])
+  getifaddrs sched_setscheduler unshare udev_monitor_set_receive_buffer_size])

 dnl Availability of various common headers (non-fatal if missing).
 AC_CHECK_HEADERS([pwd.h regex.h sys/un.h \
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index a69dc1175..01438ea17 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1764,12 +1764,14 @@ static int nodeStateInitialize(bool privileged,

     udev_monitor_enable_receiving(priv->udev_monitor);

+#if HAVE_UDEV_MONITOR_SET_RECEIVE_BUFFER_SIZE
     /* mimic udevd's behaviour and override the systems rmem_max limit in case
      * there's a significant number of device 'add' events
      */
     if (geteuid() == 0)
         udev_monitor_set_receive_buffer_size(priv->udev_monitor,
                                              128 * 1024 * 1024);
+#endif

     /* We register the monitor with the event callback so we are
      * notified by udev of device changes before we enumerate existing
--
2.13.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] udev: Fix build on older platforms
Posted by Daniel P. Berrange 6 years, 10 months ago
On Wed, May 31, 2017 at 12:22:01PM +0200, Erik Skultety wrote:
> Caused by commit @d1eea6c1 due to the missing symbol on older platforms.
> 
> Signed-off-by: Erik Skultety <eskultet@redhat.com>
> ---
> Despite falling under build-breaker category, I'd like to get a proper review,
> since I'm not really familiar with autoconf and there might be a better fix.
> 
> Erik
> 
>  configure.ac                       | 2 +-
>  src/node_device/node_device_udev.c | 2 ++
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 246f4e077..b78c8b790 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -322,7 +322,7 @@ AC_CHECK_FUNCS_ONCE([cfmakeraw fallocate geteuid getgid getgrnam_r \
>    getmntent_r getpwuid_r getrlimit getuid if_indextoname kill mmap \
>    newlocale posix_fallocate posix_memalign prlimit regexec \
>    sched_getaffinity setgroups setns setrlimit symlink sysctlbyname \
> -  getifaddrs sched_setscheduler unshare])
> +  getifaddrs sched_setscheduler unshare udev_monitor_set_receive_buffer_size])

That is always going to fail - this AC_CHECK_FUNCS_ONCE macro is only
able to detect functions that are part of glibc.


Take a look at m4/virt-dbus.m4 for an example of how to check for a
function in another library, after detecting the library with pkgconfig


>  dnl Availability of various common headers (non-fatal if missing).
>  AC_CHECK_HEADERS([pwd.h regex.h sys/un.h \
> diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
> index a69dc1175..01438ea17 100644
> --- a/src/node_device/node_device_udev.c
> +++ b/src/node_device/node_device_udev.c
> @@ -1764,12 +1764,14 @@ static int nodeStateInitialize(bool privileged,
> 
>      udev_monitor_enable_receiving(priv->udev_monitor);
> 
> +#if HAVE_UDEV_MONITOR_SET_RECEIVE_BUFFER_SIZE
>      /* mimic udevd's behaviour and override the systems rmem_max limit in case
>       * there's a significant number of device 'add' events
>       */
>      if (geteuid() == 0)
>          udev_monitor_set_receive_buffer_size(priv->udev_monitor,
>                                               128 * 1024 * 1024);
> +#endif
> 
>      /* We register the monitor with the event callback so we are
>       * notified by udev of device changes before we enumerate existing
> --
> 2.13.0
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] udev: Fix build on older platforms
Posted by Michal Privoznik 6 years, 10 months ago
On 05/31/2017 12:22 PM, Erik Skultety wrote:
> Caused by commit @d1eea6c1 due to the missing symbol on older platforms.
> 
> Signed-off-by: Erik Skultety <eskultet@redhat.com>
> ---
> Despite falling under build-breaker category, I'd like to get a proper review,
> since I'm not really familiar with autoconf and there might be a better fix.
> 
> Erik
> 
>  configure.ac                       | 2 +-
>  src/node_device/node_device_udev.c | 2 ++
>  2 files changed, 3 insertions(+), 1 deletion(-)


diff --git a/m4/virt-udev.m4 b/m4/virt-udev.m4
index 85ca2cb1a..be7dba5d2 100644
--- a/m4/virt-udev.m4
+++ b/m4/virt-udev.m4
@@ -34,6 +34,14 @@ AC_DEFUN([LIBVIRT_CHECK_UDEV],[
      if test "$with_udev_logging" = "yes" ; then
         AC_DEFINE_UNQUOTED([HAVE_UDEV_LOGGING], 1, [whether libudev logging can be used])
      fi
+
+    old_CFLAGS="$CFLAGS"
+    old_LIBS="$LIBS"
+    CFLAGS="$CFLAGS $UDEV_CFLAGS"
+    LIBS="$CFLAGS $UDEV_LIBS"
+    AC_CHECK_FUNCS([udev_monitor_set_receive_buffer_size])
+    CFLAGS="$old_CFLAGS"
+    LIBS="$old_LIBS"
   fi
 ])


This is what I wanted to say, but Daniel beat me to it. ACK if you go this way.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] udev: Fix build on older platforms
Posted by Erik Skultety 6 years, 10 months ago
On Wed, May 31, 2017 at 12:44:37PM +0200, Michal Privoznik wrote:
> On 05/31/2017 12:22 PM, Erik Skultety wrote:
> > Caused by commit @d1eea6c1 due to the missing symbol on older platforms.
> >
> > Signed-off-by: Erik Skultety <eskultet@redhat.com>
> > ---
> > Despite falling under build-breaker category, I'd like to get a proper review,
> > since I'm not really familiar with autoconf and there might be a better fix.
> >
> > Erik
> >
> >  configure.ac                       | 2 +-
> >  src/node_device/node_device_udev.c | 2 ++
> >  2 files changed, 3 insertions(+), 1 deletion(-)
>
>
> diff --git a/m4/virt-udev.m4 b/m4/virt-udev.m4
> index 85ca2cb1a..be7dba5d2 100644
> --- a/m4/virt-udev.m4
> +++ b/m4/virt-udev.m4
> @@ -34,6 +34,14 @@ AC_DEFUN([LIBVIRT_CHECK_UDEV],[
>       if test "$with_udev_logging" = "yes" ; then
>          AC_DEFINE_UNQUOTED([HAVE_UDEV_LOGGING], 1, [whether libudev logging can be used])
>       fi
> +
> +    old_CFLAGS="$CFLAGS"
> +    old_LIBS="$LIBS"
> +    CFLAGS="$CFLAGS $UDEV_CFLAGS"
> +    LIBS="$CFLAGS $UDEV_LIBS"
> +    AC_CHECK_FUNCS([udev_monitor_set_receive_buffer_size])
> +    CFLAGS="$old_CFLAGS"
> +    LIBS="$old_LIBS"
>    fi
>  ])
>
>
> This is what I wanted to say, but Daniel beat me to it. ACK if you go this way.

Thanks, help's appreciated, the fix is not pushed.

Erik

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list