[libvirt] [PATCH] small compilation problem with old dbus versions

Daniel P. Berrange berrange at redhat.com
Fri Dec 5 14:31:17 UTC 2008


On Fri, Dec 05, 2008 at 03:18:04PM +0100, Daniel Veillard wrote:
> dbus_watch_get_unix_fd() was added in dbus >= 1.1.1, it deprecate
> dbus_watch_get_fd(), so we should use the later if compiling against
> the old stuff,
  
> -    info->watch = virEventAddHandle(dbus_watch_get_unix_fd(watch), flags,
> -                                    dbus_watch_callback, watch, NULL);
> +#if (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR == 1 && DBUS_VERSION_MICRO >= 1) || (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MAJOR > 1) || (DBUS_VERSION_MAJOR > 1) 

This conditional is rather painful to read. I think we'd be better
off just explicitly checking for the function

In configure where we already have the HALL check 

    old_CFLAGS=$CFLAGS
    old_LDFLAGS=$LDFLAGS
    CFLAGS="$CFLAGS $HAL_CFLAGS"
    LDFLAGS="$LDFLAGS $HAL_LIBS"
    AC_CHECK_FUNCS([libhal_get_all_devices],,[with_hal=no])
    CFLAGS="$old_CFLAGS"
    LDFLAGS="$old_LDFLAGS"


Change to

    old_CFLAGS=$CFLAGS
    old_LDFLAGS=$LDFLAGS
    CFLAGS="$CFLAGS $HAL_CFLAGS"
    LDFLAGS="$LDFLAGS $HAL_LIBS"
    AC_CHECK_FUNCS([libhal_get_all_devices],,[with_hal=no])
    AC_CHECK_FUNCS([dbus_watch_get_unix_fd])
    CFLAGS="$old_CFLAGS"
    LDFLAGS="$old_LDFLAGS"

So we can then just do

#if HAVE_DBUS_WATCH_GET_UNIX_FD

> +    fd = dbus_watch_get_unix_fd(watch);
> +#else
> +    fd = dbus_watch_get_fd(watch);
> +#endif
> +    info->watch = virEventAddHandle(fd, flags, dbus_watch_callback,
> +                                    watch, NULL);
>      if (info->watch < 0) {
>          VIR_FREE(info);
>          return 0;

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list