Add -name option, by Anthony Liguori.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2505 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
ths 2007-03-19 15:17:08 +00:00
parent dcfb90144b
commit c35734b2a6
6 changed files with 42 additions and 10 deletions

View File

@ -235,6 +235,12 @@ static void do_info_version(void)
term_printf("%s\n", QEMU_VERSION); term_printf("%s\n", QEMU_VERSION);
} }
static void do_info_name(void)
{
if (qemu_name)
term_printf("%s\n", qemu_name);
}
static void do_info_block(void) static void do_info_block(void)
{ {
bdrv_info(); bdrv_info();
@ -1314,6 +1320,8 @@ static term_cmd_t info_cmds[] = {
"", "show which guest mouse is receiving events" }, "", "show which guest mouse is receiving events" },
{ "vnc", "", do_info_vnc, { "vnc", "", do_info_vnc,
"", "show the vnc server status"}, "", "show the vnc server status"},
{ "name", "", do_info_name,
"", "show the current VM name" },
#if defined(TARGET_PPC) #if defined(TARGET_PPC)
{ "cpustats", "", do_info_cpu_stats, { "cpustats", "", do_info_cpu_stats,
"", "show CPU statistics", }, "", "show CPU statistics", },

View File

@ -331,6 +331,10 @@ slows down the IDE transfers).
Load the contents of file as an option ROM. This option is useful to load Load the contents of file as an option ROM. This option is useful to load
things like EtherBoot. things like EtherBoot.
@item -name string
Sets the name of the guest. This name will be display in the SDL window
caption. The name will also be used for the VNC server.
@end table @end table
USB options: USB options:

19
sdl.c
View File

@ -216,13 +216,18 @@ static void sdl_process_key(SDL_KeyboardEvent *ev)
static void sdl_update_caption(void) static void sdl_update_caption(void)
{ {
char buf[1024]; char buf[1024];
strcpy(buf, "QEMU"); const char *status = "";
if (!vm_running) {
strcat(buf, " [Stopped]"); if (!vm_running)
} status = " [Stopped]";
if (gui_grab) { else if (gui_grab)
strcat(buf, " - Press Ctrl-Alt to exit grab"); status = " - Press Ctrl-Alt to exit grab";
}
if (qemu_name)
snprintf(buf, sizeof(buf), "QEMU (%s)%s", qemu_name, status);
else
snprintf(buf, sizeof(buf), "QEMU%s", status);
SDL_WM_SetCaption(buf, "QEMU"); SDL_WM_SetCaption(buf, "QEMU");
} }

9
vl.c
View File

@ -189,6 +189,7 @@ const char *option_rom[MAX_OPTION_ROMS];
int nb_option_roms; int nb_option_roms;
int semihosting_enabled = 0; int semihosting_enabled = 0;
int autostart = 1; int autostart = 1;
const char *qemu_name;
/***********************************************************/ /***********************************************************/
/* x86 ISA bus support */ /* x86 ISA bus support */
@ -6395,6 +6396,7 @@ void help(void)
#if defined(TARGET_PPC) || defined(TARGET_SPARC) #if defined(TARGET_PPC) || defined(TARGET_SPARC)
"-g WxH[xDEPTH] Set the initial graphical resolution and depth\n" "-g WxH[xDEPTH] Set the initial graphical resolution and depth\n"
#endif #endif
"-name string set the name of the guest\n"
"\n" "\n"
"Network options:\n" "Network options:\n"
"-net nic[,vlan=n][,macaddr=addr][,model=type]\n" "-net nic[,vlan=n][,macaddr=addr][,model=type]\n"
@ -6553,7 +6555,8 @@ enum {
QEMU_OPTION_no_reboot, QEMU_OPTION_no_reboot,
QEMU_OPTION_daemonize, QEMU_OPTION_daemonize,
QEMU_OPTION_option_rom, QEMU_OPTION_option_rom,
QEMU_OPTION_semihosting QEMU_OPTION_semihosting,
QEMU_OPTION_name,
}; };
typedef struct QEMUOption { typedef struct QEMUOption {
@ -6644,6 +6647,7 @@ const QEMUOption qemu_options[] = {
#if defined(TARGET_ARM) #if defined(TARGET_ARM)
{ "semihosting", 0, QEMU_OPTION_semihosting }, { "semihosting", 0, QEMU_OPTION_semihosting },
#endif #endif
{ "name", HAS_ARG, QEMU_OPTION_name },
{ NULL }, { NULL },
}; };
@ -7340,6 +7344,9 @@ int main(int argc, char **argv)
case QEMU_OPTION_semihosting: case QEMU_OPTION_semihosting:
semihosting_enabled = 1; semihosting_enabled = 1;
break; break;
case QEMU_OPTION_name:
qemu_name = optarg;
break;
} }
} }
} }

1
vl.h
View File

@ -114,6 +114,7 @@ void hw_error(const char *fmt, ...);
extern const char *bios_dir; extern const char *bios_dir;
extern int vm_running; extern int vm_running;
extern const char *qemu_name;
typedef struct vm_change_state_entry VMChangeStateEntry; typedef struct vm_change_state_entry VMChangeStateEntry;
typedef void VMChangeStateHandler(void *opaque, int running); typedef void VMChangeStateHandler(void *opaque, int running);

11
vnc.c
View File

@ -1056,6 +1056,8 @@ static int protocol_client_msg(VncState *vs, char *data, size_t len)
static int protocol_client_init(VncState *vs, char *data, size_t len) static int protocol_client_init(VncState *vs, char *data, size_t len)
{ {
char pad[3] = { 0, 0, 0 }; char pad[3] = { 0, 0, 0 };
char buf[1024];
int size;
vs->width = vs->ds->width; vs->width = vs->ds->width;
vs->height = vs->ds->height; vs->height = vs->ds->height;
@ -1100,8 +1102,13 @@ static int protocol_client_init(VncState *vs, char *data, size_t len)
vnc_write(vs, pad, 3); /* padding */ vnc_write(vs, pad, 3); /* padding */
vnc_write_u32(vs, 4); if (qemu_name)
vnc_write(vs, "QEMU", 4); size = snprintf(buf, sizeof(buf), "QEMU (%s)", qemu_name);
else
size = snprintf(buf, sizeof(buf), "QEMU");
vnc_write_u32(vs, size);
vnc_write(vs, buf, size);
vnc_flush(vs); vnc_flush(vs);
vnc_read_when(vs, protocol_client_msg, 1); vnc_read_when(vs, protocol_client_msg, 1);