Re: [PATCH] kvm tools: Add support for PS/2 keyboard system

2011-06-02 Thread Ingo Molnar

* Sasha Levin levinsasha...@gmail.com wrote:

 From: John Floren j...@jfloren.net
 
 Add support for PS/2 keyboard system with AUX device (aka mouse).
 The device works with vnc, the guest must be started with the
 '--vnc' parameter for the device to be initialized.
 
 Signed-off-by: John Floren j...@jfloren.net
 [ turn into patch and clean up code ]
 Signed-off-by: Sasha Levin levinsasha...@gmail.com
 ---
  tools/kvm/Makefile|1 +
  tools/kvm/hw/pckbd.c  |  475 
 +

Since this is a PS2 keyboard and mouse driver please name it 
i8042.[ch] like the kernel-side does.

that will also make it easier to find the guest-side - host-side 
pair of guest-driver/host-driver files :-)

  tools/kvm/hw/vesa.c   |3 +
  tools/kvm/include/kvm/pckbd.h |   19 ++
  tools/kvm/ioport.c|4 -
  tools/kvm/kvm-run.c   |5 +-
  6 files changed, 502 insertions(+), 5 deletions(-)
  create mode 100644 tools/kvm/hw/pckbd.c
  create mode 100644 tools/kvm/include/kvm/pckbd.h

In general the code looks very clean to me!

Found two minor nits:

 + ret = state.kq[state.kread++ % QUEUE_SIZE];
 + ret = state.mq[state.mread++ % QUEUE_SIZE];

Please increment the index explicitly, on a separate line - the 
permanent side-effect to the keyboard state is not obvious at first 
sight.

Thanks,

Ingo
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm tools: Add support for PS/2 keyboard system

2011-06-02 Thread Pekka Enberg

On Wed, 1 Jun 2011, Sasha Levin wrote:

From: John Floren j...@jfloren.net

Add support for PS/2 keyboard system with AUX device (aka mouse).
The device works with vnc, the guest must be started with the
'--vnc' parameter for the device to be initialized.

Signed-off-by: John Floren j...@jfloren.net
[ turn into patch and clean up code ]
Signed-off-by: Sasha Levin levinsasha...@gmail.com


I am seeing this in my guest dmesg:

[   24.972609] i8042: PNP: No PS/2 controller found. Probing ports 
directly.

[   25.568982] i8042: Can't read CTR while initializing i8042
[   25.568996] i8042: probe of i8042 failed with error -5
[   25.569102] mousedev: PS/2 mouse device common for all mice

and nothing happens when I try to press some keys in vncviewer. There's a 
small blinking thingy following the mouse which I assume is our guest 
mouse cursor?


Pekka
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm tools: Add support for PS/2 keyboard system

2011-06-02 Thread Pekka Enberg

On Thu, 2 Jun 2011, Ingo Molnar wrote:

Since this is a PS2 keyboard and mouse driver please name it
i8042.[ch] like the kernel-side does.

that will also make it easier to find the guest-side - host-side
pair of guest-driver/host-driver files :-)


Fixed, thanks!
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm tools: Add support for PS/2 keyboard system

2011-06-02 Thread Sasha Levin
On Thu, 2011-06-02 at 11:52 +0300, Pekka Enberg wrote:
 On Wed, 1 Jun 2011, Sasha Levin wrote:
  From: John Floren j...@jfloren.net
 
  Add support for PS/2 keyboard system with AUX device (aka mouse).
  The device works with vnc, the guest must be started with the
  '--vnc' parameter for the device to be initialized.
 
  Signed-off-by: John Floren j...@jfloren.net
  [ turn into patch and clean up code ]
  Signed-off-by: Sasha Levin levinsasha...@gmail.com
 
 I am seeing this in my guest dmesg:
 
 [   24.972609] i8042: PNP: No PS/2 controller found. Probing ports 
 directly.
 [   25.568982] i8042: Can't read CTR while initializing i8042
 [   25.568996] i8042: probe of i8042 failed with error -5
 [   25.569102] mousedev: PS/2 mouse device common for all mice
 
 and nothing happens when I try to press some keys in vncviewer. There's a 
 small blinking thingy following the mouse which I assume is our guest 
 mouse cursor?

Strange, those are the same errors you're supposed to get when theres no
i8042 device at all.

Could you verify that hw/pckbd.c is being built? Did the makefile get
updated?

What I'm seeing here is:

[   49.326316] i8042: PNP: No PS/2 controller found. Probing ports
directly.
[   50.410492] serio: i8042 KBD port at 0x60,0x64 irq 1
[   51.518829] serio: i8042 AUX port at 0x60,0x64 irq 12
[   51.519104] mousedev: PS/2 mouse device common for all mice

-- 

Sasha.

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm tools: Add support for PS/2 keyboard system

2011-06-02 Thread Pekka Enberg

On Thu, 2 Jun 2011, Sasha Levin wrote:

Strange, those are the same errors you're supposed to get when theres no
i8042 device at all.

Could you verify that hw/pckbd.c is being built? Did the makefile get
updated?

What I'm seeing here is:

[   49.326316] i8042: PNP: No PS/2 controller found. Probing ports
directly.
[   50.410492] serio: i8042 KBD port at 0x60,0x64 irq 1
[   51.518829] serio: i8042 AUX port at 0x60,0x64 irq 12
[   51.519104] mousedev: PS/2 mouse device common for all mice


kbd_init() is called if that's what you wanted to know.

Pekka
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm tools: Add support for PS/2 keyboard system

2011-06-02 Thread Ingo Molnar

* Pekka Enberg penb...@kernel.org wrote:

 On Thu, 2 Jun 2011, Sasha Levin wrote:
 Strange, those are the same errors you're supposed to get when theres no
 i8042 device at all.
 
 Could you verify that hw/pckbd.c is being built? Did the makefile get
 updated?
 
 What I'm seeing here is:
 
 [   49.326316] i8042: PNP: No PS/2 controller found. Probing ports
 directly.
 [   50.410492] serio: i8042 KBD port at 0x60,0x64 irq 1
 [   51.518829] serio: i8042 AUX port at 0x60,0x64 irq 12
 [   51.519104] mousedev: PS/2 mouse device common for all mice
 
 kbd_init() is called if that's what you wanted to know.

btw., i suspect port IO printf()s in i8042.c would be rather 
informative now: they would nicely and synchronously interlace with 
guest serial console output, showing exactly what is going on in the 
probing sequence.

Thanks,

Ingo
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm tools: Add support for PS/2 keyboard system

2011-06-02 Thread Pekka Enberg
On Thu, 2011-06-02 at 11:18 +0200, Ingo Molnar wrote:
 * Pekka Enberg penb...@kernel.org wrote:
 
  On Thu, 2 Jun 2011, Sasha Levin wrote:
  Strange, those are the same errors you're supposed to get when theres no
  i8042 device at all.
  
  Could you verify that hw/pckbd.c is being built? Did the makefile get
  updated?
  
  What I'm seeing here is:
  
  [   49.326316] i8042: PNP: No PS/2 controller found. Probing ports
  directly.
  [   50.410492] serio: i8042 KBD port at 0x60,0x64 irq 1
  [   51.518829] serio: i8042 AUX port at 0x60,0x64 irq 12
  [   51.519104] mousedev: PS/2 mouse device common for all mice
  
  kbd_init() is called if that's what you wanted to know.
 
 btw., i suspect port IO printf()s in i8042.c would be rather 
 informative now: they would nicely and synchronously interlace with 
 guest serial console output, showing exactly what is going on in the 
 probing sequence.

Do you mean a generic ioport tracing thing?

  ./kvm run --trace=ioport

or something?

Pekka


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm tools: Add support for PS/2 keyboard system

2011-06-02 Thread Sasha Levin
On Thu, 2011-06-02 at 12:15 +0300, Pekka Enberg wrote:
 On Thu, 2 Jun 2011, Sasha Levin wrote:
  Strange, those are the same errors you're supposed to get when theres no
  i8042 device at all.
 
  Could you verify that hw/pckbd.c is being built? Did the makefile get
  updated?
 
  What I'm seeing here is:
 
  [   49.326316] i8042: PNP: No PS/2 controller found. Probing ports
  directly.
  [   50.410492] serio: i8042 KBD port at 0x60,0x64 irq 1
  [   51.518829] serio: i8042 AUX port at 0x60,0x64 irq 12
  [   51.519104] mousedev: PS/2 mouse device common for all mice
 
 kbd_init() is called if that's what you wanted to know.

I've pulled master, and tried running keyboard on it. What I see now is:

[   33.114810] i8042: PNP: No PS/2 controller found. Probing ports
directly.
[   33.365370] serio: i8042 KBD port at 0x60,0x64 irq 1
[   33.365599] mousedev: PS/2 mouse device common for all mice

Which means that the mouse is gone. Might be related to what you're
seeing.


-- 

Sasha.

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm tools: Add support for PS/2 keyboard system

2011-06-02 Thread Ingo Molnar

* Pekka Enberg penb...@kernel.org wrote:

 On Thu, 2011-06-02 at 11:18 +0200, Ingo Molnar wrote:
  * Pekka Enberg penb...@kernel.org wrote:
  
   On Thu, 2 Jun 2011, Sasha Levin wrote:
   Strange, those are the same errors you're supposed to get when theres no
   i8042 device at all.
   
   Could you verify that hw/pckbd.c is being built? Did the makefile get
   updated?
   
   What I'm seeing here is:
   
   [   49.326316] i8042: PNP: No PS/2 controller found. Probing ports
   directly.
   [   50.410492] serio: i8042 KBD port at 0x60,0x64 irq 1
   [   51.518829] serio: i8042 AUX port at 0x60,0x64 irq 12
   [   51.519104] mousedev: PS/2 mouse device common for all mice
   
   kbd_init() is called if that's what you wanted to know.
  
  btw., i suspect port IO printf()s in i8042.c would be rather 
  informative now: they would nicely and synchronously interlace with 
  guest serial console output, showing exactly what is going on in the 
  probing sequence.
 
 Do you mean a generic ioport tracing thing?
 
   ./kvm run --trace=ioport
 
 or something?

heh, yeah :-)

btw., i'm getting the same message here:

[1.458000] usbcore: registered new interface driver libusual
[1.46] i8042: PNP: No PS/2 controller found. Probing ports directly.
[1.463000] i8042: Can't read CTR while initializing i8042
[1.464000] i8042: probe of i8042 failed with error -5
[1.465000] mousedev: PS/2 mouse device common for all mice
[1.467000] rtc_cmos rtc_cmos: rtc core: registered rtc_cmos as rtc0

Thanks,

Ingo
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm tools: Add support for PS/2 keyboard system

2011-06-02 Thread Ingo Molnar

btw., i tried to match up the kernel's i8042.c with kvm's and it was 
pretty hard due to arbitrary differences. The kernel knows about:

---
/*
 * Status register bits.
 */

#define I8042_STR_PARITY0x80
#define I8042_STR_TIMEOUT   0x40
#define I8042_STR_AUXDATA   0x20
#define I8042_STR_KEYLOCK   0x10
#define I8042_STR_CMDDAT0x08
#define I8042_STR_MUXERR0x04
#define I8042_STR_IBF   0x02
#define I8042_STR_OBF   0x01

/*
 * Control register bits.
 */

#define I8042_CTR_KBDINT0x01
#define I8042_CTR_AUXINT0x02
#define I8042_CTR_IGNKEYLOCK0x08
#define I8042_CTR_KBDDIS0x10
#define I8042_CTR_AUXDIS0x20
#define I8042_CTR_XLATE 0x40

/*
 * Return codes.
 */

#define I8042_RET_CTL_TEST  0x55
---


While hw/i8042.c knows about similar things, just under different 
names:

---
#define CMD_READ_MODE   0x20
#define CMD_WRITE_MODE  0x60
#define CMD_WRITE_AUX_BUF   0xD3
#define CMD_WRITE_AUX   0xD4
#define CMD_TEST_AUX0xA9
#define CMD_DISABLE_AUX 0xA7
#define CMD_ENABLE_AUX  0xA8

#define RESPONSE_ACK0xFA

#define MODE_DISABLE_AUX0x20

#define AUX_ENABLE_REPORTING0x20
#define AUX_SCALING_FLAG0x10
#define AUX_DEFAULT_RESOLUTION  0x2
#define AUX_DEFAULT_SAMPLE  100

#define KBD_STATUS_SYS  0x4
#define KBD_STATUS_A2   0x8
#define KBD_STATUS_INH  0x10
#define KBD_STATUS_OBF  0x01
#define KBD_STATUS_AUX_OBF  0x20

#define KBD_MODE_KBD_INT0x01
#define KBD_MODE_SYS0x02
---

Would it be possible for hw/i8042.c to use the kernel names, to make 
it easier to review and debug this code?

(also, 0x2 should be 0x02 to make it easier to review as well.)

Thanks,

Ingo
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html