[Spice-devel] [PATCH linux/vd_agent 2/2] Handling keyboard description message

Christophe Fergeau cfergeau at redhat.com
Thu Nov 13 09:24:12 PST 2014


On Wed, Nov 05, 2014 at 08:54:00AM +0100, Pavel Grunt wrote:
> The agent tries to set the appropriate keyboard layout
> when the message is received.
> 
> RFE: https://bugs.freedesktop.org/show_bug.cgi?id=85332
> ---
> depends on http://lists.freedesktop.org/archives/spice-devel/2014-November/017821.html
> ---
>  src/vdagent.c                |  4 ++++
>  src/vdagentd-proto-strings.h |  1 +
>  src/vdagentd-proto.h         |  1 +
>  src/vdagentd.c               | 10 ++++++++++
>  4 files changed, 16 insertions(+)
> 
> diff --git a/src/vdagent.c b/src/vdagent.c
> index 9d130d5..b4175a1 100644
> --- a/src/vdagent.c
> +++ b/src/vdagent.c
> @@ -127,6 +127,10 @@ void daemon_read_complete(struct udscs_connection **connp,
>                                                             fx_open_dir, debug);
>          }
>          break;
> +    case VDAGENTD_KEYBOARD_DESCRIPTION:
> +        vdagent_x11_set_keyboard_description(x11, data);

I don't think 'data' is guaranteed to be nul-terminated (think
buggy/misbehaving client), so you need to either pass the size, or
ensure that it ends with a '\0' at some point in the agent code.

Christophe


> +        free(data);
> +        break;
>      default:
>          syslog(LOG_ERR, "Unknown message from vdagentd type: %d, ignoring",
>                 header->type);
> diff --git a/src/vdagentd-proto-strings.h b/src/vdagentd-proto-strings.h
> index e76cb3b..4ee0f9d 100644
> --- a/src/vdagentd-proto-strings.h
> +++ b/src/vdagentd-proto-strings.h
> @@ -34,6 +34,7 @@ static const char * const vdagentd_messages[] = {
>          "file xfer status",
>          "file xfer data",
>          "client disconnected",
> +        "keyboard description",
>  };
>  
>  #endif
> diff --git a/src/vdagentd-proto.h b/src/vdagentd-proto.h
> index 25e6a36..5cb0a26 100644
> --- a/src/vdagentd-proto.h
> +++ b/src/vdagentd-proto.h
> @@ -40,6 +40,7 @@ enum {
>      VDAGENTD_FILE_XFER_STATUS,
>      VDAGENTD_FILE_XFER_DATA,
>      VDAGENTD_CLIENT_DISCONNECTED,  /* daemon -> client */
> +    VDAGENTD_KEYBOARD_DESCRIPTION,
>      VDAGENTD_NO_MESSAGES /* Must always be last */
>  };
>  
> diff --git a/src/vdagentd.c b/src/vdagentd.c
> index b5c7d14..eea7f4d 100644
> --- a/src/vdagentd.c
> +++ b/src/vdagentd.c
> @@ -293,6 +293,13 @@ static void do_client_file_xfer(struct vdagent_virtio_port *vport,
>      udscs_write(conn, msg_type, 0, 0, data, message_header->size);
>  }
>  
> +static void do_client_keyboard_description(VDAgentMessage *message_header,
> +                                           uint8_t *data)
> +{
> +    udscs_write(active_session_conn, VDAGENTD_KEYBOARD_DESCRIPTION, 0, 0,
> +                data, message_header->size);
> +}
> +
>  int virtio_port_read_complete(
>          struct vdagent_virtio_port *vport,
>          int port_nr,
> @@ -379,6 +386,9 @@ int virtio_port_read_complete(
>          syslog(LOG_DEBUG, "Set max clipboard: %d", msg->max);
>          max_clipboard = msg->max;
>          break;
> +    case VD_AGENT_KEYBOARD_DESCRIPTION:
> +        do_client_keyboard_description(message_header, data);
> +        break;
>      default:
>          syslog(LOG_WARNING, "unknown message type %d, ignoring",
>                 message_header->type);
> -- 
> 1.9.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20141113/0224b908/attachment-0001.sig>


More information about the Spice-devel mailing list