* [Qemu-devel] [PATCH] un-register kbd driver for USB kbd unplug
@ 2010-06-08 10:43 Jes.Sorensen
2010-06-08 10:43 ` [Qemu-devel] [PATCH] un-register kbd driver in case of " Jes.Sorensen
2010-06-08 12:14 ` [Qemu-devel] Re: [PATCH] un-register kbd driver for " Shahar Havivi
0 siblings, 2 replies; 6+ messages in thread
From: Jes.Sorensen @ 2010-06-08 10:43 UTC (permalink / raw)
To: anthony; +Cc: shavivi, qemu-devel, Jes Sorensen
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Hi,
This is a fairly simple fix for the problem where the keyboard event
handler is left in place when a keyboard is unplugged, eg. USB.
The long term solution would be to use Shahar Havivi's multi-keyboard
support patch[1] from March, but until Shahar's patch is ready, this one
fixes the current crash problem.
Cheers,
Jes
[1]: http://www.mail-archive.com/qemu-devel@nongnu.org/msg28589.html
Jes Sorensen (1):
un-register kbd driver in case of USB kbd unplug.
console.h | 1 +
hw/usb-hid.c | 3 +++
input.c | 6 ++++++
3 files changed, 10 insertions(+), 0 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH] un-register kbd driver in case of USB kbd unplug.
2010-06-08 10:43 [Qemu-devel] [PATCH] un-register kbd driver for USB kbd unplug Jes.Sorensen
@ 2010-06-08 10:43 ` Jes.Sorensen
2010-06-08 12:14 ` [Qemu-devel] Re: [PATCH] un-register kbd driver for " Shahar Havivi
1 sibling, 0 replies; 6+ messages in thread
From: Jes.Sorensen @ 2010-06-08 10:43 UTC (permalink / raw)
To: anthony; +Cc: shavivi, qemu-devel, Jes Sorensen
From: Jes Sorensen <Jes.Sorensen@redhat.com>
If a USB keyboard is unplugged, the keyboard eventhandler is never
removed, and events will continue to be passed through to the device,
causing crashes or memory corruption.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
console.h | 1 +
hw/usb-hid.c | 3 +++
input.c | 6 ++++++
3 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/console.h b/console.h
index cac959f..aafb031 100644
--- a/console.h
+++ b/console.h
@@ -42,6 +42,7 @@ typedef struct QEMUPutLEDEntry {
} QEMUPutLEDEntry;
void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
+void qemu_remove_kbd_event_handler(void);
QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
void *opaque, int absolute,
const char *name);
diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index 8e6c6e0..333b626 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -856,6 +856,9 @@ static void usb_hid_handle_destroy(USBDevice *dev)
if (s->kind != USB_KEYBOARD)
qemu_remove_mouse_event_handler(s->ptr.eh_entry);
+ if (s->kind == USB_KEYBOARD)
+ qemu_remove_kbd_event_handler();
+
/* TODO: else */
}
diff --git a/input.c b/input.c
index 651442d..ec05548 100644
--- a/input.c
+++ b/input.c
@@ -42,6 +42,12 @@ void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
qemu_put_kbd_event = func;
}
+void qemu_remove_kbd_event_handler(void)
+{
+ qemu_put_kbd_event_opaque = NULL;
+ qemu_put_kbd_event = NULL;
+}
+
static void check_mode_change(void)
{
static int current_is_absolute, current_has_absolute;
--
1.6.5.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] Re: [PATCH] un-register kbd driver for USB kbd unplug
2010-06-08 10:43 [Qemu-devel] [PATCH] un-register kbd driver for USB kbd unplug Jes.Sorensen
2010-06-08 10:43 ` [Qemu-devel] [PATCH] un-register kbd driver in case of " Jes.Sorensen
@ 2010-06-08 12:14 ` Shahar Havivi
1 sibling, 0 replies; 6+ messages in thread
From: Shahar Havivi @ 2010-06-08 12:14 UTC (permalink / raw)
To: Jes.Sorensen, anthony; +Cc: qemu-devel
On Tue, Jun 08, 2010 at 12:43:50PM +0200, Jes.Sorensen@redhat.com wrote:
> Date: Tue, 8 Jun 2010 12:43:50 +0200
> From: Jes.Sorensen@redhat.com
> To: anthony@codemonkey.ws
> Cc: qemu-devel@nongnu.org, shavivi@redhat.com,
> Jes Sorensen <Jes.Sorensen@redhat.com>
> Subject: [PATCH] un-register kbd driver for USB kbd unplug
>
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> Hi,
>
> This is a fairly simple fix for the problem where the keyboard event
> handler is left in place when a keyboard is unplugged, eg. USB.
>
> The long term solution would be to use Shahar Havivi's multi-keyboard
> support patch[1] from March, but until Shahar's patch is ready, this one
> fixes the current crash problem.
>
> Cheers,
> Jes
Anthony,
You reply that you applied the patch:
http://lists.gnu.org/archive/html/qemu-devel/2010-05/msg00673.html
but it didn't made it, is there a problem with the patch?
Thanks,
Shahar.
>
> [1]: http://www.mail-archive.com/qemu-devel@nongnu.org/msg28589.html
>
> Jes Sorensen (1):
> un-register kbd driver in case of USB kbd unplug.
>
> console.h | 1 +
> hw/usb-hid.c | 3 +++
> input.c | 6 ++++++
> 3 files changed, 10 insertions(+), 0 deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH] un-register kbd driver in case of USB kbd unplug.
2010-06-08 13:12 [Qemu-devel] [PATCH v2] " Jes.Sorensen
@ 2010-06-08 13:12 ` Jes.Sorensen
2010-06-09 7:52 ` Markus Armbruster
2010-06-14 20:57 ` Anthony Liguori
0 siblings, 2 replies; 6+ messages in thread
From: Jes.Sorensen @ 2010-06-08 13:12 UTC (permalink / raw)
To: anthony; +Cc: kwolf, shavivi, qemu-devel, Jes Sorensen
From: Jes Sorensen <Jes.Sorensen@redhat.com>
If a USB keyboard is unplugged, the keyboard eventhandler is never
removed, and events will continue to be passed through to the device,
causing crashes or memory corruption.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
console.h | 1 +
hw/usb-hid.c | 8 ++++++--
input.c | 6 ++++++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/console.h b/console.h
index cac959f..aafb031 100644
--- a/console.h
+++ b/console.h
@@ -42,6 +42,7 @@ typedef struct QEMUPutLEDEntry {
} QEMUPutLEDEntry;
void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
+void qemu_remove_kbd_event_handler(void);
QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
void *opaque, int absolute,
const char *name);
diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index 8e6c6e0..ca04511 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -854,9 +854,13 @@ static void usb_hid_handle_destroy(USBDevice *dev)
{
USBHIDState *s = (USBHIDState *)dev;
- if (s->kind != USB_KEYBOARD)
+ switch(s->kind) {
+ case USB_KEYBOARD:
+ qemu_remove_kbd_event_handler();
+ break;
+ default:
qemu_remove_mouse_event_handler(s->ptr.eh_entry);
- /* TODO: else */
+ }
}
static int usb_hid_initfn(USBDevice *dev, int kind)
diff --git a/input.c b/input.c
index 651442d..ec05548 100644
--- a/input.c
+++ b/input.c
@@ -42,6 +42,12 @@ void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
qemu_put_kbd_event = func;
}
+void qemu_remove_kbd_event_handler(void)
+{
+ qemu_put_kbd_event_opaque = NULL;
+ qemu_put_kbd_event = NULL;
+}
+
static void check_mode_change(void)
{
static int current_is_absolute, current_has_absolute;
--
1.6.5.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] un-register kbd driver in case of USB kbd unplug.
2010-06-08 13:12 ` [Qemu-devel] [PATCH] un-register kbd driver in case of " Jes.Sorensen
@ 2010-06-09 7:52 ` Markus Armbruster
2010-06-14 20:57 ` Anthony Liguori
1 sibling, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2010-06-09 7:52 UTC (permalink / raw)
To: Jes.Sorensen; +Cc: kwolf, shavivi, qemu-devel
Jes.Sorensen@redhat.com writes:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> If a USB keyboard is unplugged, the keyboard eventhandler is never
> removed, and events will continue to be passed through to the device,
> causing crashes or memory corruption.
Looks good.
I wonder how many more unplug surprises to expect.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] un-register kbd driver in case of USB kbd unplug.
2010-06-08 13:12 ` [Qemu-devel] [PATCH] un-register kbd driver in case of " Jes.Sorensen
2010-06-09 7:52 ` Markus Armbruster
@ 2010-06-14 20:57 ` Anthony Liguori
1 sibling, 0 replies; 6+ messages in thread
From: Anthony Liguori @ 2010-06-14 20:57 UTC (permalink / raw)
To: Jes.Sorensen; +Cc: kwolf, shavivi, qemu-devel
On 06/08/2010 08:12 AM, Jes.Sorensen@redhat.com wrote:
> From: Jes Sorensen<Jes.Sorensen@redhat.com>
>
> If a USB keyboard is unplugged, the keyboard eventhandler is never
> removed, and events will continue to be passed through to the device,
> causing crashes or memory corruption.
>
> Signed-off-by: Jes Sorensen<Jes.Sorensen@redhat.com>
>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> console.h | 1 +
> hw/usb-hid.c | 8 ++++++--
> input.c | 6 ++++++
> 3 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/console.h b/console.h
> index cac959f..aafb031 100644
> --- a/console.h
> +++ b/console.h
> @@ -42,6 +42,7 @@ typedef struct QEMUPutLEDEntry {
> } QEMUPutLEDEntry;
>
> void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
> +void qemu_remove_kbd_event_handler(void);
> QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
> void *opaque, int absolute,
> const char *name);
> diff --git a/hw/usb-hid.c b/hw/usb-hid.c
> index 8e6c6e0..ca04511 100644
> --- a/hw/usb-hid.c
> +++ b/hw/usb-hid.c
> @@ -854,9 +854,13 @@ static void usb_hid_handle_destroy(USBDevice *dev)
> {
> USBHIDState *s = (USBHIDState *)dev;
>
> - if (s->kind != USB_KEYBOARD)
> + switch(s->kind) {
> + case USB_KEYBOARD:
> + qemu_remove_kbd_event_handler();
> + break;
> + default:
> qemu_remove_mouse_event_handler(s->ptr.eh_entry);
> - /* TODO: else */
> + }
> }
>
> static int usb_hid_initfn(USBDevice *dev, int kind)
> diff --git a/input.c b/input.c
> index 651442d..ec05548 100644
> --- a/input.c
> +++ b/input.c
> @@ -42,6 +42,12 @@ void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
> qemu_put_kbd_event = func;
> }
>
> +void qemu_remove_kbd_event_handler(void)
> +{
> + qemu_put_kbd_event_opaque = NULL;
> + qemu_put_kbd_event = NULL;
> +}
> +
> static void check_mode_change(void)
> {
> static int current_is_absolute, current_has_absolute;
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-06-14 20:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-08 10:43 [Qemu-devel] [PATCH] un-register kbd driver for USB kbd unplug Jes.Sorensen
2010-06-08 10:43 ` [Qemu-devel] [PATCH] un-register kbd driver in case of " Jes.Sorensen
2010-06-08 12:14 ` [Qemu-devel] Re: [PATCH] un-register kbd driver for " Shahar Havivi
-- strict thread matches above, loose matches on Subject: below --
2010-06-08 13:12 [Qemu-devel] [PATCH v2] " Jes.Sorensen
2010-06-08 13:12 ` [Qemu-devel] [PATCH] un-register kbd driver in case of " Jes.Sorensen
2010-06-09 7:52 ` Markus Armbruster
2010-06-14 20:57 ` Anthony Liguori
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).