Commit c35734b2a6f9b028edacd5813ff271728ce2a9e3

Authored by ths
1 parent dcfb9014

Add -name option, by Anthony Liguori.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2505 c046a42c-6fe2-441c-8c8c-71466251a162
monitor.c
@@ -235,6 +235,12 @@ static void do_info_version(void) @@ -235,6 +235,12 @@ static void do_info_version(void)
235 term_printf("%s\n", QEMU_VERSION); 235 term_printf("%s\n", QEMU_VERSION);
236 } 236 }
237 237
  238 +static void do_info_name(void)
  239 +{
  240 + if (qemu_name)
  241 + term_printf("%s\n", qemu_name);
  242 +}
  243 +
238 static void do_info_block(void) 244 static void do_info_block(void)
239 { 245 {
240 bdrv_info(); 246 bdrv_info();
@@ -1314,6 +1320,8 @@ static term_cmd_t info_cmds[] = { @@ -1314,6 +1320,8 @@ static term_cmd_t info_cmds[] = {
1314 "", "show which guest mouse is receiving events" }, 1320 "", "show which guest mouse is receiving events" },
1315 { "vnc", "", do_info_vnc, 1321 { "vnc", "", do_info_vnc,
1316 "", "show the vnc server status"}, 1322 "", "show the vnc server status"},
  1323 + { "name", "", do_info_name,
  1324 + "", "show the current VM name" },
1317 #if defined(TARGET_PPC) 1325 #if defined(TARGET_PPC)
1318 { "cpustats", "", do_info_cpu_stats, 1326 { "cpustats", "", do_info_cpu_stats,
1319 "", "show CPU statistics", }, 1327 "", "show CPU statistics", },
qemu-doc.texi
@@ -331,6 +331,10 @@ slows down the IDE transfers). @@ -331,6 +331,10 @@ slows down the IDE transfers).
331 Load the contents of file as an option ROM. This option is useful to load 331 Load the contents of file as an option ROM. This option is useful to load
332 things like EtherBoot. 332 things like EtherBoot.
333 333
  334 +@item -name string
  335 +Sets the name of the guest. This name will be display in the SDL window
  336 +caption. The name will also be used for the VNC server.
  337 +
334 @end table 338 @end table
335 339
336 USB options: 340 USB options:
@@ -216,13 +216,18 @@ static void sdl_process_key(SDL_KeyboardEvent *ev) @@ -216,13 +216,18 @@ static void sdl_process_key(SDL_KeyboardEvent *ev)
216 static void sdl_update_caption(void) 216 static void sdl_update_caption(void)
217 { 217 {
218 char buf[1024]; 218 char buf[1024];
219 - strcpy(buf, "QEMU");  
220 - if (!vm_running) {  
221 - strcat(buf, " [Stopped]");  
222 - }  
223 - if (gui_grab) {  
224 - strcat(buf, " - Press Ctrl-Alt to exit grab");  
225 - } 219 + const char *status = "";
  220 +
  221 + if (!vm_running)
  222 + status = " [Stopped]";
  223 + else if (gui_grab)
  224 + status = " - Press Ctrl-Alt to exit grab";
  225 +
  226 + if (qemu_name)
  227 + snprintf(buf, sizeof(buf), "QEMU (%s)%s", qemu_name, status);
  228 + else
  229 + snprintf(buf, sizeof(buf), "QEMU%s", status);
  230 +
226 SDL_WM_SetCaption(buf, "QEMU"); 231 SDL_WM_SetCaption(buf, "QEMU");
227 } 232 }
228 233
@@ -189,6 +189,7 @@ const char *option_rom[MAX_OPTION_ROMS]; @@ -189,6 +189,7 @@ const char *option_rom[MAX_OPTION_ROMS];
189 int nb_option_roms; 189 int nb_option_roms;
190 int semihosting_enabled = 0; 190 int semihosting_enabled = 0;
191 int autostart = 1; 191 int autostart = 1;
  192 +const char *qemu_name;
192 193
193 /***********************************************************/ 194 /***********************************************************/
194 /* x86 ISA bus support */ 195 /* x86 ISA bus support */
@@ -6395,6 +6396,7 @@ void help(void) @@ -6395,6 +6396,7 @@ void help(void)
6395 #if defined(TARGET_PPC) || defined(TARGET_SPARC) 6396 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
6396 "-g WxH[xDEPTH] Set the initial graphical resolution and depth\n" 6397 "-g WxH[xDEPTH] Set the initial graphical resolution and depth\n"
6397 #endif 6398 #endif
  6399 + "-name string set the name of the guest\n"
