[Spice-devel] [PATCH] server: input_channel: fix input on BE machines

Denis Kirjanov kirjanov at gmail.com
Tue Apr 14 00:26:20 PDT 2015


On 4/13/15, Christophe Fergeau <cfergeau at redhat.com> wrote:
> Hey,
>
> I don't really understand why this one is needed.
> I've checked that before inputs_channel_handle_parsed() is called, the
> data goes through parse_msgc_inputs_key_down() in
> generated_server_demarshallers.c and this should byte swap the data if
> needed.
>
> I'd add a
> printf("(%02x %02x %02x %02x)\n", start[0], start[1], start[2],
> start[3]); somewhere in that function in
> generated_server_demarshallers.c
> as well as printf("%08x\n", out->code); right after
> out->code = consume_uint32(&in);
> to try to figure out what's going on (or you can achieve the same in gdb)
>
> As this is a similar issue as your patch about the number of channels,
> can you double check that on your big endian builds, WORDS_BIGENDIAN is
> defined when generated_server_demarshallers.c is built?

Oh,

I'll double check that.

> Christophe
>
> On Mon, Apr 13, 2015 at 04:37:29PM +0300, Denis Kirjanov wrote:
>> The following patch fixes the input between SPICE
>> server on BE machine and LE client
>>
>> Signed-off-by: Denis Kirjanov <kda at itsirius.su>
>> ---
>>  server/inputs_channel.c |   23 +++++++++++++++++++----
>>  1 file changed, 19 insertions(+), 4 deletions(-)
>>
>> diff --git a/server/inputs_channel.c b/server/inputs_channel.c
>> index b0ba1d6..6f19492 100644
>> --- a/server/inputs_channel.c
>> +++ b/server/inputs_channel.c
>> @@ -28,6 +28,7 @@
>>  #include <spice/vd_agent.h>
>>  #include <spice/protocol.h>
>>  #include <stdbool.h>
>> +#include <glib.h>
>>
>>  #include "common/marshaller.h"
>>  #include "common/messages.h"
>> @@ -326,21 +327,24 @@ static int
>> inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
>>      InputsChannel *inputs_channel = (InputsChannel *)rcc->channel;
>>      InputsChannelClient *icc = (InputsChannelClient *)rcc;
>>      uint32_t i;
>> +    uint32_t key_code;
>>
>>      spice_assert(g_inputs_channel == inputs_channel);
>>      switch (type) {
>>      case SPICE_MSGC_INPUTS_KEY_DOWN: {
>>          SpiceMsgcKeyDown *key_down = message;
>> -        if (key_down->code == CAPS_LOCK_SCAN_CODE ||
>> -            key_down->code == NUM_LOCK_SCAN_CODE ||
>> -            key_down->code == SCROLL_LOCK_SCAN_CODE) {
>> +               key_code = GUINT32_FROM_LE(key_down->code);
>> +        if (key_code == CAPS_LOCK_SCAN_CODE ||
>> +            key_code == NUM_LOCK_SCAN_CODE ||
>> +            key_code == SCROLL_LOCK_SCAN_CODE) {
>>              activate_modifiers_watch();
>>          }
>>      }
>>      case SPICE_MSGC_INPUTS_KEY_UP: {
>>          SpiceMsgcKeyUp *key_up = message;
>> +               key_code = GUINT32_FROM_LE(key_up->code);
>>          for (i = 0; i < 4; i++) {
>> -            uint8_t code = (key_up->code >> (i * 8)) & 0xff;
>> +            uint8_t code = (key_code >> (i * 8)) & 0xff;
>>              if (code == 0) {
>>                  break;
>>              }
>> @@ -357,6 +361,9 @@ static int
>> inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
>>      }
>>      case SPICE_MSGC_INPUTS_MOUSE_MOTION: {
>>          SpiceMsgcMouseMotion *mouse_motion = message;
>> +               mouse_motion->dx = GUINT32_FROM_LE(mouse_motion->dx);
>> +               mouse_motion->dy = GUINT32_FROM_LE(mouse_motion->dy);
>> +               mouse_motion->buttons_state =
>> GUINT32_FROM_LE(mouse_motion->buttons_state);
>>
>>          if (++icc->motion_count % SPICE_INPUT_MOTION_ACK_BUNCH == 0 &&
>>              !g_inputs_channel->src_during_migrate) {
>> @@ -374,6 +381,10 @@ static int
>> inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
>>      }
>>      case SPICE_MSGC_INPUTS_MOUSE_POSITION: {
>>          SpiceMsgcMousePosition *pos = message;
>> +               pos->x = GUINT32_FROM_LE(pos->x);
>> +               pos->y = GUINT32_FROM_LE(pos->y);
>> +               pos->buttons_state = GUINT32_FROM_LE(pos->buttons_state);
>> +               pos->display_id = GUINT32_FROM_LE(pos->display_id);
>>
>>          if (++icc->motion_count % SPICE_INPUT_MOTION_ACK_BUNCH == 0 &&
>>              !g_inputs_channel->src_during_migrate) {
>> @@ -400,6 +411,8 @@ static int
>> inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
>>      }
>>      case SPICE_MSGC_INPUTS_MOUSE_PRESS: {
>>          SpiceMsgcMousePress *mouse_press = message;
>> +               mouse_press->buttons_state =
>> GINT16_FROM_LE(mouse_press->buttons_state);
>> +
>>          int dz = 0;
>>          if (mouse_press->button == SPICE_MOUSE_BUTTON_UP) {
>>              dz = -1;
>> @@ -428,6 +441,8 @@ static int
>> inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
>>      }
>>      case SPICE_MSGC_INPUTS_MOUSE_RELEASE: {
>>          SpiceMsgcMouseRelease *mouse_release = message;
>> +               mouse_release->buttons_state =
>> GUINT32_FROM_LE(mouse_release->buttons_state);
>> +
>>          if (reds_get_mouse_mode() == SPICE_MOUSE_MODE_CLIENT) {
>>              if (reds_get_agent_mouse() && reds_has_vdagent()) {
>>                  inputs_channel->mouse_state.buttons =
>> --
>> 1.7.10.4
>>
>> _______________________________________________
>> Spice-devel mailing list
>> Spice-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>


-- 
Regards,
Denis


More information about the Spice-devel mailing list