Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KgOFb-0001qk-HF for qemu-devel@nongnu.org; Thu, 18 Sep 2008 14:29:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KgOFZ-0001q7-Ti for qemu-devel@nongnu.org; Thu, 18 Sep 2008 14:29:10 -0400 Received: from [199.232.76.173] (port=50910 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KgOFZ-0001q2-Lm for qemu-devel@nongnu.org; Thu, 18 Sep 2008 14:29:09 -0400 Received: from savannah.gnu.org ([199.232.41.3]:41480 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KgOFZ-00046P-8W for qemu-devel@nongnu.org; Thu, 18 Sep 2008 14:29:09 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KgOFY-0001Nu-OH for qemu-devel@nongnu.org; Thu, 18 Sep 2008 18:29:08 +0000 Received: from blueswir1 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KgOFY-0001No-BN for qemu-devel@nongnu.org; Thu, 18 Sep 2008 18:29:08 +0000 MIME-Version: 1.0 Errors-To: blueswir1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Blue Swirl Message-Id: Date: Thu, 18 Sep 2008 18:29:08 +0000 Subject: [Qemu-devel] [5257] Add -uuid command line option (Gleb Natapov) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5257 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5257 Author: blueswir1 Date: 2008-09-18 18:29:08 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Add -uuid command line option (Gleb Natapov) Modified Paths: -------------- trunk/sysemu.h trunk/vl.c Modified: trunk/sysemu.h =================================================================== --- trunk/sysemu.h 2008-09-18 18:27:29 UTC (rev 5256) +++ trunk/sysemu.h 2008-09-18 18:29:08 UTC (rev 5257) @@ -8,6 +8,8 @@ extern int vm_running; extern const char *qemu_name; +extern uint8_t qemu_uuid[]; +#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" typedef struct vm_change_state_entry VMChangeStateEntry; typedef void VMChangeStateHandler(void *opaque, int running); Modified: trunk/vl.c =================================================================== --- trunk/vl.c 2008-09-18 18:27:29 UTC (rev 5256) +++ trunk/vl.c 2008-09-18 18:29:08 UTC (rev 5257) @@ -254,6 +254,8 @@ QEMUTimer *icount_rt_timer; QEMUTimer *icount_vm_timer; +uint8_t qemu_uuid[16]; + #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) /***********************************************************/ @@ -7700,6 +7702,7 @@ "-g WxH[xDEPTH] Set the initial graphical resolution and depth\n" #endif "-name string set the name of the guest\n" + "-uuid %%08x-%%04x-%%04x-%%04x-%%012x specify machine UUID\n" "\n" "Network options:\n" "-net nic[,vlan=n][,macaddr=addr][,model=type]\n" @@ -7894,6 +7897,7 @@ QEMU_OPTION_startdate, QEMU_OPTION_tb_size, QEMU_OPTION_icount, + QEMU_OPTION_uuid, }; typedef struct QEMUOption { @@ -7982,6 +7986,7 @@ #ifdef CONFIG_CURSES { "curses", 0, QEMU_OPTION_curses }, #endif + { "uuid", HAS_ARG, QEMU_OPTION_uuid }, /* temporary options */ { "usb", 0, QEMU_OPTION_usb }, @@ -8192,6 +8197,23 @@ } #endif +static int qemu_uuid_parse(const char *str, uint8_t *uuid) +{ + int ret; + + if(strlen(str) != 36) + return -1; + + ret = sscanf(str, UUID_FMT, &uuid[0], &uuid[1], &uuid[2], &uuid[3], + &uuid[4], &uuid[5], &uuid[6], &uuid[7], &uuid[8], &uuid[9], + &uuid[10], &uuid[11], &uuid[12], &uuid[13], &uuid[14], &uuid[15]); + + if(ret != 16) + return -1; + + return 0; +} + #define MAX_NET_CLIENTS 32 #ifndef _WIN32 @@ -8770,6 +8792,13 @@ case QEMU_OPTION_show_cursor: cursor_hide = 0; break; + case QEMU_OPTION_uuid: + if(qemu_uuid_parse(optarg, qemu_uuid) < 0) { + fprintf(stderr, "Fail to parse UUID string." + " Wrong format.\n"); + exit(1); + } + break; case QEMU_OPTION_daemonize: daemonize = 1; break;