Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-22 Thread Anthony Liguori

Luiz Capitulino wrote:

On Thu, 22 Oct 2009 10:40:54 -0500
Anthony Liguori  wrote:

  

Luiz Capitulino wrote:


 Yeah, I agree.

 When testing migration, for example, I have to type 'migrate -d tcp:0:'
several times... Maybe there's a smarter way to do this, but the monitor
macros idea seems interesting to me.
  
  
When we have QMP, we can create a QMP socket at a well known location 
based on the -name parameter.  We could also introduce a qm command that 
allowed one to execute monitor commands from the shell.  That allows 
people to write whatever crazy shell scripts they want.



 Yes.

 What about the macros idea? Are you against it?
  


I'm concerned that it's a snowball of complexity waiting to happen for 
very little benefit.


I think we're trying to solve a non-existent problem.

Regards,

Anthony Liguori




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-22 Thread Luiz Capitulino
On Thu, 22 Oct 2009 10:40:54 -0500
Anthony Liguori  wrote:

> Luiz Capitulino wrote:
> >  Yeah, I agree.
> >
> >  When testing migration, for example, I have to type 'migrate -d tcp:0:'
> > several times... Maybe there's a smarter way to do this, but the monitor
> > macros idea seems interesting to me.
> >   
> 
> When we have QMP, we can create a QMP socket at a well known location 
> based on the -name parameter.  We could also introduce a qm command that 
> allowed one to execute monitor commands from the shell.  That allows 
> people to write whatever crazy shell scripts they want.

 Yes.

 What about the macros idea? Are you against it?




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-22 Thread Luiz Capitulino
On Thu, 22 Oct 2009 17:02:29 +0200
Kevin Wolf  wrote:

> Am 22.10.2009 16:40, schrieb Luiz Capitulino:
> > On Wed, 21 Oct 2009 19:35:03 +0100
> > Jamie Lokier  wrote:
> >> If the monitor accepted ";" as a command separator, to put multiple
> >> commands on a single line,  could just be a quoted
> >> string which is processed as a line.
> > 
> >  Why is ";" needed?
> 
> How else would you specify multiple commands for one macro?

 Let me rephrase this better: what use cases do we have for
multiple commands in one line/macro?

> >> - add_key key  
> >> - remove_key  
> >> - list_keys
> > 
> >  What's key?
> 
> Some kind of key binding. If we allowed all keys, it would probably make
> sense to use the sendkeys style format, but I assume we'll only support
> ctrl-alt- which already has a special meaning.

 Ah, I see now. Would have to think about this.

> >  Ah, it doesn't have macro_del and if we use QObjects we can
> > consider saving its json representation in file so that we can
> > have macro_load.
> 
> You are thinking about having this to avoid typing in the macro each
> time you start a VM?

 Yes.

> For something the user might want to touch I'd
> prefer a simple solution like reading ~/.qemurc or something like that
> and executing it as a "monitor script".

 That's right, asking the user to edit json doesn't seem like
a good idea.. I guess I'm working too much with it. :)




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-22 Thread Anthony Liguori

Luiz Capitulino wrote:

 Yeah, I agree.

 When testing migration, for example, I have to type 'migrate -d tcp:0:'
several times... Maybe there's a smarter way to do this, but the monitor
macros idea seems interesting to me.
  


When we have QMP, we can create a QMP socket at a well known location 
based on the -name parameter.  We could also introduce a qm command that 
allowed one to execute monitor commands from the shell.  That allows 
people to write whatever crazy shell scripts they want.


Regards,

Anthony Liguori




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-22 Thread Kevin Wolf
Am 22.10.2009 16:40, schrieb Luiz Capitulino:
> On Wed, 21 Oct 2009 19:35:03 +0100
> Jamie Lokier  wrote:
>> If the monitor accepted ";" as a command separator, to put multiple
>> commands on a single line,  could just be a quoted
>> string which is processed as a line.
> 
>  Why is ";" needed?

