From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/5] Use libuuid if available.
Date: Thu, 05 Jun 2008 10:18:15 -0500 [thread overview]
Message-ID: <484803B7.50908@codemonkey.ws> (raw)
In-Reply-To: <20080605083551.11678.57336.stgit@gleb-debian.qumranet.com.qumranet.com>
Gleb Natapov wrote:
> If libuuid is available use it for input validation and UUID generation if
> user does not provide one.
>
> Signed-off-by: Gleb Natapov <gleb@qumranet.com>
> ---
>
> Makefile.target | 4 ++++
> configure | 14 ++++++++++++++
> monitor.c | 10 ++++++++++
> vl.c | 17 +++++++++++++++++
> 4 files changed, 45 insertions(+), 0 deletions(-)
>
> diff --git a/Makefile.target b/Makefile.target
> index e06a99e..c1385af 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -502,6 +502,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 f204d04..49ee04c 100755
> --- a/configure
> +++ b/configure
> @@ -113,6 +113,7 @@ build_docs="no"
> uname_release=""
> curses="yes"
> nptl="yes"
> +uuid="yes"
>
> # OS specific
> targetos=`uname -s`
> @@ -314,6 +315,8 @@ for opt do
> ;;
> --enable-uname-release=*) uname_release="$optarg"
> ;;
> + --disable-uuid) uuid="no"
> + ;;
> --sparc_cpu=*)
> sparc_cpu="$optarg"
> case $sparc_cpu in
> @@ -728,6 +731,12 @@ if test "$vnc_tls" = "yes" ; then
> fi
>
> ##########################################
> +# uuid library
> +if test "$uuid" = "yes" ; then
> + `pkg-config uuid` || uuid="no"
> +fi
> +
> +##########################################
>
Need to redirect stderr to avoid ugly warnings to the user if the
command isn't found. Make sure you test with pkg-config renamed and
ensure that no nasty messages get printed.
> # alsa sound support libraries
>
> if test "$alsa" = "yes" ; then
> @@ -862,6 +871,7 @@ echo "Documentation $build_docs"
> [ ! -z "$uname_release" ] && \
> echo "uname -r $uname_release"
> echo "NPTL support $nptl"
> +echo "UUID support $uuid"
>
> if test $sdl_too_old = "yes"; then
> echo "-> Your SDL version is too old - please upgrade to have SDL support"
> @@ -1070,6 +1080,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/monitor.c b/monitor.c
> index 9233625..1cc9079 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -47,6 +47,10 @@
> #define offsetof(type, field) ((size_t) &((type *)0)->field)
> #endif
>
> +#ifdef CONFIG_UUID
> +#include <uuid/uuid.h>
> +extern uuid_t qemu_uuid;
> +#endif
>
uuid_t is just an unsigned char[16] so just use that to represent that
data type. That will eliminate a lot of the CONFIG_UUID stuff.
> /*
> * Supported types:
> *
> @@ -256,8 +260,14 @@ static void do_info_name(void)
>
> static void do_info_uuid(void)
> {
> +#ifdef CONFIG_UUID
> + char uuid_str[37];
> + uuid_unparse(qemu_uuid, uuid_str);
> + term_printf("%s\n", uuid_str);
> +#else
>
Just use a printf() string here again to eliminate the need for CONFIG_UUID.
Regards,
Anthony Liguori
> if (qemu_uuid_str)
> term_printf("%s\n", qemu_uuid_str);
> +#endif
> }
>
> static void do_info_block(void)
> diff --git a/vl.c b/vl.c
> index 8e9e841..be31263 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -131,6 +131,11 @@ int inet_aton(const char *cp, struct in_addr *ia);
>
> #include "exec-all.h"
>
> +#ifdef CONFIG_UUID
> +#include <uuid/uuid.h>
> +uuid_t qemu_uuid;
> +#endif
> +
> #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
> #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
> #ifdef __sun__
> @@ -8234,6 +8239,13 @@ int main(int argc, char **argv)
> break;
> case QEMU_OPTION_uuid:
> qemu_uuid_str = optarg;
> +#ifdef CONFIG_UUID
> + if (uuid_parse(qemu_uuid_str, qemu_uuid) < 0) {
> + 2 fprintf(stderr, "Fail to parse UUID string."
> + " Wrong format.\n");
> + exit(1);
> + }
> +#endif
> break;
> case QEMU_OPTION_daemonize:
> daemonize = 1;
> @@ -8317,6 +8329,11 @@ int main(int argc, char **argv)
> }
> }
>
> +#if CONFIG_UUID
> + if (!qemu_uuid_str)
> + uuid_generate(qemu_uuid);
> +#endif
> +
> #ifndef _WIN32
> if (daemonize && !nographic && vnc_display == NULL) {
> fprintf(stderr, "Can only daemonize if using -nographic or -vnc\n");
>
>
>
>
next prev parent reply other threads:[~2008-06-05 15:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-05 8:35 [Qemu-devel] [PATCH 1/5] Add OUT support to vmport Gleb Natapov
2008-06-05 8:35 ` [Qemu-devel] [PATCH 2/5] Add -uuid command line option Gleb Natapov
2008-06-05 15:13 ` Anthony Liguori
2008-06-05 8:35 ` [Qemu-devel] [PATCH 3/5] Add "info uuid" command to monitor Gleb Natapov
2008-06-05 15:14 ` Anthony Liguori
2008-06-05 8:35 ` [Qemu-devel] [PATCH 4/5] Use libuuid if available Gleb Natapov
2008-06-05 15:18 ` Anthony Liguori [this message]
2008-06-05 20:20 ` Gleb Natapov
2008-06-05 20:27 ` Anthony Liguori
2008-06-05 22:22 ` Paul Brook
2008-06-06 0:18 ` Anthony Liguori
2008-06-06 9:18 ` Daniel P. Berrange
2008-06-05 8:35 ` [Qemu-devel] [PATCH 5/5] Add support for UUID query to vmport interface Gleb Natapov
2008-06-05 15:19 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=484803B7.50908@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).