6398 "\n" 6400 "\n"
6399 "Network options:\n" 6401 "Network options:\n"
6400 "-net nic[,vlan=n][,macaddr=addr][,model=type]\n" 6402 "-net nic[,vlan=n][,macaddr=addr][,model=type]\n"
@@ -6553,7 +6555,8 @@ enum { @@ -6553,7 +6555,8 @@ enum {
6553 QEMU_OPTION_no_reboot, 6555 QEMU_OPTION_no_reboot,
6554 QEMU_OPTION_daemonize, 6556 QEMU_OPTION_daemonize,
6555 QEMU_OPTION_option_rom, 6557 QEMU_OPTION_option_rom,
6556 - QEMU_OPTION_semihosting 6558 + QEMU_OPTION_semihosting,
  6559 + QEMU_OPTION_name,
6557 }; 6560 };
6558 6561
6559 typedef struct QEMUOption { 6562 typedef struct QEMUOption {
@@ -6644,6 +6647,7 @@ const QEMUOption qemu_options[] = { @@ -6644,6 +6647,7 @@ const QEMUOption qemu_options[] = {
6644 #if defined(TARGET_ARM) 6647 #if defined(TARGET_ARM)
6645 { "semihosting", 0, QEMU_OPTION_semihosting }, 6648 { "semihosting", 0, QEMU_OPTION_semihosting },
6646 #endif 6649 #endif
  6650 + { "name", HAS_ARG, QEMU_OPTION_name },
6647 { NULL }, 6651 { NULL },
6648 }; 6652 };
6649 6653
@@ -7340,6 +7344,9 @@ int main(int argc, char **argv) @@ -7340,6 +7344,9 @@ int main(int argc, char **argv)
7340 case QEMU_OPTION_semihosting: 7344 case QEMU_OPTION_semihosting:
7341 semihosting_enabled = 1; 7345 semihosting_enabled = 1;
7342 break; 7346 break;
  7347 + case QEMU_OPTION_name:
  7348 + qemu_name = optarg;
  7349 + break;
7343 } 7350 }
7344 } 7351 }
7345 } 7352 }
@@ -114,6 +114,7 @@ void hw_error(const char *fmt, ...); @@ -114,6 +114,7 @@ void hw_error(const char *fmt, ...);
114 extern const char *bios_dir; 114 extern const char *bios_dir;
115 115
116 extern int vm_running; 116 extern int vm_running;
  117 +extern const char *qemu_name;
117 118
118 typedef struct vm_change_state_entry VMChangeStateEntry; 119 typedef struct vm_change_state_entry VMChangeStateEntry;
119 typedef void VMChangeStateHandler(void *opaque, int running); 120 typedef void VMChangeStateHandler(void *opaque, int running);
@@ -1056,6 +1056,8 @@ static int protocol_client_msg(VncState *vs, char *data, size_t len) @@ -1056,6 +1056,8 @@ static int protocol_client_msg(VncState *vs, char *data, size_t len)
1056 static int protocol_client_init(VncState *vs, char *data, size_t len) 1056 static int protocol_client_init(VncState *vs, char *data, size_t len)
1057 { 1057 {
1058 char pad[3] = { 0, 0, 0 }; 1058 char pad[3] = { 0, 0, 0 };
  1059 + char buf[1024];
  1060 + int size;
1059 1061
1060 vs->width = vs->ds->width; 1062 vs->width = vs->ds->width;
1061 vs->height = vs->ds->height; 1063 vs->height = vs->ds->height;
@@ -1100,8 +1102,13 @@ static int protocol_client_init(VncState *vs, char *data, size_t len) @@ -1100,8 +1102,13 @@ static int protocol_client_init(VncState *vs, char *data, size_t len)
1100 1102
1101 vnc_write(vs, pad, 3); /* padding */ 1103 vnc_write(vs, pad, 3); /* padding */
1102 1104
1103 - vnc_write_u32(vs, 4);  
1104 - vnc_write(vs, "QEMU", 4); 1105 + if (qemu_name)
  1106 + size = snprintf(buf, sizeof(buf), "QEMU (%s)", qemu_name);
  1107 + else
  1108 + size = snprintf(buf, sizeof(buf), "QEMU");
  1109 +
  1110 + vnc_write_u32(vs, size);
  1111 + vnc_write(vs, buf, size);
1105 vnc_flush(vs); 1112 vnc_flush(vs);
1106 1113
1107 vnc_read_when(vs, protocol_client_msg, 1); 1114 vnc_read_when(vs, protocol_client_msg, 1);