vhost-net: disable when cross-endian

As of today, vhost assumes guest and host have the same endianness.
This is definitely not compatible with modern PPC64 and ARM that
can change endianness at runtime. Let's disable vhost-net and print
an error message when we detect such a case:

qemu-system-ppc64: vhost-net does not support cross-endian
qemu-system-ppc64: unable to start vhost net: 38: falling back on userspace virtio

This way users can continue to run VMs without changing their setup and
have a chance to know that performance will be impacted.

Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Greg Kurz 2014-06-24 19:55:03 +02:00 committed by Michael S. Tsirkin
parent 7826c2b2a4
commit 371df9f5e0

View File

@ -275,6 +275,19 @@ static void vhost_net_stop_one(struct vhost_net *net,
vhost_dev_disable_notifiers(&net->dev, dev); vhost_dev_disable_notifiers(&net->dev, dev);
} }
static bool vhost_net_device_endian_ok(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 true;
#endif
}
int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
int total_queues) int total_queues)
{ {
@ -283,6 +296,12 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
int r, i = 0; int r, i = 0;
if (!vhost_net_device_endian_ok(dev)) {
error_report("vhost-net does not support cross-endian");
r = -ENOSYS;
goto err;
}
if (!k->set_guest_notifiers) { if (!k->set_guest_notifiers) {
error_report("binding does not support guest notifiers"); error_report("binding does not support guest notifiers");
r = -ENOSYS; r = -ENOSYS;