Re: [PATCH] Do endian swapping.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey,

On Mon, Nov 28, 2016 at 03:08:34PM +0100, Michal Suchanek wrote:
> This allows running big endian and little endian guest side by side using
> cut&paste between them.
> 
> There is some general design idea that swapping should come as cloce to
> virtio_read/virtio_write as possible. In particular, the protocol between
> vdagent and vdagentd is guest-specific and in native endian. With muliple
> layers of headers this is a bit tricky. A few message types have to be swapped
> fully before passing through vdagentd.
> 
> Signed-off-by: Michal Suchanek <msuchanek@xxxxxxx>
> ---
>  src/vdagentd/uinput.c      |  4 +++
>  src/vdagentd/vdagentd.c    | 68 ++++++++++++++++++++++++++++++++++------------
>  src/vdagentd/virtio-port.c | 35 +++++++++++++++---------
>  3 files changed, 76 insertions(+), 31 deletions(-)
> 
> diff --git a/src/vdagentd/uinput.c b/src/vdagentd/uinput.c
> index e2966c4..21292cb 100644
> --- a/src/vdagentd/uinput.c
> +++ b/src/vdagentd/uinput.c
> @@ -200,6 +200,10 @@ void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
>      };
>      int i, down;
>  
> +    mouse->x = le32toh(mouse->x);
> +    mouse->y = le32toh(mouse->y);
> +    mouse->buttons = le32toh(mouse->buttons);
> +
>      if (*uinputp) {
>          if (mouse->display_id >= uinput->screen_count) {

No swapping of mouse->display_id?

> diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c
> index a1faf23..f91434d 100644
> --- a/src/vdagentd/vdagentd.c
> +++ b/src/vdagentd/vdagentd.c
> @@ -399,15 +422,18 @@ static int virtio_port_read_complete(
>          if (message_header->size != sizeof(VDAgentMaxClipboard))
>              goto size_error;
>          VDAgentMaxClipboard *msg = (VDAgentMaxClipboard *)data;
> -        syslog(LOG_DEBUG, "Set max clipboard: %d", msg->max);
> -        max_clipboard = msg->max;
> +        syslog(LOG_DEBUG, "Set max clipboard: %d", le32toh(msg->max));
> +        max_clipboard = le32toh(msg->max);
>          break;
>      case VD_AGENT_AUDIO_VOLUME_SYNC:
>          if (message_header->size < sizeof(VDAgentAudioVolumeSync))
>              goto size_error;
> +        VDAgentAudioVolumeSync *vdata = (VDAgentAudioVolumeSync *)data;
> +        if (message_header->size < sizeof(VDAgentAudioVolumeSync) +
> +                vdata->nchannels * sizeof(vdata->volume[0]))
> +            goto size_error;

This last change seems unrelated, and would be missing a vdata->nchannels
byteswap if I'm not mistaken.

Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]