qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Add -name option
@ 2007-03-04  3:11 Anthony Liguori
  2007-03-04  9:30 ` Avi Kivity
  0 siblings, 1 reply; 5+ messages in thread
From: Anthony Liguori @ 2007-03-04  3:11 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 336 bytes --]

This option helps differentiate between guests when running more than 
one instance of QEMU.  It adds a string to the SDL window title and to 
the VNC server title.

Having a name associated with a guest is also terribly useful for 
management tools as it gives a standard way to identify guests to the user.

Regards,

Anthony Liguori

[-- Attachment #2: qemu-name.diff --]
[-- Type: text/x-patch, Size: 4551 bytes --]

diff -r 5b37ca9b68f9 monitor.c
--- a/monitor.c	Sun Mar 04 00:52:16 2007 +0000
+++ b/monitor.c	Sat Mar 03 20:59:23 2007 -0600
@@ -233,6 +233,12 @@ static void do_info_version(void)
 static void do_info_version(void)
 {
   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)
@@ -1303,6 +1309,8 @@ static term_cmd_t info_cmds[] = {
       "", "show which guest mouse is receiving events" },
     { "vnc", "", do_info_vnc,
       "", "show the vnc server status"},
+    { "name", "", do_info_name,
+      "", "show the current VM name" },
     { NULL, NULL, },
 };
 
diff -r 5b37ca9b68f9 qemu-doc.texi
--- a/qemu-doc.texi	Sun Mar 04 00:52:16 2007 +0000
+++ b/qemu-doc.texi	Sat Mar 03 21:05:12 2007 -0600
@@ -330,6 +330,10 @@ slows down the IDE transfers).
 @item -option-rom file
 Load the contents of file as an option ROM.  This option is useful to load
 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
 
diff -r 5b37ca9b68f9 sdl.c
--- a/sdl.c	Sun Mar 04 00:52:16 2007 +0000
+++ b/sdl.c	Sat Mar 03 20:58:51 2007 -0600
@@ -216,13 +216,19 @@ static void sdl_update_caption(void)
 static void sdl_update_caption(void)
 {
     char buf[1024];
-    strcpy(buf, "QEMU");
-    if (!vm_running) {
-        strcat(buf, " [Stopped]");
-    }
-    if (gui_grab) {
-        strcat(buf, " - Press Ctrl-Alt to exit grab");
-    }
+    const char *status = "";
+
+    if (!vm_running)
+	    status = " [Stopped]";
+    else if (gui_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");
 }
 
diff -r 5b37ca9b68f9 vl.c
--- a/vl.c	Sun Mar 04 00:52:16 2007 +0000
+++ b/vl.c	Sat Mar 03 21:06:32 2007 -0600
@@ -189,6 +189,7 @@ int nb_option_roms;
 int nb_option_roms;
 int semihosting_enabled = 0;
 int autostart = 1;
+const char *qemu_name;
 
 /***********************************************************/
 /* x86 ISA bus support */
@@ -6391,6 +6392,7 @@ void help(void)
 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
            "-g WxH[xDEPTH]  Set the initial graphical resolution and depth\n"
 #endif
+	   "-name string    set the name of the guest\n"
            "\n"
            "Network options:\n"
            "-net nic[,vlan=n][,macaddr=addr][,model=type]\n"
@@ -6548,7 +6550,8 @@ enum {
     QEMU_OPTION_no_reboot,
     QEMU_OPTION_daemonize,
     QEMU_OPTION_option_rom,
-    QEMU_OPTION_semihosting
+    QEMU_OPTION_semihosting,
+    QEMU_OPTION_name,
 };
 
 typedef struct QEMUOption {
@@ -6638,6 +6641,7 @@ const QEMUOption qemu_options[] = {
 #if defined(TARGET_ARM)
     { "semihosting", 0, QEMU_OPTION_semihosting },
 #endif
+    { "name", HAS_ARG, QEMU_OPTION_name },
     { NULL },
 };
 
@@ -7318,6 +7322,9 @@ int main(int argc, char **argv)
             case QEMU_OPTION_semihosting:
                 semihosting_enabled = 1;
                 break;
+            case QEMU_OPTION_name:
+                qemu_name = optarg;
+                break;
             }
         }
     }
diff -r 5b37ca9b68f9 vl.h
--- a/vl.h	Sun Mar 04 00:52:16 2007 +0000
+++ b/vl.h	Sat Mar 03 20:58:51 2007 -0600
@@ -114,6 +114,7 @@ extern const char *bios_dir;
 extern const char *bios_dir;
 
 extern int vm_running;
+extern const char *qemu_name;
 
 typedef struct vm_change_state_entry VMChangeStateEntry;
 typedef void VMChangeStateHandler(void *opaque, int running);
diff -r 5b37ca9b68f9 vnc.c
--- a/vnc.c	Sun Mar 04 00:52:16 2007 +0000
+++ b/vnc.c	Sat Mar 03 20:58:51 2007 -0600
@@ -1056,6 +1056,8 @@ static int protocol_client_init(VncState
 static int protocol_client_init(VncState *vs, char *data, size_t len)
 {
     char pad[3] = { 0, 0, 0 };
+    char buf[1024];
+    int size;
 
     vs->width = vs->ds->width;
     vs->height = vs->ds->height;
@@ -1100,8 +1102,13 @@ static int protocol_client_init(VncState
 	
     vnc_write(vs, pad, 3);           /* padding */
 
-    vnc_write_u32(vs, 4);        
-    vnc_write(vs, "QEMU", 4);
+    if (qemu_name) 
+	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_read_when(vs, protocol_client_msg, 1);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] Add -name option
  2007-03-04  3:11 [Qemu-devel] [PATCH] Add -name option Anthony Liguori
@ 2007-03-04  9:30 ` Avi Kivity
  2007-03-04 17:11   ` Anthony Liguori
  0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2007-03-04  9:30 UTC (permalink / raw)
  To: qemu-devel

Anthony Liguori wrote:
> This option helps differentiate between guests when running more than 
> one instance of QEMU.  It adds a string to the SDL window title and to 
> the VNC server title.
>
> Having a name associated with a guest is also terribly useful for 
> management tools as it gives a standard way to identify guests to the 
> user.
>
>  
> -    vnc_write_u32(vs, 4);        
> -    vnc_write(vs, "QEMU", 4);
> +    if (qemu_name) 
> +	size = snprintf(buf, sizeof(buf), "QEMU (%s)", qemu_name);
> +    else
> +	size = snprintf(buf, sizeof(buf), "QEMU");
> +

Perhaps in the modern style:

    snprintf("%s - QEMU", sizeof, qemu_name)

?

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] Add -name option
  2007-03-04  9:30 ` Avi Kivity
