* [Qemu-devel] [PATCH] No keyboard / mouse after reboot
@ 2009-07-13 23:26 Dinesh Subhraveti
2009-07-14 1:10 ` Anthony Liguori
0 siblings, 1 reply; 3+ messages in thread
From: Dinesh Subhraveti @ 2009-07-13 23:26 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1935 bytes --]
At system initialization, some guests conclude that i8042 controller is missing when the PS2 buffer is full. As a result, the guest comes up with no keyboard or mouse. The behavior is seen when the user types or mouses over the VNC window during the BIOS phase of a reboot, causing the PS2 buffer to fill up. It doesn't occur when the system boots the first time, since the device is initially disabled and doesn't accept events.
This patch tunes Qemu parameters to reasonable values which make the guest happy. Linux assumes the size of PS2 buffer to be 16 bytes, while Qemu defines it as 256. Reducing PS2_QUEUE_SIZE to 15 ensures that the guest never sees the buffer to be full.
However, PS2 mouse event handler drops mouse events unless there is at least 16 bytes of buffer space left in the queue (to account for mouse movements that consume multiple events). With PS2_QUEUE_SIZE reduced to 15, there will never be 16 bytes left in the queue and no mouse event ever gets in. So the size of reserved buffer space is reduced to 8.
With these changes, both keyboard and mouse remain responsive after reboot, even when typed or moused over during reboot. Tested with SLES 11 GM 64-bit guest.
---
diff --git a/hw/ps2.c b/hw/ps2.c
index fb77005..51a3ab8 100644
--- a/hw/ps2.c
+++ b/hw/ps2.c
@@ -70,7 +70,7 @@
#define MOUSE_STATUS_ENABLED 0x20
#define MOUSE_STATUS_SCALE21 0x10
-#define PS2_QUEUE_SIZE 256
+#define PS2_QUEUE_SIZE 15
typedef struct {
uint8_t data[PS2_QUEUE_SIZE];
@@ -346,7 +346,7 @@ static void ps2_mouse_event(void *opaque,
s->mouse_buttons = buttons_state;
if (!(s->mouse_status & MOUSE_STATUS_REMOTE) &&
- (s->common.queue.count < (PS2_QUEUE_SIZE - 16))) {
+ (s->common.queue.count < (PS2_QUEUE_SIZE - 8))) {
for(;;) {
/* if not remote, send event. Multiple events are sent if
too big deltas */
[-- Attachment #2: Type: text/html, Size: 2920 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] No keyboard / mouse after reboot
2009-07-13 23:26 [Qemu-devel] [PATCH] No keyboard / mouse after reboot Dinesh Subhraveti
@ 2009-07-14 1:10 ` Anthony Liguori
2009-07-14 1:42 ` [Qemu-devel] " Dinesh Subhraveti
0 siblings, 1 reply; 3+ messages in thread
From: Anthony Liguori @ 2009-07-14 1:10 UTC (permalink / raw)
To: Dinesh Subhraveti; +Cc: qemu-devel
Needs a Signed-off-by. However...
Dinesh Subhraveti wrote:
> At system initialization, some guests conclude that i8042 controller
> is missing when the PS2 buffer is full. As a result, the guest comes
> up with no keyboard or mouse. The behavior is seen when the user
> types or mouses over the VNC window during the BIOS phase of a reboot,
> causing the PS2 buffer to fill up. It doesn't occur when the system
> boots the first time, since the device is initially disabled and
> doesn't accept events.
>
> This patch tunes Qemu parameters to reasonable values which make the
> guest happy. Linux assumes the size of PS2 buffer to be 16 bytes,
> while Qemu defines it as 256. Reducing PS2_QUEUE_SIZE to 15 ensures
> that the guest never sees the buffer to be full.
Why is Linux making assumptions about queue size being 16? It sounds
broken to me. In fact, I looked in one of my PC hardware books and it
claims that the typical KBD buffer size is around 20 bytes so if Linux
is assuming 16, it's definitely broken.
But there's speculation in the previous thread that we're masking a BIOS
bug. Has that been ruled out?
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] Re: [PATCH] No keyboard / mouse after reboot
2009-07-14 1:10 ` Anthony Liguori
@ 2009-07-14 1:42 ` Dinesh Subhraveti
0 siblings, 0 replies; 3+ messages in thread
From: Dinesh Subhraveti @ 2009-07-14 1:42 UTC (permalink / raw)
To: qemu-devel
"Anthony Liguori" <anthony@codemonkey.ws> wrote in message
news:4A5BDB00.8030100@codemonkey.ws...
> Needs a Signed-off-by. However...
>
> Dinesh Subhraveti wrote:
>> At system initialization, some guests conclude that i8042 controller is
>> missing when the PS2 buffer is full. As a result, the guest comes up
>> with no keyboard or mouse. The behavior is seen when the user types or
>> mouses over the VNC window during the BIOS phase of a reboot, causing the
>> PS2 buffer to fill up. It doesn't occur when the system boots the first
>> time, since the device is initially disabled and doesn't accept events.
>> This patch tunes Qemu parameters to reasonable values which make the
>> guest happy. Linux assumes the size of PS2 buffer to be 16 bytes, while
>> Qemu defines it as 256. Reducing PS2_QUEUE_SIZE to 15 ensures that the
>> guest never sees the buffer to be full.
>
> Why is Linux making assumptions about queue size being 16? It sounds
Good question, for which I don't know the answer. But regardless of the
buffer size, it fills up quite quickly with mouse events, and the guest
would be left without a keyboard.
> broken to me. In fact, I looked in one of my PC hardware books and it
> claims that the typical KBD buffer size is around 20 bytes so if Linux is
> assuming 16, it's definitely broken.
>
> But there's speculation in the previous thread that we're masking a BIOS
> bug. Has that been ruled out?
>
Yeah, this doesn't seem to be a BIOS issue. It is also reproducible
with -kernel option.
Thanks,
Dinesh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-07-14 1:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-13 23:26 [Qemu-devel] [PATCH] No keyboard / mouse after reboot Dinesh Subhraveti
2009-07-14 1:10 ` Anthony Liguori
2009-07-14 1:42 ` [Qemu-devel] " Dinesh Subhraveti
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).