OSDN Git Service

hw/net/vmxnet3: Fix code to work on big endian hosts, too
authorThomas Huth <thuth@redhat.com>
Tue, 14 Nov 2017 11:20:24 +0000 (12:20 +0100)
committerJason Wang <jasowang@redhat.com>
Mon, 20 Nov 2017 03:08:00 +0000 (11:08 +0800)
commitc527e0afcd7d719abc3a5ca5e4c8ac2fe48b999f
treed682fd216c49d2de2bb1a37c423b9d6e3e0a5237
parent0dacea92d26c31d453c58de2e99c178fee554166
hw/net/vmxnet3: Fix code to work on big endian hosts, too

Since commit ab06ec43577177a442e8 we test the vmxnet3 device in the
pxe-tester, too (when running "make check SPEED=slow"). This now
revealed that the code is not working there if the host is a big
endian machine (for example ppc64 or s390x) - "make check SPEED=slow"
is now failing on such hosts.

The vmxnet3 code lacks endianness conversions in a couple of places.
Interestingly, the bitfields in the structs in vmxnet3.h already tried to
take care of the *bit* endianness of the C compilers - but the code missed
to change the *byte* endianness when reading or writing the corresponding
structs. So the bitfields are now wrapped into unions which allow to change
the byte endianness during runtime with the non-bitfield member of the union.
With these changes, "make check SPEED=slow" now properly works on big endian
hosts, too.

Reported-by: David Gibson <dgibson@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: David Gibson <dgibson@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
hw/net/vmware_utils.h
hw/net/vmxnet3.c
hw/net/vmxnet3.h