                                                                                                                                                                                                                                                               
Delivered-To: blauwirbel@gmail.com
Received: by 10.143.166.2 with SMTP id t2cs70005wfo;
        Thu, 28 Aug 2008 10:20:46 -0700 (PDT)
Received: by 10.151.150.20 with SMTP id c20mr2560045ybo.6.1219944045566;
        Thu, 28 Aug 2008 10:20:45 -0700 (PDT)
Return-Path: <qemu-devel-bounces+blauwirbel=gmail.com@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [199.232.76.165])
        by mx.google.com with ESMTP id i27si1399904elf.4.2008.08.28.10.20.44;
        Thu, 28 Aug 2008 10:20:45 -0700 (PDT)
Received-SPF: pass (google.com: domain of qemu-devel-bounces+blauwirbel=gmail.com@nongnu.org designates 199.232.76.165 as permitted sender) client-ip=199.232.76.165;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+blauwirbel=gmail.com@nongnu.org designates 199.232.76.165 as permitted sender) smtp.mail=qemu-devel-bounces+blauwirbel=gmail.com@nongnu.org
Received: from localhost ([127.0.0.1]:57474 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43)
	id 1KYkrh-0002CI-RJ
	for blauwirbel@gmail.com; Thu, 28 Aug 2008 13:00:57 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1KYkju-0000CV-T2
	for qemu-devel@nongnu.org; Thu, 28 Aug 2008 12:52:54 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1KYkju-0000Be-AA
	for qemu-devel@nongnu.org; Thu, 28 Aug 2008 12:52:54 -0400
Received: from [199.232.76.173] (port=36290 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1KYkju-0000BS-6S
	for qemu-devel@nongnu.org; Thu, 28 Aug 2008 12:52:54 -0400
Received: from il.qumranet.com ([212.179.150.194]:48336)
	by monty-python.gnu.org with esmtp (Exim 4.60)
	(envelope-from <gleb@qumranet.com>) id 1KYkjt-0004oB-PV
	for qemu-devel@nongnu.org; Thu, 28 Aug 2008 12:52:54 -0400
Received: from gleb-debian.qumranet.com (gleb-debian.qumranet.com.qumranet.com
	[172.16.15.143])
	by il.qumranet.com (Postfix) with ESMTP id A0A3A250DB2
	for <qemu-devel@nongnu.org>; Thu, 28 Aug 2008 19:52:52 +0300 (IDT)
Received: from gleb-debian.qumranet.com.qumranet.com (localhost [127.0.0.1])
	by gleb-debian.qumranet.com (Postfix) with ESMTP id 9FF2818D48F
	for <qemu-devel@nongnu.org>; Thu, 28 Aug 2008 19:52:52 +0300 (IDT)
From: Gleb Natapov <gleb@qumranet.com>
To: qemu-devel@nongnu.org
Date: Thu, 28 Aug 2008 19:52:52 +0300
Message-ID: <20080828165252.22851.76015.stgit@gleb-debian.qumranet.com.qumranet.com>
In-Reply-To: <20080828165232.22851.77678.stgit@gleb-debian.qumranet.com.qumranet.com>
References: <20080828165232.22851.77678.stgit@gleb-debian.qumranet.com.qumranet.com>
User-Agent: StGIT/0.14.2
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 1)
Subject: [Qemu-devel] [PATCH v3 4/6] Use libuuid if available.
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: qemu-devel@nongnu.org
List-Id: qemu-devel.nongnu.org
List-Unsubscribe: <http://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <http://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Sender: qemu-devel-bounces+blauwirbel=gmail.com@nongnu.org
Errors-To: qemu-devel-bounces+blauwirbel=gmail.com@nongnu.org

If libuuid is available use it for UUID generation in case a user asks for it.

Signed-off-by: Gleb Natapov <gleb@qumranet.com>
---

 Makefile.target |    4 ++++
 configure       |   21 +++++++++++++++++++++
 vl.c            |   16 ++++++++++++++++
 3 files changed, 41 insertions(+), 0 deletions(-)

