From patchwork Wed Apr 14 09:55:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 50135 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4F3EEB7D0E for ; Wed, 14 Apr 2010 20:08:59 +1000 (EST) Received: from localhost ([127.0.0.1]:37578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1zP3-0005iD-Tv for incoming@patchwork.ozlabs.org; Wed, 14 Apr 2010 06:01:01 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O1zJt-0003sj-Og for qemu-devel@nongnu.org; Wed, 14 Apr 2010 05:55:41 -0400 Received: from [140.186.70.92] (port=40775 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1zJo-0003om-4w for qemu-devel@nongnu.org; Wed, 14 Apr 2010 05:55:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O1zJg-0007qC-Vm for qemu-devel@nongnu.org; Wed, 14 Apr 2010 05:55:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39531) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1zJg-0007px-OA for qemu-devel@nongnu.org; Wed, 14 Apr 2010 05:55:28 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o3E9tRq4032212 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 14 Apr 2010 05:55:27 -0400 Received: from zweiblum.home.kraxel.org (vpn1-4-70.ams2.redhat.com [10.36.4.70]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o3E9tOrW023090; Wed, 14 Apr 2010 05:55:25 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id B1B0970114; Wed, 14 Apr 2010 11:55:23 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 14 Apr 2010 11:55:15 +0200 Message-Id: <1271238922-10008-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1271238922-10008-1-git-send-email-kraxel@redhat.com> References: <1271238922-10008-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [RfC PATCH 04/11] spice: add keyboard X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Open keyboard channel. Now you can type into the spice client and the keyboard events are sent to your guest. You'll need some other display like vnc to actually see the guest responding to them though. --- Makefile.target | 2 +- qemu-spice.h | 1 + spice-input.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ spice.c | 2 + 4 files changed, 61 insertions(+), 1 deletions(-) create mode 100644 spice-input.c diff --git a/Makefile.target b/Makefile.target index ad3e595..4da1b27 100644 --- a/Makefile.target +++ b/Makefile.target @@ -194,7 +194,7 @@ obj-i386-y += cirrus_vga.o apic.o ioapic.o piix_pci.o obj-i386-y += vmmouse.o vmport.o hpet.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o -obj-i386-$(CONFIG_SPICE) += spice.o +obj-i386-$(CONFIG_SPICE) += spice.o spice-input.o # shared objects obj-ppc-y = ppc.o diff --git a/qemu-spice.h b/qemu-spice.h index 5597576..ceb3db2 100644 --- a/qemu-spice.h +++ b/qemu-spice.h @@ -12,6 +12,7 @@ extern SpiceServer *spice_server; extern int using_spice; void qemu_spice_init(void); +void qemu_spice_input_init(void); #else /* CONFIG_SPICE */ diff --git a/spice-input.c b/spice-input.c new file mode 100644 index 0000000..e05f300 --- /dev/null +++ b/spice-input.c @@ -0,0 +1,57 @@ +#include +#include +#include + +#include + +#include "qemu-common.h" +#include "qemu-spice.h" +#include "console.h" + +/* keyboard bits */ + +typedef struct QemuSpiceKbd { + SpiceKbdInstance sin; + int ledstate; +} QemuSpiceKbd; + +static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag); +static uint8_t kbd_get_leds(SpiceKbdInstance *sin); +static void kbd_leds(void *opaque, int l); + +static SpiceKbdInterface kbd_interface = { + .base.type = SPICE_INTERFACE_KEYBOARD, + .base.description = "qemu keyboard", + .base.major_version = SPICE_INTERFACE_KEYBOARD_MAJOR, + .base.minor_version = SPICE_INTERFACE_KEYBOARD_MINOR, + .push_scan_freg = kbd_push_key, + .get_leds = kbd_get_leds, +}; + +static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag) +{ + kbd_put_keycode(frag); +} + +static uint8_t kbd_get_leds(SpiceKbdInstance *sin) +{ + QemuSpiceKbd *kbd = container_of(sin, QemuSpiceKbd, sin); + return kbd->ledstate; +} + +static void kbd_leds(void *opaque, int ledstate) +{ + QemuSpiceKbd *kbd = opaque; + kbd->ledstate = ledstate; + spice_server_kbd_leds(&kbd->sin, ledstate); +} + +void qemu_spice_input_init(void) +{ + QemuSpiceKbd *kbd; + + kbd = qemu_mallocz(sizeof(*kbd)); + kbd->sin.base.sif = &kbd_interface.base; + spice_server_add_interface(spice_server, &kbd->sin.base); + qemu_add_led_event_handler(kbd_leds, kbd); +} diff --git a/spice.c b/spice.c index 5315b18..68d8c95 100644 --- a/spice.c +++ b/spice.c @@ -167,4 +167,6 @@ void qemu_spice_init(void) spice_server_init(spice_server, &core_interface); using_spice = 1; + + qemu_spice_input_init(); }