vdagentd: Do endian swapping.master
commitb08381422d51650ff3bbd8a6a27040a3b4a0b7c2
authorMichal Suchanek <msuchanek@suse.de>
Tue, 8 Nov 2016 15:47:07 +0000 (8 16:47 +0100)
committerMichal Suchanek <msuchanek@suse.de>
Tue, 24 Jan 2017 18:41:35 +0000 (24 19:41 +0100)
tree8b869d1561c5eaf07994f28f4a92702c1a6ccd10
parent8aa7e403d79e3ed375d6f2f6657910419e0aa78a
vdagentd: Do endian swapping.

This allows running big endian and little endian guest side by side using
cut & paste between them.

There is a general design idea that swapping should come as close 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@suse.de>
Signed-off-by: Victor Toso <me@victortoso.com>
---
v2:
 - introduce helper functions to swap (a portion of) a message wholesale
 - pollute fewer places with swapping sometimes at the cost of slightly
   more verbose code
v3:
 - use glib byteswap macros in place of endian.h byteswap macros
 - move variable declaration out of case statement
 - reuse more of existing clipboard code
v4:
 - also use glib byteswap for 64bit swaps
 - use file xfer message structure for swapping size
v5:
 - rebase on top of vdagentd: early return on bad message size
src/vdagentd/vdagentd.c
src/vdagentd/virtio-port.c