@ 2007-03-04 17:11   ` Anthony Liguori
  2007-03-04 17:23     ` Avi Kivity
  2007-03-04 20:00     ` Daniel P. Berrange
  0 siblings, 2 replies; 5+ messages in thread
From: Anthony Liguori @ 2007-03-04 17:11 UTC (permalink / raw)
  To: qemu-devel

Avi Kivity wrote:
> Anthony Liguori wrote:
>> This option helps differentiate between guests when running more than 
>> one instance of QEMU.  It adds a string to the SDL window title and 
>> to the VNC server title.
>>
>> Having a name associated with a guest is also terribly useful for 
>> management tools as it gives a standard way to identify guests to the 
>> user.
>>
>>  
>> -    vnc_write_u32(vs, 4);        -    vnc_write(vs, "QEMU", 4);
>> +    if (qemu_name) +    size = snprintf(buf, sizeof(buf), "QEMU 
>> (%s)", qemu_name);
>> +    else
>> +    size = snprintf(buf, sizeof(buf), "QEMU");
>> +
>
> Perhaps in the modern style:
>
>    snprintf("%s - QEMU", sizeof, qemu_name)

So right now we have:

QEMU
QEMU - Press Ctrl+Alt to exit grab

My patch would add:

QEMU (WinXP Home)
QEMU (WinXP Home) - Press Ctrl+Alt to exit grab

You're suggesting:

WinXP Home - QEMU
WinXP Home - QEMU - Press Ctrl+Alt to exit grab

I like yours for the first title but the SDL grab version seems a little 
strange.  That's why I stuck it in ()s in the first place.

Anyone else have ideas?

Regards,

Anthony Liguori

> ?
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] Add -name option
  2007-03-04 17:11   ` Anthony Liguori
