On Wed, 29 Oct 2014 09:42:09 +0100 Cédric Le Goater <c...@fr.ibm.com> wrote:
> When the guest and the host have a different endian order, the data > being accessed in the vring queues needs to be byteswapped. > > This patch adds a VHOST_VRING_F_BYTESWAP flag to inform the vhost > kernel backend to byteswap vring data. > > Signed-off-by: Cédric Le Goater <c...@fr.ibm.com> > --- > hw/virtio/vhost.c | 25 ++++++++++++++++++++++++- > include/hw/virtio/vhost.h | 1 + > linux-headers/linux/vhost.h | 3 +++ > 3 files changed, 28 insertions(+), 1 deletion(-) > +static bool vhost_virtqueue_needs_byteswap(VirtIODevice *vdev) > +{ > +#ifdef TARGET_IS_BIENDIAN > +#ifdef HOST_WORDS_BIGENDIAN > + return !virtio_is_big_endian(vdev); > +#else > + return virtio_is_big_endian(vdev); > +#endif > + > +#else > + return false; > +#endif > +} *thinks aloud* We call this function after features have been negotiated, so we should be able to reuse this interface for virtio-1 by checking for VIRTIO_F_VERSION_1, right?