Commit 8fcb1b90cdd14a53c442455c74d7593edeb07d7a

Authored by blueswir1
1 parent 3cce6243

Add -uuid command line option (Gleb Natapov)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5257 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 31 additions and 0 deletions
sysemu.h
... ... @@ -8,6 +8,8 @@ extern const char *bios_dir;
8 8  
9 9 extern int vm_running;
10 10 extern const char *qemu_name;
  11 +extern uint8_t qemu_uuid[];
  12 +#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
11 13  
12 14 typedef struct vm_change_state_entry VMChangeStateEntry;
13 15 typedef void VMChangeStateHandler(void *opaque, int running);
... ...
... ... @@ -254,6 +254,8 @@ static int64_t qemu_icount_bias;
254 254 QEMUTimer *icount_rt_timer;
255 255 QEMUTimer *icount_vm_timer;
256 256  
  257 +uint8_t qemu_uuid[16];
  258 +
257 259 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
258 260  
259 261 /***********************************************************/
... ... @@ -7700,6 +7702,7 @@ static void help(int exitcode)
7700 7702 "-g WxH[xDEPTH] Set the initial graphical resolution and depth\n"
7701 7703 #endif
7702 7704 "-name string set the name of the guest\n"
  7705 + "-uuid %%08x-%%04x-%%04x-%%04x-%%012x specify machine UUID\n"
7703 7706 "\n"
7704 7707 "Network options:\n"
7705 7708 "-net nic[,vlan=n][,macaddr=addr][,model=type]\n"
... ... @@ -7894,6 +7897,7 @@ enum {
7894 7897 QEMU_OPTION_startdate,
7895 7898 QEMU_OPTION_tb_size,
7896 7899 QEMU_OPTION_icount,
  7900 + QEMU_OPTION_uuid,
7897 7901 };
7898 7902  
7899 7903 typedef struct QEMUOption {
... ... @@ -7982,6 +7986,7 @@ const QEMUOption qemu_options[] = {
7982 7986 #ifdef CONFIG_CURSES
7983 7987 { "curses", 0, QEMU_OPTION_curses },
7984 7988 #endif
  7989 + { "uuid", HAS_ARG, QEMU_OPTION_uuid },
7985 7990  
7986 7991 /* temporary options */
7987 7992 { "usb", 0, QEMU_OPTION_usb },
... ... @@ -8192,6 +8197,23 @@ static BOOL WINAPI qemu_ctrl_handler(DWORD type)
8192 8197 }
8193 8198 #endif
8194 8199  
  8200 +static int qemu_uuid_parse(const char *str, uint8_t *uuid)
  8201 +{
  8202 + int ret;
  8203 +
  8204 + if(strlen(str) != 36)
  8205 + return -1;
  8206 +
  8207 + ret = sscanf(str, UUID_FMT, &uuid[0], &uuid[1], &uuid[2], &uuid[3],
  8208 + &uuid[4], &uuid[5], &uuid[6], &uuid[7], &uuid[8], &uuid[9],
  8209 + &uuid[10], &uuid[11], &uuid[12], &uuid[13], &uuid[14], &uuid[15]);
  8210 +
  8211 + if(ret != 16)
  8212 + return -1;
  8213 +
  8214 + return 0;
  8215 +}
  8216 +
8195 8217 #define MAX_NET_CLIENTS 32
8196 8218  
8197 8219 #ifndef _WIN32
... ... @@ -8770,6 +8792,13 @@ int main(int argc, char **argv)
8770 8792 case QEMU_OPTION_show_cursor:
8771 8793 cursor_hide = 0;
8772 8794 break;
  8795 + case QEMU_OPTION_uuid:
  8796 + if(qemu_uuid_parse(optarg, qemu_uuid) < 0) {
  8797 + fprintf(stderr, "Fail to parse UUID string."
  8798 + " Wrong format.\n");
  8799 + exit(1);
  8800 + }
  8801 + break;
8773 8802 case QEMU_OPTION_daemonize:
8774 8803 daemonize = 1;
8775 8804 break;
... ...