[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 2/6] Add -uuid command line option.
From: |
Gleb Natapov |
Subject: |
[Qemu-devel] [PATCH v3 2/6] Add -uuid command line option. |
Date: |
Thu, 28 Aug 2008 19:52:42 +0300 |
User-agent: |
StGIT/0.14.2 |
Let user specify UUID of the virtual machine.
Signed-off-by: Gleb Natapov <address@hidden>
---
sysemu.h | 2 ++
vl.c | 29 +++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/sysemu.h b/sysemu.h
index b12fae0..931ac3a 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -8,6 +8,8 @@ extern const char *bios_dir;
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);
diff --git a/vl.c b/vl.c
index 245177a..30fef2a 100644
--- a/vl.c
+++ b/vl.c
@@ -257,6 +257,8 @@ static int64_t qemu_icount_bias;
QEMUTimer *icount_rt_timer;
QEMUTimer *icount_vm_timer;
+uint8_t qemu_uuid[16];
+
#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
/***********************************************************/
@@ -7710,6 +7712,7 @@ static void help(int exitcode)
"-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"
@@ -7904,6 +7907,7 @@ enum {
QEMU_OPTION_startdate,
QEMU_OPTION_tb_size,
QEMU_OPTION_icount,
+ QEMU_OPTION_uuid,
};
typedef struct QEMUOption {
@@ -7992,6 +7996,7 @@ const QEMUOption qemu_options[] = {
#ifdef CONFIG_CURSES
{ "curses", 0, QEMU_OPTION_curses },
#endif
+ { "uuid", HAS_ARG, QEMU_OPTION_uuid },
/* temporary options */
{ "usb", 0, QEMU_OPTION_usb },
@@ -8202,6 +8207,23 @@ static BOOL WINAPI qemu_ctrl_handler(DWORD type)
}
#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
@@ -8780,6 +8802,13 @@ int main(int argc, char **argv)
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;
- Re: [Qemu-devel] [PATCH v3 1/6] Use IO port for qemu<->guest BIOS communication., (continued)
- Re: [Qemu-devel] [PATCH v3 1/6] Use IO port for qemu<->guest BIOS communication., Blue Swirl, 2008/08/29
- Re: [Qemu-devel] [PATCH v3 1/6] Use IO port for qemu<->guest BIOS communication., Blue Swirl, 2008/08/30
- Re: [Qemu-devel] [PATCH v3 1/6] Use IO port for qemu<->guest BIOS communication., Gleb Natapov, 2008/08/31
- Re: [Qemu-devel] [PATCH v3 1/6] Use IO port for qemu<->guest BIOS communication., Blue Swirl, 2008/08/31
- Re: [Qemu-devel] [PATCH v3 1/6] Use IO port for qemu<->guest BIOS communication., Blue Swirl, 2008/08/31
- Re: [Qemu-devel] [PATCH v3 1/6] Use IO port for qemu<->guest BIOS communication., Gleb Natapov, 2008/08/31
- Re: [Qemu-devel] [PATCH v3 1/6] Use IO port for qemu<->guest BIOS communication., Blue Swirl, 2008/08/31
- Re: [Qemu-devel] [PATCH v3 1/6] Use IO port for qemu<->guest BIOS communication., Gleb Natapov, 2008/08/31
- Re: [Qemu-devel] [PATCH v3 1/6] Use IO port for qemu<->guest BIOS communication., Blue Swirl, 2008/08/31
- Re: [Qemu-devel] [PATCH v3 1/6] Use IO port for qemu<->guest BIOS communication., Gleb Natapov, 2008/08/31
[Qemu-devel] [PATCH v3 2/6] Add -uuid command line option.,
Gleb Natapov <=
[Qemu-devel] [PATCH v3 3/6] Add "info uuid" command to monitor., Gleb Natapov, 2008/08/28
[Qemu-devel] [PATCH v3 4/6] Use libuuid if available., Gleb Natapov, 2008/08/28
[Qemu-devel] [PATCH v3 5/6] Add UUID to firmware configuration info., Gleb Natapov, 2008/08/28
[Qemu-devel] [PATCH v3 6/6] Pass cpu speed into SM BIOS., Gleb Natapov, 2008/08/28