How else would you specify multiple commands for one macro?

>>
>> - add_key key  
>> - remove_key  
>> - list_keys
> 
>  What's key?

Some kind of key binding. If we allowed all keys, it would probably make
sense to use the sendkeys style format, but I assume we'll only support
ctrl-alt- which already has a special meaning.

>  Ah, it doesn't have macro_del and if we use QObjects we can
> consider saving its json representation in file so that we can
> have macro_load.

You are thinking about having this to avoid typing in the macro each
time you start a VM? For something the user might want to touch I'd
prefer a simple solution like reading ~/.qemurc or something like that
and executing it as a "monitor script".

Kevin




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-22 Thread Luiz Capitulino
On Wed, 21 Oct 2009 19:35:03 +0100
Jamie Lokier  wrote:

> Mulyadi Santosa wrote:
> > On Wed, Oct 21, 2009 at 11:24 PM, Glauber Costa  wrote:
> > > You can provide a monitor command to do that
> > >
> > > something in the lines of:
> > > - add_macro  
> > > - remove_macro 
> > > - list_macros
> > 
> > Please CMIIW, "command_list" here refers to at least one of monitor
> > commands, right? meaning, i.e one could do:
> > add_macro ctrl_alt_shift_s "stop"
> > 
> > or extend that so it does:
> > add_macro ctrl_alt_shift_s "stop print $pc"
> > 
> > so, it stops the VM followed by printing program counter.
> 
> If the monitor accepted ";" as a command separator, to put multiple
> commands on a single line,  could just be a quoted
> string which is processed as a line.

 Why is ";" needed?

> If we're going to have keyboard macros, it would be nice and probably
> very easy to have monitor macros too - monitor commands which expand
> to a line in the same way.
> 
> The number of times I've typed things like send_key control-alt-del
> and would have appreciated a "cad" macro...

 Yeah, I agree.

 When testing migration, for example, I have to type 'migrate -d tcp:0:'
several times... Maybe there's a smarter way to do this, but the monitor
macros idea seems interesting to me.

> Syntax idea comes to mind is:
> 
> - Add ";" as command separator.

 Not difficult, but not trivial.

> - add_macro  
> - remove_macro 
> - list_macros

 Why not macro_add?

> 
> - add_key key  
> - remove_key  
> - list_keys

 What's key?

 Anyway, below there's a patch with an initial implementation. I've
implemented it using the "old" monitor style because I didn't want
to think about the right "object model" for this yet..

 If people think this is interesting I will work on a serious
implementation for submission.

 Ah, it doesn't have macro_del and if we use QObjects we can
consider saving its json representation in file so that we can
have macro_load.

commit e7fa305f82f4f99168166bda437e86d3a6343064
Author: Luiz Capitulino 
Date:   Thu Oct 22 12:26:06 2009 -0200

monitor: Add macro support

This is a buggy, untested, initial implementation, which only supports
"macro_add" and "macro_list".

Example:

(qemu) macro_add mi "migrate -d tcp:localhost:"

Signed-off-by: Luiz Capitulino 

diff --git a/monitor.c b/monitor.c
index 2566f4a..f8e2844 100644
--- a/monitor.c
+++ b/monitor.c
@@ -107,6 +107,15 @@ struct Monitor {
 QLIST_ENTRY(Monitor) entry;
 };
 
+typedef struct MonitorMacro {
+QTAILQ_ENTRY(MonitorMacro) entry;
+const char *name;
+const char *command_line;
+} MonitorMacro;
+
+static QTAILQ_HEAD(monitor_macros, MonitorMacro) monitor_macros = 
+QTAILQ_HEAD_INITIALIZER(monitor_macros);
+
 static QLIST_HEAD(mon_list, Monitor) mon_list;
 
 static const mon_cmd_t mon_cmds[];
@@ -1909,6 +1918,25 @@ static void do_closefd(Monitor *mon, const QDict *qdict)
fdname);
 }
 
