: Add -uuid option to Qemu
PATCH 2/3 : Add -uuid option to Qemu
As suggested by Anthony, this patch and the next one were split apart. This patch just adds the basic plumbing to qemu to be able to set the uuid on the command-line, and retrieve the information via "info uuid".
configure +22 -0
@@ -108,6 +108,7 @@ uname_release="" curses="yes" nptl="yes" mixemu="no" +uuid="yes" # OS specific targetos=`uname -s`
@@ -271,6 +272,8 @@ for opt do ;; --fmod-inc=*) fmod_inc="$optarg" ;; + --disable-uuid) uuid="no" + ;; --audio-card-list=*) audio_card_list="$optarg" ;; --audio-drv-list=*) audio_drv_list="$optarg"
@@ -433,6 +436,7 @@ echo " --enable-darwin-user enable echo " --disable-darwin-user disable all darwin usermode emulation targets" echo " --fmod-lib path to FMOD library" echo " --fmod-inc path to FMOD includes" +echo " --disable-uuid disable UUID support" echo " --enable-uname-release=R Return R for uname -r in usermode emulation" echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9" echo " --disable-vde disable support for vde network"
@@ -851,6 +855,19 @@ EOF fi fi # test "$curses" +########################################## +# 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 $ARCH_CFLAGS -o $TMPE $TMPC -luuid 2> /dev/null ; then + uuid=yes + fi +fi # test "$uuid" + # Check if tools are available to build documentation. if [ -x "`which texi2html 2>/dev/null`" ] && \ [ -x "`which pod2man 2>/dev/null`" ]; then
@@ -922,6 +939,7 @@ echo "Documentation $build_docs" echo "uname -r $uname_release" echo "NPTL support $nptl" echo "vde support $vde" +echo "UUID Support $uuid" if test $sdl_too_old = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -1122,6 +1140,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
Makefile.target +4 -0
@@ -515,6 +515,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
monitor.c +15 -0
@@ -1363,6 +1363,20 @@ static void do_inject_nmi(int cpu_index) }#endif +static void do_info_uuid (void ) +{ +extern char *qemu_uuid; +#ifdef CONFIG_UUID +term_printf ("uuid: " ); +if (qemu_uuid ==NULL ) +term_printf ("Not set\n" ); +else +term_printf ("%s\n" , qemu_uuid); +#else +term_printf ("uuid support: not compiled\n" ); +#endif +} +static term_cmd_t term_cmds[] = { {"help|?" ,"s?" , do_help,"[cmd]" ,"show the help" },
@@ -1502,6 +1516,7 @@ static term_cmd_t info_cmds[] = { { "slirp", "", do_info_slirp, "", "show SLIRP statistics", }, #endif + { "uuid", "", do_info_uuid, "", "show UUID information" }, { NULL, NULL, }, };
vl.c +15 -0
@@ -252,6 +252,8 @@ static int64_t qemu_icount_bias;QEMUTimer *icount_rt_timer;QEMUTimer *icount_vm_timer; +const char *qemu_uuid; +#define TFR (expr) do { if ((expr) != -1) break; } while (errno == EINTR)/***********************************************************/
@@ -7574,6 +7576,10 @@ static void help(int exitcode) "-no-shutdown stop before shutdown\n" "-loadvm [tag|id] start right away with a saved state (loadvm in monitor)\n" "-vnc display start a VNC server on display\n" +#ifdef CONFIG_UUID + "-uuid %%08x-%%04x-%%04x-%%012x\n" + " specify machine UUID\n" +#endif#ifndef _WIN32 "-daemonize daemonize QEMU after initializing\n"#endif
@@ -7690,6 +7696,7 @@ enum { QEMU_OPTION_clock, QEMU_OPTION_startdate, QEMU_OPTION_tb_size, + QEMU_OPTION_uuid, QEMU_OPTION_icount, };
@@ -7779,6 +7786,9 @@ const QEMUOption qemu_options[] = { #ifdef CONFIG_CURSES { "curses", 0, QEMU_OPTION_curses }, #endif +#ifdef CONFIG_UUID + { "uuid", HAS_ARG, QEMU_OPTION_uuid }, +#endif /* temporary options */ { "usb", 0, QEMU_OPTION_usb },
@@ -8553,6 +8563,11 @@ int main(int argc, char **argv)case QEMU_OPTION_daemonize: daemonize =1 ;break ; +#ifdef CONFIG_UUID +case QEMU_OPTION_uuid: + qemu_uuid = optarg; +break ; +#endif case QEMU_OPTION_option_rom:if (nb_option_roms >=MAX_OPTION_ROMS ) {fprintf (stderr,"Too many option ROMs\n" );
Quoted 3 lines · Chris Lalancette
As suggested by Anthony, this patch and the next one were split apart. This patch just adds the basic plumbing to qemu to be able to set the uuid on the command-line, and retrieve the information via "info uuid".
What is the point of CONFIG_UUID and the libuuid test in that patch? I can't see any dependency on it in the source code. IMHO the -uuid switch should be present unconditionally.
Oh, and I'd like to see a cleaned up patch merged soon, even if the qemu <=> bochs bios communication path isn't worked out yet. I need the uuid for xen support too.
cheers,
Gerd
PS: Anyone knows a way to make thunderbird include inline attachments in
the reply, so I can comment the patches better?
Signature · 1 line
http://kraxel.fedorapeople.org/xenner/
Quoted 8 lines · Gerd Hoffmann
Quoted 3 lines · Chris Lalancette
As suggested by Anthony, this patch and the next one were split apart. This patch just adds the basic plumbing to qemu to be able to set the uuid on the command-line, and retrieve the information via "info uuid".
What is the point of
CONFIG_UUIDand the libuuid test in that patch? I can't see any dependency on it in the source code. IMHO the -uuid switch should be present unconditionally.
Here is the patch series where there is no CONFIG_UUID test (was posted here two month ago):
http://lists.gnu.org/archive/html/qemu-devel/2008-06/msg00443.html
http://lists.gnu.org/archive/html/qemu-devel/2008-06/msg00444.html
And this one checks for libuuid and uses it for random uuid generation if available (UUID should be RFC compliant):
http://lists.gnu.org/archive/html/qemu-devel/2008-06/msg00446.html
--
Gleb.
Am 05.08.2008 um 15:53 schrieb Gleb Natapov:
Quoted 9 lines · Gerd Hoffmann
Quoted 8 lines
Quoted 3 lines · Chris Lalancette
As suggested by Anthony, this patch and the next one were split apart. This patch just adds the basic plumbing to qemu to be able to set the uuid on the command-line, and retrieve the information via "info uuid".
What is the point of
CONFIG_UUIDand the libuuid test in that patch? I can't see any dependency on it in the source code. IMHO the -uuid switch should be present unconditionally.
Quoted 8 lines
Here is the patch series where there is no
CONFIG_UUIDtest (was posted here two month ago):
http://lists.gnu.org/archive/html/qemu-devel/2008-06/msg00443.html
http://lists.gnu.org/archive/html/qemu-devel/2008-06/msg00444.htmlAnd this one checks for libuuid and uses it for random uuid generation if available (UUID should be RFC compliant):
http://lists.gnu.org/archive/html/qemu-devel/2008-06/msg00446.html
It seemed general consensus that we don't want values randomly generated at runtime in QEMU, rather having some constant, widely acceptable value and leaving it to either management tools or the user determining them. There was a long discussion about this topic before, concerning IPv4 subnets.
I don't really see a use case where we'd want a universally unique ID generated by QEMU at runtime either - it would seem better to generate it using some external tool (e.g., uuidgen or GUIDgen) and then pass the same value as command line argument (or config file option) to a certain virtual machine. After all it's supposed to be unique and not changing with each QEMU invocation.
Andreas
Quoted 8 lines · Gerd Hoffmann
Quoted 3 lines · Chris Lalancette
As suggested by Anthony, this patch and the next one were split apart. This patch just adds the basic plumbing to qemu to be able to set the uuid on the command-line, and retrieve the information via "info uuid".
What is the point of
CONFIG_UUIDand the libuuid test in that patch? I can't see any dependency on it in the source code. IMHO the -uuid switch should be present unconditionally.
Hm, CONFIG_UUID is used, for instance, to control whether we output the -uuid part of the help string. There are other uses in the patch as well.
I think the problem with including it unconditionally is that it drags in the uuid library, which may or may not always be available. Now, as far as I can tell, that library comes with e2fsprogs, so basically any Linux system will have it, but that might not be the case for other OS's.
Chris Lalancette
Quoted 11 lines · Chris Lalancette
Quoted 7 lines · Gerd Hoffmann
Quoted 3 lines · Chris Lalancette
As suggested by Anthony, this patch and the next one were split apart. This patch just adds the basic plumbing to qemu to be able to set the uuid on the command-line, and retrieve the information via "info uuid".
What is the point of
CONFIG_UUIDand the libuuid test in that patch? I can't see any dependency on it in the source code. IMHO the -uuid switch should be present unconditionally.Hm,
CONFIG_UUIDis used, for instance, to control whether we output the -uuid part of the help string. There are other uses in the patch as well.
Sure.
Quoted 2 lines
I think the problem with including it unconditionally is that it drags in the uuid library, which may or may not always be available.
Does it? As far I can see none of the bits wrapped into #ifdef CONFIG_UUID actually calls that library.
If you wanna do stuff like generating a uuid in case none was specified on the command line, _then_ you'll need libuuid and those parts should be compiled conditionally. I don't see the point for the -uuid cmd line switch though.
Gleb's patches seem to have organized things this way according to his reply (didn't check list archive).
cheers,
Gerd
Signature · 1 line
http://kraxel.fedorapeople.org/xenner/