Index: qemu/Makefile.target
===================================================================
--- qemu.orig/Makefile.target	2008-08-31 12:35:25.000000000 +0000
+++ qemu/Makefile.target	2008-08-31 12:35:36.000000000 +0000
@@ -519,6 +519,10 @@
 LIBS += $(CONFIG_VNC_TLS_LIBS)
 endif
 
+ifdef CONFIG_UUID
+LIBS += -luuid
+endif
+
 # SCSI layer
 OBJS+= lsi53c895a.o esp.o
 
Index: qemu/configure
===================================================================
--- qemu.orig/configure	2008-08-31 12:34:52.000000000 +0000
+++ qemu/configure	2008-08-31 12:35:36.000000000 +0000
@@ -110,6 +110,7 @@
 aio="yes"
 nptl="yes"
 mixemu="no"
+uuid="yes"
 
 # OS specific
 targetos=`uname -s`
@@ -316,6 +317,8 @@
   ;;
   --enable-uname-release=*) uname_release="$optarg"
   ;;
+  --disable-uuid) uuid="no"
+  ;;
   --sparc_cpu=*)
       sparc_cpu="$optarg"
       case $sparc_cpu in
@@ -780,6 +783,19 @@
 fi
 
 ##########################################
+# uuid library
+if test "$uuid" = "yes" ; then
+  uuid=no
+  cat > $TMPC << EOF
+#include <uuid/uuid.h>
+int main(void) { uuid_t u; return 0; }
+EOF
+  if $cc -o $TMPE $TMPC -luuid 2> /dev/null ; then
+    uuid=yes
+  fi
+fi
+
+##########################################
 # Sound support libraries probe
 
 audio_drv_probe()
@@ -961,6 +977,7 @@
 echo "NPTL support      $nptl"
 echo "vde support       $vde"
 echo "AIO support       $aio"
+echo "UUID support      $uuid"
 
 if test $sdl_too_old = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -1168,6 +1185,10 @@
   echo "CONFIG_VNC_TLS_LIBS=$vnc_tls_libs" >> $config_mak
   echo "#define CONFIG_VNC_TLS 1" >> $config_h
 fi
+if test "$uuid" = "yes" ; then
+  echo "CONFIG_UUID=yes" >> $config_mak
+  echo "#define CONFIG_UUID 1" >> $config_h
+fi
 qemu_version=`head $source_path/VERSION`
 echo "VERSION=$qemu_version" >>$config_mak
 echo "#define QEMU_VERSION \"$qemu_version\"" >> $config_h
Index: qemu/vl.c
===================================================================
--- qemu.orig/vl.c	2008-08-31 12:35:30.000000000 +0000
+++ qemu/vl.c	2008-08-31 12:35:36.000000000 +0000
@@ -142,6 +142,11 @@
 
 #include "exec-all.h"
 
+#ifdef CONFIG_UUID
+#include <uuid/uuid.h>
+static int generate_uuid;
+#endif
+
 #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
 #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
 #ifdef __sun__
@@ -8803,6 +8808,15 @@
                 cursor_hide = 0;
                 break;
             case QEMU_OPTION_uuid:
+                if (strcmp(optarg, "gen") == 0) {
+#ifdef CONFIG_UUID
+                    generate_uuid = 1;
+                    break;
+#else
+                    fprintf(stderr, "UUID generation not supported.\n");
+                    exit(1);
+#endif
+                }
                 if(qemu_uuid_parse(optarg, qemu_uuid) < 0) {
                     fprintf(stderr, "Fail to parse UUID string."
                             " Wrong format.\n");
@@ -8908,6 +8922,11 @@
            monitor_device = "stdio";
     }
 
+#ifdef CONFIG_UUID
+    if (generate_uuid)
+        uuid_generate(qemu_uuid);
+#endif
+
 #ifndef _WIN32
     if (daemonize) {
 	pid_t pid;