@ 2007-03-04 17:23     ` Avi Kivity
  2007-03-04 20:00     ` Daniel P. Berrange
  1 sibling, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2007-03-04 17:23 UTC (permalink / raw)
  To: qemu-devel

Anthony Liguori wrote:
>
> So right now we have:
>
> QEMU
> QEMU - Press Ctrl+Alt to exit grab
>
> My patch would add:
>
> QEMU (WinXP Home)
> QEMU (WinXP Home) - Press Ctrl+Alt to exit grab
>
> You're suggesting:
>
> WinXP Home - QEMU
> WinXP Home - QEMU - Press Ctrl+Alt to exit grab
>
> I like yours for the first title but the SDL grab version seems a 
> little strange.  That's why I stuck it in ()s in the first place.
>
> Anyone else have ideas?

Maybe

    WinXP Home - QEMU (press Ctrl+Alt to exit grab)
    WinXP Home (press Ctrl + Alt to exit grab) - QEMU

or even

    WinXP Home - QEMU

with detection that the mouse is being furiously moved on its pad, 
coupled with the motion sensor indicating the machine is being kicked.


-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] Add -name option
  2007-03-04 17:11   ` Anthony Liguori
  2007-03-04 17:23     ` Avi Kivity
@ 2007-03-04 20:00     ` Daniel P. Berrange
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel P. Berrange @ 2007-03-04 20:00 UTC (permalink / raw)
  To: qemu-devel

On Sun, Mar 04, 2007 at 11:11:15AM -0600, Anthony Liguori wrote:
> Avi Kivity wrote:
> >Anthony Liguori wrote:
> >>This option helps differentiate between guests when running more than 
> >>one instance of QEMU.  It adds a string to the SDL window title and 
> >>to the VNC server title.
> >>
> >>Having a name associated with a guest is also terribly useful for 
> >>management tools as it gives a standard way to identify guests to the 
> >>user.
> >>
> >> 
> >>-    vnc_write_u32(vs, 4);        -    vnc_write(vs, "QEMU", 4);
> >>+    if (qemu_name) +    size = snprintf(buf, sizeof(buf), "QEMU 
> >>(%s)", qemu_name);
> >>+    else
> >>+    size = snprintf(buf, sizeof(buf), "QEMU");
> >>+
> >
> >Perhaps in the modern style:
> >
> >   snprintf("%s - QEMU", sizeof, qemu_name)
> 
> So right now we have:
> 
> QEMU
> QEMU - Press Ctrl+Alt to exit grab
> 
> My patch would add:
> 
> QEMU (WinXP Home)
> QEMU (WinXP Home) - Press Ctrl+Alt to exit grab
> 
> You're suggesting:
> 
> WinXP Home - QEMU
> WinXP Home - QEMU - Press Ctrl+Alt to exit grab
> 
> I like yours for the first title but the SDL grab version seems a little 
> strange.  That's why I stuck it in ()s in the first place.
> 
> Anyone else have ideas?

Take 'QEMU' out of the title as it doesn't really give any useful info
compared to the name of the OS. If the user doesn't specify an explicit
name it can use the generic 'QEMU' as title, otherwise leave it out.

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-03-04 20:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-04  3:11 [Qemu-devel] [PATCH] Add -name option Anthony Liguori
2007-03-04  9:30 ` Avi Kivity
2007-03-04 17:11   ` Anthony Liguori
2007-03-04 17:23     ` Avi Kivity
2007-03-04 20:00     ` Daniel P. Berrange

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).