qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v2 1/3] vhost: move cross-endian check to vhost core


From: Greg Kurz
Subject: [Qemu-devel] [PATCH v2 1/3] vhost: move cross-endian check to vhost core
Date: Thu, 02 Apr 2015 16:04:02 +0200
User-agent: StGit/0.17-dirty

The cross-endian support isn't really a vhost_net affair: it affects
any vhost device. This patch moves the checking to the vhost core code.

While, we're here, let's give a meaningful name to the helper.

Signed-off-by: Greg Kurz <address@hidden>
---
 hw/net/vhost_net.c |   19 -------------------
 hw/virtio/vhost.c  |   16 ++++++++++++++++
 2 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 9028e52..a1dcaec 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -273,19 +273,6 @@ static void vhost_net_stop_one(struct vhost_net *net,
     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 total_queues)
 {
@@ -294,12 +281,6 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
     int r, e, i;
 
-    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) {
         error_report("binding does not support guest notifiers");
         r = -ENOSYS;
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 9e6e9cc..771abae 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -17,10 +17,12 @@
 #include "hw/hw.h"
 #include "qemu/atomic.h"
 #include "qemu/range.h"
+#include "qemu/error-report.h"
 #include <linux/vhost.h>
 #include "exec/address-spaces.h"
 #include "hw/virtio/virtio-bus.h"
 #include "migration/migration.h"
+#include "hw/virtio/virtio-access.h"
 
 static void vhost_dev_sync_region(struct vhost_dev *dev,
                                   MemoryRegionSection *section,
@@ -1030,11 +1032,25 @@ void vhost_ack_features(struct vhost_dev *hdev, const 
int *feature_bits,
     }
 }
 
+static bool virtio_legacy_is_cross_endian(VirtIODevice *vdev)
+{
+#ifdef HOST_WORDS_BIGENDIAN
+    return !virtio_access_is_big_endian(vdev);
+#else
+    return virtio_access_is_big_endian(vdev);
+#endif
+}
+
 /* Host notifiers must be enabled at this point. */
 int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
 {
     int i, r;
 
+    if (virtio_legacy_is_cross_endian(vdev)) {
+        error_report("vhost does not support cross-endian");
+        return -ENOSYS;
+    }
+
     hdev->started = true;
 
     r = vhost_dev_set_features(hdev, hdev->log_enabled);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]