+static void do_macro_add(Monitor *mon, const QDict *qdict)
+{
+MonitorMacro *macro;
+
+macro = qemu_mallocz(sizeof(*macro));
+macro->name = qemu_strdup(qdict_get_str(qdict, "name"));
+macro->command_line = qemu_strdup(qdict_get_str(qdict, "command"));
+
+QTAILQ_INSERT_TAIL(&monitor_macros, macro, entry);
+}
+
+static void do_macro_list(Monitor *mon, const QDict *qdict)
+{
+MonitorMacro *macro;
+
+QTAILQ_FOREACH(macro, &monitor_macros, entry)
+monitor_printf(mon, "%s: \"%s\"\n", macro->name, macro->command_line);
+}
+
 static void do_loadvm(Monitor *mon, const QDict *qdict)
 {
 int saved_vm_running  = vm_running;
@@ -2902,6 +2930,45 @@ static char *key_get_info(const char *type, char **key)
 return ++p;
 }
 
+static const mon_cmd_t *find_command(const char *cmdname)
+{
+const mon_cmd_t *cmd;
+
+/* find the command */
+for (cmd = mon_cmds; cmd->name != NULL; cmd++) {
+if (compare_cmd(cmdname, cmd->name))
+return cmd;
+}
+
+return NULL;
+}
+
+static const mon_cmd_t *find_macro(char *cmdname, size_t len, const char **pos)
+{
+const char *p;
+MonitorMacro *macro;
+const mon_cmd_t *cmd;
+
+QTAILQ_FOREACH(macro, &monitor_macros, entry) {
+if (strcmp(macro->name, cmdname) == 0)
+break;
+}
+
+if (!macro)
+return NULL;
+
+p = get_command_name(macro->command_line, cmdname, len);
+if (!p)
+return NULL;
+
+cmd = find_command(cmdname);
+if (!cmd)
+return NULL;
+
+*pos = p;
+return cmd;
+}
+
 static int default_fmt_format = 'x';
 static int default_fmt_size = 4;
 
