qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 4/6] Use libuuid if available.


From: Gleb Natapov
Subject: Re: [Qemu-devel] [PATCH v2 4/6] Use libuuid if available.
Date: Mon, 25 Aug 2008 17:03:51 +0300

On Mon, Aug 25, 2008 at 01:45:53PM +0200, Andreas Färber wrote:
>>> I don't remember hearing an answer on why this is necessary. For  
>>> which
>>> use case can't you just either use -uuid `uuidgen` or a hardcoded
>>> default value like the Slirp IPv4 subnet?
>> It can be used for UUID generation when VM is started for the first  
>> time.
>> Management application can retrieve UUID using monitor and use it for
>> consequent runs. But the same result can be achieved in a different  
>> way
>> too. So no, I really don't have a strong use case for this feature,  
>> but
>> the patch set is organised in such way that it is possible to ignore
>> this particular patch.
>
> Okay, then I'd ask to invert the logic so that the user has to  
> explicitly ask for it, maybe -uuid random (setting generate_uuid = 0 by 
> default and =1 in that case). Then no accidental damage should be done 
> and a Management Application can still use it.
>
Something like this?

---
    Use libuuid if available.
    
    If libuuid is available use it for UUID generation in case a user
    asks for it.
    
    Signed-off-by: Gleb Natapov <address@hidden>

diff --git a/Makefile.target b/Makefile.target
index 2464484..54defd9 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -518,6 +518,10 @@ CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
 LIBS += $(CONFIG_VNC_TLS_LIBS)
 endif
 
+ifdef CONFIG_UUID
+LIBS += -luuid
+endif
+
 # SCSI layer
 OBJS+= lsi53c895a.o esp.o
 
diff --git a/configure b/configure
index acb4a4a..fa46a64 100755
--- a/configure
+++ b/configure
@@ -110,6 +110,7 @@ curses="yes"
 aio="yes"
 nptl="yes"
 mixemu="no"
+uuid="yes"
 
 # OS specific
 targetos=`uname -s`
@@ -316,6 +317,8 @@ for opt do
   ;;
   --enable-uname-release=*) uname_release="$optarg"
   ;;
+  --disable-uuid) uuid="no"
+  ;;
   --sparc_cpu=*)
       sparc_cpu="$optarg"
       case $sparc_cpu in
@@ -780,6 +783,19 @@ EOF
 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 "uname -r          $uname_release"
 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 @@ if test "$vnc_tls" = "yes" ; then
   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
diff --git a/vl.c b/vl.c
index 30fef2a..655dd3c 100644
--- a/vl.c
+++ b/vl.c
@@ -142,6 +142,11 @@ int inet_aton(const char *cp, struct in_addr *ia);
 
 #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,12 @@ int main(int argc, char **argv)
                 cursor_hide = 0;
                 break;
             case QEMU_OPTION_uuid:
+#ifdef CONFIG_UUID
+                if (strcmp(optarg, "gen") == 0) {
+                    generate_uuid = 1;
+                    break;
+                }
+#endif
                 if(qemu_uuid_parse(optarg, qemu_uuid) < 0) {
                     fprintf(stderr, "Fail to parse UUID string."
                             " Wrong format.\n");
@@ -8908,6 +8919,11 @@ int main(int argc, char **argv)
            monitor_device = "stdio";
     }
 
+#if CONFIG_UUID
+    if (generate_uuid)
+        uuid_generate(qemu_uuid);
+#endif
+
 #ifndef _WIN32
     if (daemonize) {
        pid_t pid;
--
                        Gleb.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]