All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Tips for adding "sendkeys"
@ 2008-02-28 21:39 David Barrett
  2008-02-28 23:50 ` Alexander Graf
  0 siblings, 1 reply; 3+ messages in thread
From: David Barrett @ 2008-02-28 21:39 UTC (permalink / raw)
  To: qemu-devel

Hi there, can you give me any tips for where to get started adding a new 
function "sendkeys" to the monitor that is essentially like "sendkey" 
except for multiple keystrokes?

I'm using Qemu for some automated testing (in conjunction with AutoIt on 
the guest XP image) and it's working great.  Essentially, I've set up:

1) A stock XP guest image with all windows closed except for a big 
command prompt that has keyboard focus.

2) A script on the Linux host that launches the guest with "-loadvm" and 
"-monitor stdio" that uses "sendkey" to start an AutoIt script inside 
the guest.

The AutoIt script does all the heavy lifting of actually running the 
automated test.  However, I need "sendkey" in order to download the 
latest test script into the guest OS, and then to run it.

This works fine today, but I'm finding my Linux host scripts full of 
long strings of:

	sendkey ret
	sendkey a
	sendkey kp_decimal
	sendkey a
	sendkey u
	sendkey 3
	sendkey ret

I'd much rather do something like:

	sendkeys wget http://10.0.2.2/script.au3\ret
	sendkeys script.au3\ret

I'm guessing this is a very straightforward addition to the monitor 
code.  However, the Qemu source is rather imposing and I'm not sure 
where to start.

Can someone give me some file and function names to start looking 
around?  Something along the lines of:

"Oh, that should be simple.  Open up foo.c and look for function bar(); 
it lists all the monitor commands.  Add "sendkeys" to the list, and 
implement it in foo_impl.c.  I recommend just calling "foo_sendkey()" as 
you loop across the string.  Also, be sure to increment "numcommands" in 
"foo_func.h" else it'll destroy the universe."

Any tips you have would be appreciated.  Thanks!

-david

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

* Re: [Qemu-devel] Tips for adding "sendkeys"
  2008-02-28 21:39 [Qemu-devel] Tips for adding "sendkeys" David Barrett
@ 2008-02-28 23:50 ` Alexander Graf
  2008-02-29  0:19   ` David Barrett
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Graf @ 2008-02-28 23:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Barrett

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

Hi David,

On Feb 28, 2008, at 10:39 PM, David Barrett wrote:

> Hi there, can you give me any tips for where to get started adding a  
> new function "sendkeys" to the monitor that is essentially like  
> "sendkey" except for multiple keystrokes?

I don't really think that is needed. The sendkey command was  
implemented to send real keystrokes. A 'sendkeys' can always be  
simulated using multiple strokes.

>
>
> I'm using Qemu for some automated testing (in conjunction with  
> AutoIt on the guest XP image) and it's working great.  Essentially,  
> I've set up:
>
> 1) A stock XP guest image with all windows closed except for a big  
> command prompt that has keyboard focus.
>
> 2) A script on the Linux host that launches the guest with "-loadvm"  
> and "-monitor stdio" that uses "sendkey" to start an AutoIt script  
> inside the guest.
>
> The AutoIt script does all the heavy lifting of actually running the  
> automated test.  However, I need "sendkey" in order to download the  
> latest test script into the guest OS, and then to run it.
>
> This works fine today, but I'm finding my Linux host scripts full of  
> long strings of:
>
> 	sendkey ret
> 	sendkey a
> 	sendkey kp_decimal
> 	sendkey a
> 	sendkey u
> 	sendkey 3
> 	sendkey ret
>
> I'd much rather do something like:
>
> 	sendkeys wget http://10.0.2.2/script.au3\ret
> 	sendkeys script.au3\ret

You could just create a script/program that converts your command line  
to several 'sendkey' commands. An idea of how to implement that in C  
is attached.

>
>
> I'm guessing this is a very straightforward addition to the monitor  
> code.  However, the Qemu source is rather imposing and I'm not sure  
> where to start.

This would be monitor.c. Afaik every handling of the monitor command  
line is done there. I still don't really think it's necessary.

Alex


[-- Attachment #2: sendkey.c --]
[-- Type: application/octet-stream, Size: 1711 bytes --]

#include <stdio.h>
#include <string.h>

char *map[] = {
/* 0x00 - 0x0F */
"", "", "", "", "", "", "", "", "",  "", "", "", "ret", "", "", "",
/* 0x10 - 0x1F */
"", "", "", "", "", "", "", "", "",  "", "", "", "", "", "",  "",
/* 0x20 - 0x2F */
"", "", "", "", "", "", "", "", "",  "", "", "", "", "", "",  "",
/* 0x30 - 0x3F */
"", "", "", "", "", "", "", "", "",  "", "", "", "", "", "",  "",
/* 0x40 - 0x4F */
"", "shift-a", "shift-b", "shift-c", "", "", "", "", "",  "", "", "", "", "", "",  "",
/* 0x50 - 0x5F */
"", "", "", "", "", "", "", "", "",  "", "", "", "", "", "",  "",
/* 0x60 - 0x6F */
"", "a", "b", "c", "", "", "", "", "",  "", "", "", "", "", "",  "",
/* 0x70 - 0x7F */
"", "", "", "", "", "", "", "", "",  "", "", "", "", "", "",  "",
/* 0x80 - 0x8F */
"", "", "", "", "", "", "", "", "",  "", "", "", "", "", "",  "",
/* 0x90 - 0x9F */
"", "", "", "", "", "", "", "", "",  "", "", "", "", "", "",  "",
/* 0xA0 - 0xAF */
"", "", "", "", "", "", "", "", "",  "", "", "", "", "", "", "",
/* 0xB0 - 0xBF */
"", "", "", "", "", "", "", "", "",  "", "", "", "", "", "", "",
/* 0xC0 - 0xCF */
"", "", "", "", "", "", "", "", "",  "", "", "", "", "", "", "",
/* 0xD0 - 0xDF */
"", "", "", "", "", "", "", "", "",  "", "", "", "", "", "", "",
/* 0xE0 - 0xEF */
"", "", "", "", "", "", "", "", "",  "", "", "", "", "", "", "",
/* 0xF0 - 0xFF */
"", "", "", "", "", "", "", "", "",  "", "", "", "", "", "", "",
};

int main(int argc, unsigned char **argv) {
    unsigned char *ns;
    if(argc != 2) { printf("Error: specify text to convert as $1\n"); return 1; }
    for(ns=argv[1]; *ns; ns++) {
        char *resolved = map[*ns];
        if(strlen(resolved)) printf("sendkey %s\n", resolved);
    }
}

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



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

* Re: [Qemu-devel] Tips for adding "sendkeys"
  2008-02-28 23:50 ` Alexander Graf
