If libuuid from e2fsprogs is available, we use that to
generate UUIDs.

Signed-off-by: Mark McLoughlin <[EMAIL PROTECTED]>

Index: libvirt/configure.in
===================================================================
--- libvirt.orig/configure.in
+++ libvirt/configure.in
@@ -189,6 +189,22 @@ dnl
 AC_CHECK_HEADERS(linux/param.h linux/sockios.h linux/if_bridge.h 
linux/if_tun.h,,
                  AC_MSG_ERROR([You must install kernel-headers in order to 
compile libvirt]))
 
+dnl
+dnl check for libuuid
+dnl
+AC_ARG_ENABLE(libuuid,
+              AC_HELP_STRING([--disable-libuuid],
+                             [disable support for generating UUIDs using 
e2fsprogs libuuid [default=no]]),,
+              enable_libuuid=yes)
+
+if test "x$enable_libuuid" == "xyes" ; then
+    AC_CHECK_LIB(uuid, uuid_generate,
+                 [AC_CHECK_HEADER(uuid/uuid.h,
+                                 AC_DEFINE(ENABLE_LIBUUID,, [enable generating 
UUIDs using libuuid])
+                                 UUID_LIBS="-luuid" AC_SUBST(UUID_LIBS),
+                                 AC_MSG_ERROR([You must install libuuid in 
order to compile libvirt]))])
+fi
+
 dnl ==========================================================================
 dnl find libxml2 library, borrowed from xmlsec
 dnl ==========================================================================
Index: libvirt/qemud/Makefile.am
===================================================================
--- libvirt.orig/qemud/Makefile.am
+++ libvirt/qemud/Makefile.am
@@ -16,7 +16,7 @@ libvirt_qemud_CFLAGS = \
         -I$(top_srcdir)/include -I$(top_builddir)/include $(LIBXML_CFLAGS) \
         -Wall -Wextra -DLOCAL_STATE_DIR="\"$(localstatedir)\"" \
         -DSYSCONF_DIR="\"$(sysconfdir)\""
-libvirt_qemud_LDFLAGS = $(LIBXML_LIBS) $(SYSFS_LIBS)
+libvirt_qemud_LDFLAGS = $(LIBXML_LIBS) $(SYSFS_LIBS) $(UUID_LIBS)
 libvirt_qemud_DEPENDENCIES =
 libvirt_qemud_LDADD =
 
Index: libvirt/qemud/uuid.c
===================================================================
--- libvirt.orig/qemud/uuid.c
+++ libvirt/qemud/uuid.c
@@ -23,6 +23,9 @@
 
 #include "uuid.h"
 
+#ifdef ENABLE_LIBUUID
+#include <uuid/uuid.h>
+#else
 #include <errno.h>
 #include <fcntl.h>
 #include <stdlib.h>
@@ -34,6 +37,18 @@
 
 #include "protocol.h"
 #include "internal.h"
+#endif
+
+#ifdef ENABLE_LIBUUID
+
+int
+qemudGenerateUUID(unsigned char *uuid)
+{
+    uuid_generate(uuid);
+    return 0;
+}
+
+#else /* ENABLE_LIBUUID */
 
 static int
 qemudGenerateRandomBytes(unsigned char *buf,
@@ -89,6 +104,8 @@ qemudGenerateUUID(unsigned char *uuid)
     return qemudGeneratePseudoRandomBytes(uuid, QEMUD_UUID_RAW_LEN);
 }
 
+#endif /* ENABLE_LIBUUID */
+
 int
 qemudParseUUID(const char *uuid, unsigned char *rawuuid) {
     const char *cur;

-- 

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

Reply via email to