From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KXcvj-0004tw-BO for qemu-devel@nongnu.org; Mon, 25 Aug 2008 10:20:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KXcvi-0004sk-FL for qemu-devel@nongnu.org; Mon, 25 Aug 2008 10:20:26 -0400 Received: from [199.232.76.173] (port=53303 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KXcvh-0004sG-Qc for qemu-devel@nongnu.org; Mon, 25 Aug 2008 10:20:26 -0400 Received: from il.qumranet.com ([212.179.150.194]:16935) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KXcfg-00041x-N0 for qemu-devel@nongnu.org; Mon, 25 Aug 2008 10:03:53 -0400 Date: Mon, 25 Aug 2008 17:03:51 +0300 From: Gleb Natapov Subject: Re: [Qemu-devel] [PATCH v2 4/6] Use libuuid if available. Message-ID: <20080825140351.GO6192@minantech.com> References: <20080825095800.18703.30602.stgit@gleb-debian.qumranet.com.qumranet.com> <20080825095820.18703.69963.stgit@gleb-debian.qumranet.com.qumranet.com> <20080825112621.GL6192@minantech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?utf-8?Q?F=C3=A4rber?= Cc: qemu-devel@nongnu.org On Mon, Aug 25, 2008 at 01:45:53PM +0200, Andreas F=C3=A4rber wrote: >>> I don't remember hearing an answer on why this is necessary. For =20 >>> 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 =20 >> time. >> Management application can retrieve UUID using monitor and use it for >> consequent runs. But the same result can be achieved in a different =20 >> way >> too. So no, I really don't have a strong use case for this feature, =20 >> 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 =20 > explicitly ask for it, maybe -uuid random (setting generate_uuid =3D 0 by= =20 > default and =3D1 in that case). Then no accidental damage should be done= =20 > and a Management Application can still use it. > Something like this? --- Use libuuid if available. =20 If libuuid is available use it for UUID generation in case a user asks for it. =20 Signed-off-by: Gleb Natapov diff --git a/Makefile.target b/Makefile.target index 2464484..54defd9 100644 --- a/Makefile.target +++ b/Makefile.target @@ -518,6 +518,10 @@ CPPFLAGS +=3D $(CONFIG_VNC_TLS_CFLAGS) LIBS +=3D $(CONFIG_VNC_TLS_LIBS) endif =20 +ifdef CONFIG_UUID +LIBS +=3D -luuid +endif + # SCSI layer OBJS+=3D lsi53c895a.o esp.o =20 diff --git a/configure b/configure index acb4a4a..fa46a64 100755 --- a/configure +++ b/configure @@ -110,6 +110,7 @@ curses=3D"yes" aio=3D"yes" nptl=3D"yes" mixemu=3D"no" +uuid=3D"yes" =20 # OS specific targetos=3D`uname -s` @@ -316,6 +317,8 @@ for opt do ;; --enable-uname-release=3D*) uname_release=3D"$optarg" ;; + --disable-uuid) uuid=3D"no" + ;; --sparc_cpu=3D*) sparc_cpu=3D"$optarg" case $sparc_cpu in @@ -780,6 +783,19 @@ EOF fi =20 ########################################## +# uuid library +if test "$uuid" =3D "yes" ; then + uuid=3Dno + cat > $TMPC << EOF +#include +int main(void) { uuid_t u; return 0; } +EOF + if $cc -o $TMPE $TMPC -luuid 2> /dev/null ; then + uuid=3Dyes + fi +fi + +########################################## # Sound support libraries probe =20 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" =20 if test $sdl_too_old =3D "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" @@ -1168,6 +1185,10 @@ if test "$vnc_tls" =3D "yes" ; then echo "CONFIG_VNC_TLS_LIBS=3D$vnc_tls_libs" >> $config_mak echo "#define CONFIG_VNC_TLS 1" >> $config_h fi +if test "$uuid" =3D "yes" ; then + echo "CONFIG_UUID=3Dyes" >> $config_mak + echo "#define CONFIG_UUID 1" >> $config_h +fi qemu_version=3D`head $source_path/VERSION` echo "VERSION=3D$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); =20 #include "exec-all.h" =20 +#ifdef CONFIG_UUID +#include +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 =3D 0; break; case QEMU_OPTION_uuid: +#ifdef CONFIG_UUID + if (strcmp(optarg, "gen") =3D=3D 0) { + generate_uuid =3D 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 =3D "stdio"; } =20 +#if CONFIG_UUID + if (generate_uuid) + uuid_generate(qemu_uuid); +#endif + #ifndef _WIN32 if (daemonize) { pid_t pid; -- Gleb.