@ 2008-02-29  0:19   ` David Barrett
  0 siblings, 0 replies; 3+ messages in thread
From: David Barrett @ 2008-02-29  0:19 UTC (permalink / raw)
  To: Alexander Graf; +Cc: qemu-devel

I agree, it's only for convenience.  Sendkey is great for individual 
keystrokes, but it's not super convenient for batches of keystrokes.

Incidentally, what's the policy for patch submission to Qemu?  If I 
write this patch and submit it, what are the odds that it would get 
accepted in the mainline?

If the policy is only bugfixes and functional enhancements are accepted 
(a reasonable policy), then I'll just make due -- I don't want to tie 
myself to a custom fork forever.

But if the policy includes convenience additions like this, then I might 
take a crack at it.

Thanks!

-david

Alexander Graf wrote:
> Hi David,
> 
> On Feb 28, 2008, at 10:39 PM, David Barrett wrote:
> 
>> Hi there, can you give me any tips for where to get started adding a 
>> new function "sendkeys" to the monitor that is essentially like 
>> "sendkey" except for multiple keystrokes?
> 
> I don't really think that is needed. The sendkey command was implemented 
> to send real keystrokes. A 'sendkeys' can always be simulated using 
> multiple strokes.
> 
>>
>>
>> I'm using Qemu for some automated testing (in conjunction with AutoIt 
>> on the guest XP image) and it's working great.  Essentially, I've set up:
>>
>> 1) A stock XP guest image with all windows closed except for a big 
>> command prompt that has keyboard focus.
>>
>> 2) A script on the Linux host that launches the guest with "-loadvm" 
>> and "-monitor stdio" that uses "sendkey" to start an AutoIt script 
>> inside the guest.
>>
>> The AutoIt script does all the heavy lifting of actually running the 
>> automated test.  However, I need "sendkey" in order to download the 
>> latest test script into the guest OS, and then to run it.
>>
>> This works fine today, but I'm finding my Linux host scripts full of 
>> long strings of:
>>
>>     sendkey ret
>>     sendkey a
>>     sendkey kp_decimal
>>     sendkey a
>>     sendkey u
>>     sendkey 3
>>     sendkey ret
>>
>> I'd much rather do something like:
>>
>>     sendkeys wget http://10.0.2.2/script.au3\ret
>>     sendkeys script.au3\ret
> 
> You could just create a script/program that converts your command line 
> to several 'sendkey' commands. An idea of how to implement that in C is 
> attached.
> 
>>
>>
>> I'm guessing this is a very straightforward addition to the monitor 
>> code.  However, the Qemu source is rather imposing and I'm not sure 
>> where to start.
> 
> This would be monitor.c. Afaik every handling of the monitor command 
> line is done there. I still don't really think it's necessary.
> 
> Alex
> 
> 

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

end of thread, other threads:[~2008-02-29  0:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-28 21:39 [Qemu-devel] Tips for adding "sendkeys" David Barrett
2008-02-28 23:50 ` Alexander Graf
2008-02-29  0:19   ` David Barrett

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.