@@ -2927,15 +2994,13 @@ static const mon_cmd_t *monitor_parse_command(Monitor 
*mon,
 if (!p)
 return NULL;
 
-/* find the command */
-for(cmd = mon_cmds; cmd->name != NULL; cmd++) {
-if (compare_cmd(cmdname, cmd->name))
-break;
-}
-
-if (cmd->name == NULL) {
-monitor_printf(mon, "unknown 

Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-22 Thread Kevin Wolf
Am 21.10.2009 20:08, schrieb Anthony Liguori:
> Glauber Costa wrote:
>> On Wed, Oct 21, 2009 at 2:55 PM, Anthony Liguori  
>> wrote:
>>   
>>> Glauber Costa wrote:
>>> 
 Why don't we provide a mechanism to make a macro out of a sequence of
 monitor commands, and let the user assign whatever he wants out of that?

   
>>> Really?  This seems exceedingly complicated to me.
>>>
>>> Redirecting the kernel output to serial and logging is a considerably better
>>> solution.
>>> 
>> To his specific problem, yes.
>>
>> But this probably don't work so well on some OSes that are less serial 
>> friendly.
>> Also, there are valid use cases in which one may want, for example, to pause
>> fast if some graphical event happens, which is an extension of what he 
>> mentioned
>> initially.
>>   
> 
> Then type "stop" in the monitor and hit enter when you need to.  Or, 
> write a simple VNC client using gtk-vnc that can have any sort of crazy 
> key sequences you want.

Having two different consoles at the same time is easy. Guest graphics
in the SDL window, serial console on stdio. And now I need to add a
monitor. Means that I need to start using named pipes or TCP connections
or something. And I need to arrange the windows so that I can see qemu's
SDL window and the shell with my netcat (or whatever) gets the enter key
I hit. Yes, it's possible, but it's not nice.

I like Jamie's suggestion for macros.

Kevin




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-21 Thread Jamie Lokier
Mulyadi Santosa wrote:
> On Wed, Oct 21, 2009 at 11:24 PM, Glauber Costa  wrote:
> > You can provide a monitor command to do that
> >
> > something in the lines of:
> > - add_macro  
> > - remove_macro 
> > - list_macros
> 
> Please CMIIW, "command_list" here refers to at least one of monitor
> commands, right? meaning, i.e one could do:
> add_macro ctrl_alt_shift_s "stop"
> 
> or extend that so it does:
> add_macro ctrl_alt_shift_s "stop print $pc"
> 
> so, it stops the VM followed by printing program counter.

If the monitor accepted ";" as a command separator, to put multiple
commands on a single line,  could just be a quoted
string which is processed as a line.

If we're going to have keyboard macros, it would be nice and probably
very easy to have monitor macros too - monitor commands which expand
to a line in the same way.

The number of times I've typed things like send_key control-alt-del
and would have appreciated a "cad" macro...

Syntax idea comes to mind is:

- Add ";" as command separator.

- add_macro  
- remove_macro 
- list_macros

- add_key key  
- remove_key  
- list_keys

(If I were starting from nothing it'd be macro_add, macro_remove
etc. or maybe "macro add", but the above seems more consistent with
the existing monitor)

-- Jamie




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-21 Thread Anthony Liguori

Glauber Costa wrote:

On Wed, Oct 21, 2009 at 2:55 PM, Anthony Liguori  wrote:
  

Glauber Costa wrote:


Why don't we provide a mechanism to make a macro out of a sequence of
monitor commands, and let the user assign whatever he wants out of that?

  

Really?  This seems exceedingly complicated to me.

Redirecting the kernel output to serial and logging is a considerably better
solution.


To his specific problem, yes.

But this probably don't work so well on some OSes that are less serial friendly.
Also, there are valid use cases in which one may want, for example, to pause
fast if some graphical event happens, which is an extension of what he mentioned
initially.
  


Then type "stop" in the monitor and hit enter when you need to.  Or, 
write a simple VNC client using gtk-vnc that can have any sort of crazy 
key sequences you want.


Regards,

Anthony Liguori






Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-21 Thread Glauber Costa
On Wed, Oct 21, 2009 at 2:55 PM, Anthony Liguori  wrote:
> Glauber Costa wrote:
>>
>> Why don't we provide a mechanism to make a macro out of a sequence of
>> monitor commands, and let the user assign whatever he wants out of that?
>>
>
> Really?  This seems exceedingly complicated to me.
>
> Redirecting the kernel output to serial and logging is a considerably better
> solution.
To his specific problem, yes.

But this probably don't work so well on some OSes that are less serial friendly.
Also, there are valid use cases in which one may want, for example, to pause
fast if some graphical event happens, which is an extension of what he mentioned
initially.

-- 
Glauber  Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-21 Thread Mulyadi Santosa
On Wed, Oct 21, 2009 at 11:55 PM, Anthony Liguori  wrote:
> Really?  This seems exceedingly complicated to me.
>
> Redirecting the kernel output to serial and logging is a considerably better
> solution.

I'll respectfully consider everybody's thought hereinteresting
discussion so far though. mean while, if time permits I shall try to
improve my work and let's hear what everybody thinks.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-21 Thread Anthony Liguori

Glauber Costa wrote:

Why don't we provide a mechanism to make a macro out of a sequence of
monitor commands, and let the user assign whatever he wants out of that?
  


Really?  This seems exceedingly complicated to me.

Redirecting the kernel output to serial and logging is a considerably 
better solution.


Regards,

Anthony Liguori






Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-21 Thread Glauber Costa
On Wed, Oct 21, 2009 at 2:44 PM, Mulyadi Santosa
 wrote:
> On Wed, Oct 21, 2009 at 11:24 PM, Glauber Costa  wrote:
>> You can provide a monitor command to do that
>>
>> something in the lines of:
>> - add_macro  
>> - remove_macro 
>> - list_macros
>
> Please CMIIW, "command_list" here refers to at least one of monitor
> commands, right? meaning, i.e one could do:
> add_macro ctrl_alt_shift_s "stop"
>
> or extend that so it does:
> add_macro ctrl_alt_shift_s "stop print $pc"
>
> so, it stops the VM followed by printing program counter.

yes, this is what I meant. But notice that this is just a suggestion.
The internet is a free country,
and if you are indeed implementing this, you are free to add your own spice.

-- 
Glauber  Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-21 Thread Mulyadi Santosa
On Wed, Oct 21, 2009 at 11:24 PM, Glauber Costa  wrote:
> You can provide a monitor command to do that
>
> something in the lines of:
> - add_macro  
> - remove_macro 
> - list_macros

Please CMIIW, "command_list" here refers to at least one of monitor
commands, right? meaning, i.e one could do:
add_macro ctrl_alt_shift_s "stop"

or extend that so it does:
add_macro ctrl_alt_shift_s "stop print $pc"

so, it stops the VM followed by printing program counter.
-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-21 Thread Glauber Costa
On Wed, Oct 21, 2009 at 2:04 PM, Mulyadi Santosa
 wrote:
> On Wed, Oct 21, 2009 at 8:52 PM, Glauber Costa  wrote:
>> Why don't we provide a mechanism to make a macro out of a sequence of
>> monitor commands, and let the user assign whatever he wants out of that?
>
> Presto! never thought about thatwhat are we supposed to do in
> order to provide such mechanism? Who knows, perhaps I can lend a hand
> (again) here
You can provide a monitor command to do that

something in the lines of:
- add_macro  
- remove_macro 
- list_macros

then you could keep the assigned keys in a list, and convert the
command list to a list of functions and arguments.
For compatibility, the current assigned keystrokes would be then
converted to default macros, that could be removed,
if requested

It would be nice if you could find a way to update it on all displays,
not only SDL, at once.

this requires a little bit more work than what you did, but at least
from my point of view,
would be a nice feature, and overcome the limitations that people mentioned.



-- 
Glauber  Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-21 Thread Mulyadi Santosa
On Wed, Oct 21, 2009 at 8:52 PM, Glauber Costa  wrote:
> Why don't we provide a mechanism to make a macro out of a sequence of
> monitor commands, and let the user assign whatever he wants out of that?

Presto! never thought about thatwhat are we supposed to do in
order to provide such mechanism? Who knows, perhaps I can lend a hand
(again) here

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-21 Thread Glauber Costa
On Wed, Oct 21, 2009 at 5:27 AM, Kevin Wolf  wrote:
> Am 20.10.2009 19:08, schrieb Daniel P. Berrange:
>> On Tue, Oct 20, 2009 at 12:40:08PM +0200, Kevin Wolf wrote:
>>> Am 20.10.2009 00:20, schrieb Anthony Liguori:
 Mulyadi Santosa wrote:
> IMO, it would be faster if we provide keyboard shortcuts that will
> stop and resume VM execution right from SDL guest interface, rather
> than switching to console monitor first and type "s" or "c"
> respectively.
>

 Is this really common of an operation that you would need an escape key
 for it?

 Why are you so frequently stopping and continuing a guest?
>>>
>>> Why are you all trying to explain to him that actually he doesn't want
>>> to have this feature? I could have used it, too, at times (stop the
>>> guest to have enough time to attach gdb, for example). There are other
>>> ways to do it (although they are not as simple) and I used them, but
>>> that doesn't make this feature less useful.
>>>
>>> Does it take anything away for you? Or do you have plans to use those
>>> keys otherwise? If not, why not add a feature that some might find
>>> useful, even though others don't?
>>
>> The problem with adding lots of magic key-sequences, is that the more
>> you add, the more likely they are to clash with something that the
>> guest OS wants to use. You may make this use case work, but break
>> someone else's use case. Thus, IMHO, magic key sequences should be kept
>> to the bare minimum neccessary to access functionality for which there
>> is no other viable access method.
>
> Ok, you have a point there. But why do we have key sequences for
> fullscreen and resizing the SDL window back to its original size then?
> Both are things that could be accessed through monitor commands as well.
> And you don't need the right timing for resizing the window - unlike
> stopping the VM. So I would be really happy with swapping those for a
> "stop VM" shortcut.

Why don't we provide a mechanism to make a macro out of a sequence of
monitor commands, and let the user assign whatever he wants out of that?


-- 
Glauber  Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-21 Thread Kevin Wolf
Am 20.10.2009 19:08, schrieb Daniel P. Berrange:
> On Tue, Oct 20, 2009 at 12:40:08PM +0200, Kevin Wolf wrote:
>> Am 20.10.2009 00:20, schrieb Anthony Liguori:
>>> Mulyadi Santosa wrote:
 IMO, it would be faster if we provide keyboard shortcuts that will
 stop and resume VM execution right from SDL guest interface, rather
 than switching to console monitor first and type "s" or "c"
 respectively.
   
>>>
>>> Is this really common of an operation that you would need an escape key 
>>> for it?
>>>
>>> Why are you so frequently stopping and continuing a guest?
>>
>> Why are you all trying to explain to him that actually he doesn't want
>> to have this feature? I could have used it, too, at times (stop the
>> guest to have enough time to attach gdb, for example). There are other
>> ways to do it (although they are not as simple) and I used them, but
>> that doesn't make this feature less useful.
>>
>> Does it take anything away for you? Or do you have plans to use those
>> keys otherwise? If not, why not add a feature that some might find
>> useful, even though others don't?
> 
> The problem with adding lots of magic key-sequences, is that the more
> you add, the more likely they are to clash with something that the 
> guest OS wants to use. You may make this use case work, but break
> someone else's use case. Thus, IMHO, magic key sequences should be kept
> to the bare minimum neccessary to access functionality for which there
> is no other viable access method.

Ok, you have a point there. But why do we have key sequences for
fullscreen and resizing the SDL window back to its original size then?
Both are things that could be accessed through monitor commands as well.
And you don't need the right timing for resizing the window - unlike
stopping the VM. So I would be really happy with swapping those for a
"stop VM" shortcut.

Kevin




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-20 Thread Mulyadi Santosa
Hi...

On Wed, Oct 21, 2009 at 12:08 AM, Daniel P. Berrange
 wrote:
> The problem with adding lots of magic key-sequences, is that the more
> you add, the more likely they are to clash with something that the
> guest OS wants to use. You may make this use case work, but break
> someone else's use case. Thus, IMHO, magic key sequences should be kept
> to the bare minimum neccessary to access functionality for which there
> is no other viable access method.

Thanks for the insights from all of you. The rule "to keep the magic
keys at the bare minimum" is something I fairly agree. So probably in
maintenance and development robustness's point of view, this patch
should just live outside of main tree... well unless there are lot of
supporter

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-20 Thread Daniel P. Berrange
On Tue, Oct 20, 2009 at 12:40:08PM +0200, Kevin Wolf wrote:
> Am 20.10.2009 00:20, schrieb Anthony Liguori:
> > Mulyadi Santosa wrote:
> >> IMO, it would be faster if we provide keyboard shortcuts that will
> >> stop and resume VM execution right from SDL guest interface, rather
> >> than switching to console monitor first and type "s" or "c"
> >> respectively.
> >>   
> > 
> > Is this really common of an operation that you would need an escape key 
> > for it?
> > 
> > Why are you so frequently stopping and continuing a guest?
> 
> Why are you all trying to explain to him that actually he doesn't want
> to have this feature? I could have used it, too, at times (stop the
> guest to have enough time to attach gdb, for example). There are other
> ways to do it (although they are not as simple) and I used them, but
> that doesn't make this feature less useful.
> 
> Does it take anything away for you? Or do you have plans to use those
> keys otherwise? If not, why not add a feature that some might find
> useful, even though others don't?

The problem with adding lots of magic key-sequences, is that the more
you add, the more likely they are to clash with something that the 
guest OS wants to use. You may make this use case work, but break
someone else's use case. Thus, IMHO, magic key sequences should be kept
to the bare minimum neccessary to access functionality for which there
is no other viable access method.

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-20 Thread Anthony Liguori

Kevin Wolf wrote:

Am 20.10.2009 00:20, schrieb Anthony Liguori:
  

Mulyadi Santosa wrote:


IMO, it would be faster if we provide keyboard shortcuts that will
stop and resume VM execution right from SDL guest interface, rather
than switching to console monitor first and type "s" or "c"
respectively.
  
  
Is this really common of an operation that you would need an escape key 
for it?


Why are you so frequently stopping and continuing a guest?



Why are you all trying to explain to him that actually he doesn't want
to have this feature? I could have used it, too, at times (stop the
guest to have enough time to attach gdb, for example). There are other
ways to do it (although they are not as simple) and I used them, but
that doesn't make this feature less useful.

Does it take anything away for you? Or do you have plans to use those
keys otherwise? If not, why not add a feature that some might find
useful, even though others don't?
  


There is such a thing as feature bloat.  It leads to very confusing 
behavior for users.  It also increases the testing matrix.


As it turns out, there's a better way to do what he's looking for that 
requires no changes.  Had we just taken this patch, then that's another 
feature that has to be tested for SDL whenever there's a change there.  
It also means there will be differing behavior for VNC so it probably 
needs to be supported there.  But then for something like libvirt, it's 
not going to expect that something else pauses/starts a VM.


Features are not free.  They have long term maintenance costs so we 
should consider whether a feature really offers value.


Regards,

Anthony Liguori




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-20 Thread Kevin Wolf
Am 20.10.2009 00:20, schrieb Anthony Liguori:
> Mulyadi Santosa wrote:
>> IMO, it would be faster if we provide keyboard shortcuts that will
>> stop and resume VM execution right from SDL guest interface, rather
>> than switching to console monitor first and type "s" or "c"
>> respectively.
>>   
> 
> Is this really common of an operation that you would need an escape key 
> for it?
> 
> Why are you so frequently stopping and continuing a guest?

Why are you all trying to explain to him that actually he doesn't want
to have this feature? I could have used it, too, at times (stop the
guest to have enough time to attach gdb, for example). There are other
ways to do it (although they are not as simple) and I used them, but
that doesn't make this feature less useful.

Does it take anything away for you? Or do you have plans to use those
keys otherwise? If not, why not add a feature that some might find
useful, even though others don't?

Kevin




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-20 Thread Daniel P. Berrange
On Tue, Oct 20, 2009 at 10:16:09AM +0700, Mulyadi Santosa wrote:
> Hi Anthony...
> 
> On Tue, Oct 20, 2009 at 5:20 AM, Anthony Liguori  
> wrote:
> > Mulyadi Santosa wrote:
> >>
> >> IMO, it would be faster if we provide keyboard shortcuts that will
> >> stop and resume VM execution right from SDL guest interface, rather
> >> than switching to console monitor first and type "s" or "c"
> >> respectively.
> >>
> >
> > Is this really common of an operation that you would need an escape key for
> > it?
> >
> > Why are you so frequently stopping and continuing a guest?
> 
> Thanks for giving a review.
> 
> One of the use case is to pause guest at a specific moment relatively
> fast. For example, I boot a guest and I want to capture at a certain
> moment when the guest kernel initialize and print something in the
> screen.
> 
> As these message scrolls fast, I find it more intuitive if we could
> just press a key to pause the guest, giving us enough time to capture
> the display and resume the execution. If we switch to qemu monitor
> first, most of the time we already lost the moment.

If its too slow to switch to the monitor virtual console,then don't
configure the monitor in that way. Set it up to be on stdio, or one
of the other backends. That lets you have both the monitor & SDL
display visible at the same time & would be just as fast to type
in 'stop'  at the appropriate time.

If its kernel text output you need to see then a serial port + logging
is the best option here as Gerd suggests. If its video output you need
to see, then VNC along with something like vnc2swf which will record the
entire VNC data stream to a movie, which you can then play back and
easily pause at any point.

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-20 Thread Gerd Hoffmann

On 10/20/09 05:16, Mulyadi Santosa wrote:

As these message scrolls fast, I find it more intuitive if we could
just press a key to pause the guest, giving us enough time to capture
the display and resume the execution. If we switch to qemu monitor
first, most of the time we already lost the moment.


I'd find it more intuitive to setup a serial console in the guest, then 
simply log everything to a file ...


cheers,
  Gerd





Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-19 Thread Mulyadi Santosa
Hi Anthony...

On Tue, Oct 20, 2009 at 5:20 AM, Anthony Liguori  wrote:
> Mulyadi Santosa wrote:
>>
>> IMO, it would be faster if we provide keyboard shortcuts that will
>> stop and resume VM execution right from SDL guest interface, rather
>> than switching to console monitor first and type "s" or "c"
>> respectively.
>>
>
> Is this really common of an operation that you would need an escape key for
> it?
>
> Why are you so frequently stopping and continuing a guest?

Thanks for giving a review.

One of the use case is to pause guest at a specific moment relatively
fast. For example, I boot a guest and I want to capture at a certain
moment when the guest kernel initialize and print something in the
screen.

As these message scrolls fast, I find it more intuitive if we could
just press a key to pause the guest, giving us enough time to capture
the display and resume the execution. If we switch to qemu monitor
first, most of the time we already lost the moment.


-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com




Re: [Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-19 Thread Anthony Liguori

Mulyadi Santosa wrote:

IMO, it would be faster if we provide keyboard shortcuts that will
stop and resume VM execution right from SDL guest interface, rather
than switching to console monitor first and type "s" or "c"
respectively.
  


Is this really common of an operation that you would need an escape key 
for it?


Why are you so frequently stopping and continuing a guest?

Regards,

Anthony Liguori




[Qemu-devel] [PATCH] new SDL keyboard shortcuts to start and stop VM

2009-10-18 Thread Mulyadi Santosa
IMO, it would be faster if we provide keyboard shortcuts that will
stop and resume VM execution right from SDL guest interface, rather
than switching to console monitor first and type "s" or "c"
respectively.

Note: I simply skip checking the keys in encrypted block devices when
resuming the VM. Not sure whether we really need it or not.

Signed-off-by: Mulyadi Santosa 

sdl.c |9 +
 1 file changed, 9 insertions(+)

--- sdl.c.bak   2009-08-02 16:00:28.0 +0700
+++ sdl.c   2009-10-18 22:53:59.0 +0700
@@ -440,6 +440,7 @@ static void sdl_refresh(DisplayState *ds
 if (gui_key_modifier_pressed) {
 int keycode;
 keycode = sdl_keyevent_to_keycode(&ev->key);
+//fprintf(stderr,"scan code of key pressed is
%d\n",keycode);
 switch(keycode) {
 case 0x21: /* 'f' key on US keyboard */
 toggle_full_screen(ds);
@@ -456,6 +457,14 @@ static void sdl_refresh(DisplayState *ds
 }
 gui_keysym = 1;
 break;
+case 0x1f: /* 's' key -- stopping VM */
+vm_stop(16); /* 16 is EXCP_INTERRUPT */
+gui_keysym = 1;
+break;
+case 0x2e: /* 'c' key -- resuming VM */
+vm_start(); /* we skip checking encrypted
block drive */
+gui_keysym = 1;
+break;
 default:
 break;
 }