All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/6] vhost: cross-endian support
@ 2015-06-17 13:23 Greg Kurz
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 1/6] linux-headers: sync vhost.h Greg Kurz
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Greg Kurz @ 2015-06-17 13:23 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Cornelia Huck, Thomas Huth, qemu-devel, Stefan Hajnoczi,
	Jason Wang

Hi,

This series brings initial enablement in vhost to support legacy virtio
devices when host and guest have different endianness (for example, ppc64
versus ppc64le).

Only vhost_net is fully enabled at the moment... I haven't looked at
vhost_scsi yet.

It is basically the same patch set I had sent last month:

https://lists.gnu.org/archive/html/qemu-devel/2015-05/msg00780.html

... without the "virtio: relax feature check" patch since QEMU now
supports 64-bit features.

Some kernel support is needed, already available in Michael's vhost-next
branch at:

https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git

Please review.

---

Cédric Le Goater (1):
      vhost_net: re-enable when cross endian

Greg Kurz (5):
      linux-headers: sync vhost.h
      virtio: introduce virtio_legacy_is_cross_endian()
      vhost: set vring endianness for legacy virtio
      tap: add VNET_LE/VNET_BE operations
      vhost-net: tell tap backend about the vnet endianness


 hw/net/vhost_net.c                |   50 +++++++++++++++++++++++--------------
 hw/virtio/vhost.c                 |   50 ++++++++++++++++++++++++++++++++++++-
 include/hw/virtio/virtio-access.h |   13 ++++++++++
 include/net/net.h                 |    6 ++++
 linux-headers/linux/vhost.h       |   14 ++++++++++
 net/net.c                         |   18 +++++++++++++
 net/tap-linux.c                   |   34 +++++++++++++++++++++++++
 net/tap-linux.h                   |    2 +
 net/tap.c                         |   16 ++++++++++++
 net/tap_int.h                     |    2 +
 10 files changed, 185 insertions(+), 20 deletions(-)

--
Greg

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 1/6] linux-headers: sync vhost.h
  2015-06-17 13:23 [Qemu-devel] [PATCH 0/6] vhost: cross-endian support Greg Kurz
@ 2015-06-17 13:23 ` Greg Kurz
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 2/6] virtio: introduce virtio_legacy_is_cross_endian() Greg Kurz
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Greg Kurz @ 2015-06-17 13:23 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Cornelia Huck, Thomas Huth, qemu-devel, Stefan Hajnoczi,
	Jason Wang

This patch brings the cross-endian vhost API to QEMU.

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 linux-headers/linux/vhost.h |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h
index c656f61cfc75..ead86db91a08 100644
--- a/linux-headers/linux/vhost.h
+++ b/linux-headers/linux/vhost.h
@@ -103,6 +103,20 @@ struct vhost_memory {
 /* Get accessor: reads index, writes value in num */
 #define VHOST_GET_VRING_BASE _IOWR(VHOST_VIRTIO, 0x12, struct vhost_vring_state)
 
+/* Set the vring byte order in num. Valid values are VHOST_VRING_LITTLE_ENDIAN
+ * or VHOST_VRING_BIG_ENDIAN (other values return -EINVAL).
+ * The byte order cannot be changed while the device is active: trying to do so
+ * returns -EBUSY.
+ * This is a legacy only API that is simply ignored when VIRTIO_F_VERSION_1 is
+ * set.
+ * Not all kernel configurations support this ioctl, but all configurations that
+ * support SET also support GET.
+ */
+#define VHOST_VRING_LITTLE_ENDIAN 0
+#define VHOST_VRING_BIG_ENDIAN 1
+#define VHOST_SET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x13, struct vhost_vring_state)
+#define VHOST_GET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x14, struct vhost_vring_state)
+
 /* The following ioctls use eventfd file descriptors to signal and poll
  * for events. */
 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 2/6] virtio: introduce virtio_legacy_is_cross_endian()
  2015-06-17 13:23 [Qemu-devel] [PATCH 0/6] vhost: cross-endian support Greg Kurz
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 1/6] linux-headers: sync vhost.h Greg Kurz
@ 2015-06-17 13:23 ` Greg Kurz
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 3/6] vhost: set vring endianness for legacy virtio Greg Kurz
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Greg Kurz @ 2015-06-17 13:23 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Cornelia Huck, Thomas Huth, qemu-devel, Stefan Hajnoczi,
	Jason Wang

This helper will be used by vhost and tap to detect cross-endianness in
the legacy virtio case.

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 include/hw/virtio/virtio-access.h |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
index ee28c21fefed..cee5dd70c997 100644
--- a/include/hw/virtio/virtio-access.h
+++ b/include/hw/virtio/virtio-access.h
@@ -32,6 +32,19 @@ static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
 #endif
 }
 
+static inline bool virtio_legacy_is_cross_endian(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
+}
+
 static inline uint16_t virtio_lduw_phys(VirtIODevice *vdev, hwaddr pa)
 {
     if (virtio_access_is_big_endian(vdev)) {

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 3/6] vhost: set vring endianness for legacy virtio
  2015-06-17 13:23 [Qemu-devel] [PATCH 0/6] vhost: cross-endian support Greg Kurz
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 1/6] linux-headers: sync vhost.h Greg Kurz
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 2/6] virtio: introduce virtio_legacy_is_cross_endian() Greg Kurz
@ 2015-06-17 13:23 ` Greg Kurz
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 4/6] tap: add VNET_LE/VNET_BE operations Greg Kurz
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Greg Kurz @ 2015-06-17 13:23 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Cornelia Huck, Thomas Huth, qemu-devel, Stefan Hajnoczi,
	Jason Wang

Legacy virtio is native endian: if the guest and host endianness differ,
we have to tell vhost so it can swap bytes where appropriate. This is
done through a vhost ring ioctl.

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 hw/virtio/vhost.c |   50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 2d6c27af8d2a..d9974f49f371 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -17,9 +17,11 @@
 #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 "hw/virtio/virtio-access.h"
 #include "migration/migration.h"
 
 static struct vhost_log *vhost_log;
@@ -689,6 +691,27 @@ static void vhost_log_stop(MemoryListener *listener,
     /* FIXME: implement */
 }
 
+static int vhost_virtqueue_set_vring_endian_legacy(struct vhost_dev *dev,
+                                                   bool is_big_endian,
+                                                   int vhost_vq_index)
+{
+    struct vhost_vring_state s = {
+        .index = vhost_vq_index,
+        .num = is_big_endian
+    };
+
+    if (!dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_ENDIAN, &s)) {
+        return 0;
+    }
+
+    if (errno == ENOTTY) {
+        error_report("vhost does not support cross-endian");
+        return -ENOSYS;
+    }
+
+    return -errno;
+}
+
 static int vhost_virtqueue_start(struct vhost_dev *dev,
                                 struct VirtIODevice *vdev,
                                 struct vhost_virtqueue *vq,
@@ -719,6 +742,16 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
         return -errno;
     }
 
+    if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1) &&
+        virtio_legacy_is_cross_endian(vdev)) {
+        r = vhost_virtqueue_set_vring_endian_legacy(dev,
+                                                    virtio_is_big_endian(vdev),
+                                                    vhost_vq_index);
+        if (r) {
+            return -errno;
+        }
+    }
+
     s = l = virtio_queue_get_desc_size(vdev, idx);
     a = virtio_queue_get_desc_addr(vdev, idx);
     vq->desc = cpu_physical_memory_map(a, &l, 0);
@@ -789,8 +822,9 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev,
                                     struct vhost_virtqueue *vq,
                                     unsigned idx)
 {
+    int vhost_vq_index = idx - dev->vq_index;
     struct vhost_vring_state state = {
-        .index = idx - dev->vq_index
+        .index = vhost_vq_index,
     };
     int r;
     assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs);
@@ -801,6 +835,20 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev,
     }
     virtio_queue_set_last_avail_idx(vdev, idx, state.num);
     virtio_queue_invalidate_signalled_used(vdev, idx);
+
+    /* In the cross-endian case, we need to reset the vring endianness to
+     * native as legacy devices expect so by default.
+     */
+    if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1) &&
+        virtio_legacy_is_cross_endian(vdev)) {
+        r = vhost_virtqueue_set_vring_endian_legacy(dev,
+                                                    !virtio_is_big_endian(vdev),
+                                                    vhost_vq_index);
+        if (r < 0) {
+            error_report("failed to reset vring endianness");
+        }
+    }
+
     assert (r >= 0);
     cpu_physical_memory_unmap(vq->ring, virtio_queue_get_ring_size(vdev, idx),
                               0, virtio_queue_get_ring_size(vdev, idx));

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 4/6] tap: add VNET_LE/VNET_BE operations
  2015-06-17 13:23 [Qemu-devel] [PATCH 0/6] vhost: cross-endian support Greg Kurz
                   ` (2 preceding siblings ...)
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 3/6] vhost: set vring endianness for legacy virtio Greg Kurz
@ 2015-06-17 13:23 ` Greg Kurz
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 5/6] vhost-net: tell tap backend about the vnet endianness Greg Kurz
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Greg Kurz @ 2015-06-17 13:23 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Cornelia Huck, Thomas Huth, qemu-devel, Stefan Hajnoczi,
	Jason Wang

The linux tap and macvtap backends can be told to parse vnet headers
according to little or big endian. This is done through the TUNSETVNETLE
and TUNSETVNETBE ioctls.

This patch brings all the plumbing for QEMU to use these APIs.

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 include/net/net.h |    6 ++++++
 net/net.c         |   18 ++++++++++++++++++
 net/tap-linux.c   |   34 ++++++++++++++++++++++++++++++++++
 net/tap-linux.h   |    2 ++
 net/tap.c         |   16 ++++++++++++++++
 net/tap_int.h     |    2 ++
 6 files changed, 78 insertions(+)

diff --git a/include/net/net.h b/include/net/net.h
index e66ca03bf387..4306252b97a1 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -55,6 +55,8 @@ typedef bool (HasVnetHdrLen)(NetClientState *, int);
 typedef void (UsingVnetHdr)(NetClientState *, bool);
 typedef void (SetOffload)(NetClientState *, int, int, int, int, int);
 typedef void (SetVnetHdrLen)(NetClientState *, int);
+typedef int (SetVnetLE)(NetClientState *, bool);
+typedef int (SetVnetBE)(NetClientState *, bool);
 
 typedef struct NetClientInfo {
     NetClientOptionsKind type;
@@ -73,6 +75,8 @@ typedef struct NetClientInfo {
     UsingVnetHdr *using_vnet_hdr;
     SetOffload *set_offload;
     SetVnetHdrLen *set_vnet_hdr_len;
+    SetVnetLE *set_vnet_le;
+    SetVnetBE *set_vnet_be;
 } NetClientInfo;
 
 struct NetClientState {
@@ -139,6 +143,8 @@ void qemu_using_vnet_hdr(NetClientState *nc, bool enable);
 void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6,
                       int ecn, int ufo);
 void qemu_set_vnet_hdr_len(NetClientState *nc, int len);
+int qemu_set_vnet_le(NetClientState *nc, bool is_le);
+int qemu_set_vnet_be(NetClientState *nc, bool is_be);
 void qemu_macaddr_default_if_unset(MACAddr *macaddr);
 int qemu_show_nic_models(const char *arg, const char *const *models);
 void qemu_check_nic_model(NICInfo *nd, const char *model);
diff --git a/net/net.c b/net/net.c
index 25c2ef338d4f..6dbd61a8f2ef 100644
--- a/net/net.c
+++ b/net/net.c
@@ -510,6 +510,24 @@ void qemu_set_vnet_hdr_len(NetClientState *nc, int len)
     nc->info->set_vnet_hdr_len(nc, len);
 }
 
+int qemu_set_vnet_le(NetClientState *nc, bool is_le)
+{
+    if (!nc || !nc->info->set_vnet_le) {
+        return -ENOSYS;
+    }
+
+    return nc->info->set_vnet_le(nc, is_le);
+}
+
+int qemu_set_vnet_be(NetClientState *nc, bool is_be)
+{
+    if (!nc || !nc->info->set_vnet_be) {
+        return -ENOSYS;
+    }
+
+    return nc->info->set_vnet_be(nc, is_be);
+}
+
 int qemu_can_send_packet(NetClientState *sender)
 {
     int vm_running = runstate_is_running();
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 6c3caef21e3b..394f2a646fc0 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -198,6 +198,40 @@ void tap_fd_set_vnet_hdr_len(int fd, int len)
     }
 }
 
+int tap_fd_set_vnet_le(int fd, int is_le)
+{
+    int arg = is_le ? 1 : 0;
+
+    if (!ioctl(fd, TUNSETVNETLE, &arg)) {
+        return 0;
+    }
+
+    /* Check if our kernel supports TUNSETVNETLE */
+    if (errno == EINVAL) {
+        return -errno;
+    }
+
+    error_report("TUNSETVNETLE ioctl() failed: %s.\n", strerror(errno));
+    abort();
+}
+
+int tap_fd_set_vnet_be(int fd, int is_be)
+{
+    int arg = is_be ? 1 : 0;
+
+    if (!ioctl(fd, TUNSETVNETBE, &arg)) {
+        return 0;
+    }
+
+    /* Check if our kernel supports TUNSETVNETBE */
+    if (errno == EINVAL) {
+        return -errno;
+    }
+
+    error_report("TUNSETVNETBE ioctl() failed: %s.\n", strerror(errno));
+    abort();
+}
+
 void tap_fd_set_offload(int fd, int csum, int tso4,
                         int tso6, int ecn, int ufo)
 {
diff --git a/net/tap-linux.h b/net/tap-linux.h
index 1cf35d41bd84..01dc6f8a2db9 100644
--- a/net/tap-linux.h
+++ b/net/tap-linux.h
@@ -30,6 +30,8 @@
 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
 #define TUNSETQUEUE  _IOW('T', 217, int)
+#define TUNSETVNETLE _IOW('T', 220, int)
+#define TUNSETVNETBE _IOW('T', 222, int)
 
 #endif
 
diff --git a/net/tap.c b/net/tap.c
index aa8b3f5c8cde..5c2607ed8823 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -266,6 +266,20 @@ static void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr)
     s->using_vnet_hdr = using_vnet_hdr;
 }
 
+static int tap_set_vnet_le(NetClientState *nc, bool is_le)
+{
+    TAPState *s = DO_UPCAST(TAPState, nc, nc);
+
+    return tap_fd_set_vnet_le(s->fd, is_le);
+}
+
+static int tap_set_vnet_be(NetClientState *nc, bool is_be)
+{
+    TAPState *s = DO_UPCAST(TAPState, nc, nc);
+
+    return tap_fd_set_vnet_be(s->fd, is_be);
+}
+
 static void tap_set_offload(NetClientState *nc, int csum, int tso4,
                      int tso6, int ecn, int ufo)
 {
@@ -332,6 +346,8 @@ static NetClientInfo net_tap_info = {
     .using_vnet_hdr = tap_using_vnet_hdr,
     .set_offload = tap_set_offload,
     .set_vnet_hdr_len = tap_set_vnet_hdr_len,
+    .set_vnet_le = tap_set_vnet_le,
+    .set_vnet_be = tap_set_vnet_be,
 };
 
 static TAPState *net_tap_fd_init(NetClientState *peer,
diff --git a/net/tap_int.h b/net/tap_int.h
index d12a40996732..2378021c454d 100644
--- a/net/tap_int.h
+++ b/net/tap_int.h
@@ -40,6 +40,8 @@ int tap_probe_vnet_hdr_len(int fd, int len);
 int tap_probe_has_ufo(int fd);
 void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo);
 void tap_fd_set_vnet_hdr_len(int fd, int len);
+int tap_fd_set_vnet_le(int fd, int vnet_is_le);
+int tap_fd_set_vnet_be(int fd, int vnet_is_be);
 int tap_fd_enable(int fd);
 int tap_fd_disable(int fd);
 int tap_fd_get_ifname(int fd, char *ifname);

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 5/6] vhost-net: tell tap backend about the vnet endianness
  2015-06-17 13:23 [Qemu-devel] [PATCH 0/6] vhost: cross-endian support Greg Kurz
                   ` (3 preceding siblings ...)
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 4/6] tap: add VNET_LE/VNET_BE operations Greg Kurz
@ 2015-06-17 13:23 ` Greg Kurz
  2015-06-19  9:16   ` Thomas Huth
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 6/6] vhost_net: re-enable when cross endian Greg Kurz
  2015-06-17 15:10 ` [Qemu-devel] [PATCH 0/6] vhost: cross-endian support Michael S. Tsirkin
  6 siblings, 1 reply; 10+ messages in thread
From: Greg Kurz @ 2015-06-17 13:23 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Cornelia Huck, Thomas Huth, qemu-devel, Stefan Hajnoczi,
	Jason Wang

The default behaviour for TAP/MACVTAP is to consider vnet as native endian.

This patch handles the cases when this is not true:
- virtio 1.0: always little-endian
- legacy cross-endian

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 hw/net/vhost_net.c |   33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 1c55517e3611..8cbb2f618c1c 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -38,6 +38,7 @@
 #include "standard-headers/linux/virtio_ring.h"
 #include "hw/virtio/vhost.h"
 #include "hw/virtio/virtio-bus.h"
+#include "hw/virtio/virtio-access.h"
 
 struct vhost_net {
     struct vhost_dev dev;
@@ -197,6 +198,27 @@ static void vhost_net_set_vq_index(struct vhost_net *net, int vq_index)
     net->dev.vq_index = vq_index;
 }
 
+static int vhost_net_set_vnet_endian(VirtIODevice *dev, NetClientState *peer,
+                                     bool set)
+{
+    int r = 0;
+
+    if (virtio_has_feature(dev, VIRTIO_F_VERSION_1) ||
+        (virtio_legacy_is_cross_endian(dev) && !virtio_is_big_endian(dev))) {
+        r = qemu_set_vnet_le(peer, set);
+        if (r) {
+            error_report("backend does not support LE vnet headers");
+        }
+    } else if (virtio_legacy_is_cross_endian(dev)) {
+        r = qemu_set_vnet_be(peer, set);
+        if (r) {
+            error_report("backend does not support BE vnet headers");
+        }
+    }
+
+    return r;
+}
+
 static int vhost_net_start_one(struct vhost_net *net,
                                VirtIODevice *dev)
 {
@@ -314,6 +336,11 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
         goto err;
     }
 
+    r = vhost_net_set_vnet_endian(dev, ncs[0].peer, true);
+    if (r < 0) {
+        goto err;
+    }
+
     for (i = 0; i < total_queues; i++) {
         vhost_net_set_vq_index(get_vhost_net(ncs[i].peer), i * 2);
     }
@@ -321,7 +348,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
     r = k->set_guest_notifiers(qbus->parent, total_queues * 2, true);
     if (r < 0) {
         error_report("Error binding guest notifier: %d", -r);
-        goto err;
+        goto err_endian;
     }
 
     for (i = 0; i < total_queues; i++) {
@@ -343,6 +370,8 @@ err_start:
         fprintf(stderr, "vhost guest notifier cleanup failed: %d\n", e);
         fflush(stderr);
     }
+err_endian:
+    vhost_net_set_vnet_endian(dev, ncs[0].peer, false);
 err:
     return r;
 }
@@ -365,6 +394,8 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs,
         fflush(stderr);
     }
     assert(r >= 0);
+
+    assert(vhost_net_set_vnet_endian(dev, ncs[0].peer, false) >= 0);
 }
 
 void vhost_net_cleanup(struct vhost_net *net)

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 6/6] vhost_net: re-enable when cross endian
  2015-06-17 13:23 [Qemu-devel] [PATCH 0/6] vhost: cross-endian support Greg Kurz
                   ` (4 preceding siblings ...)
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 5/6] vhost-net: tell tap backend about the vnet endianness Greg Kurz
@ 2015-06-17 13:23 ` Greg Kurz
  2015-06-17 15:10 ` [Qemu-devel] [PATCH 0/6] vhost: cross-endian support Michael S. Tsirkin
  6 siblings, 0 replies; 10+ messages in thread
From: Greg Kurz @ 2015-06-17 13:23 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Cornelia Huck, Thomas Huth, qemu-devel, Stefan Hajnoczi,
	Jason Wang

From: Cédric Le Goater <clg@fr.ibm.com>

Cross-endianness is now checked by the core vhost code.

revert 371df9f5e0f1 "vhost-net: disable when cross-endian"

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
[ added commit message, Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 hw/net/vhost_net.c |   19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 8cbb2f618c1c..f505c91d420a 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -303,19 +303,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)
 {
@@ -324,12 +311,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;

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 0/6] vhost: cross-endian support
  2015-06-17 13:23 [Qemu-devel] [PATCH 0/6] vhost: cross-endian support Greg Kurz
                   ` (5 preceding siblings ...)
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 6/6] vhost_net: re-enable when cross endian Greg Kurz
@ 2015-06-17 15:10 ` Michael S. Tsirkin
  6 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2015-06-17 15:10 UTC (permalink / raw)
  To: Greg Kurz
  Cc: Cornelia Huck, Thomas Huth, qemu-devel, Stefan Hajnoczi,
	Jason Wang

On Wed, Jun 17, 2015 at 03:23:24PM +0200, Greg Kurz wrote:
> Hi,
> 
> This series brings initial enablement in vhost to support legacy virtio
> devices when host and guest have different endianness (for example, ppc64
> versus ppc64le).
> 
> Only vhost_net is fully enabled at the moment... I haven't looked at
> vhost_scsi yet.
> 
> It is basically the same patch set I had sent last month:
> 
> https://lists.gnu.org/archive/html/qemu-devel/2015-05/msg00780.html
> 
> ... without the "virtio: relax feature check" patch since QEMU now
> supports 64-bit features.
> 
> Some kernel support is needed, already available in Michael's vhost-next
> branch at:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git
> 
> Please review.

Seems minor enough, I've applied this.

> ---
> 
> Cédric Le Goater (1):
>       vhost_net: re-enable when cross endian
> 
> Greg Kurz (5):
>       linux-headers: sync vhost.h
>       virtio: introduce virtio_legacy_is_cross_endian()
>       vhost: set vring endianness for legacy virtio
>       tap: add VNET_LE/VNET_BE operations
>       vhost-net: tell tap backend about the vnet endianness
> 
> 
>  hw/net/vhost_net.c                |   50 +++++++++++++++++++++++--------------
>  hw/virtio/vhost.c                 |   50 ++++++++++++++++++++++++++++++++++++-
>  include/hw/virtio/virtio-access.h |   13 ++++++++++
>  include/net/net.h                 |    6 ++++
>  linux-headers/linux/vhost.h       |   14 ++++++++++
>  net/net.c                         |   18 +++++++++++++
>  net/tap-linux.c                   |   34 +++++++++++++++++++++++++
>  net/tap-linux.h                   |    2 +
>  net/tap.c                         |   16 ++++++++++++
>  net/tap_int.h                     |    2 +
>  10 files changed, 185 insertions(+), 20 deletions(-)
> 
> --
> Greg

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 5/6] vhost-net: tell tap backend about the vnet endianness
  2015-06-17 13:23 ` [Qemu-devel] [PATCH 5/6] vhost-net: tell tap backend about the vnet endianness Greg Kurz
@ 2015-06-19  9:16   ` Thomas Huth
  2015-06-19  9:45     ` Greg Kurz
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Huth @ 2015-06-19  9:16 UTC (permalink / raw)
  To: Greg Kurz
  Cc: Cornelia Huck, Jason Wang, qemu-devel, Stefan Hajnoczi,
	Michael S. Tsirkin


 Hi,

On Wed, 17 Jun 2015 15:23:49 +0200
Greg Kurz <gkurz@linux.vnet.ibm.com> wrote:

> The default behaviour for TAP/MACVTAP is to consider vnet as native endian.
> 
> This patch handles the cases when this is not true:
> - virtio 1.0: always little-endian
> - legacy cross-endian
> 
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> ---
>  hw/net/vhost_net.c |   33 ++++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> index 1c55517e3611..8cbb2f618c1c 100644
> --- a/hw/net/vhost_net.c
> +++ b/hw/net/vhost_net.c
...
> @@ -365,6 +394,8 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs,
>          fflush(stderr);
>      }
>      assert(r >= 0);
> +
> +    assert(vhost_net_set_vnet_endian(dev, ncs[0].peer, false) >= 0);
>  }

Putting the vhost_net_set_vnet_endian() within the assert statement
looks somewhat wrong to me. assert() gets defined to nothing in case
NDEBUG is defined, so the call would then simply be dropped.
I guess you rather want something like this here:

    r = vhost_net_set_vnet_endian(dev, ncs[0].peer, false);
    assert(r >= 0);

?

 Thomas

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 5/6] vhost-net: tell tap backend about the vnet endianness
  2015-06-19  9:16   ` Thomas Huth
@ 2015-06-19  9:45     ` Greg Kurz
  0 siblings, 0 replies; 10+ messages in thread
From: Greg Kurz @ 2015-06-19  9:45 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Cornelia Huck, Jason Wang, qemu-devel, Stefan Hajnoczi,
	Michael S. Tsirkin

On Fri, 19 Jun 2015 11:16:35 +0200
Thomas Huth <thuth@redhat.com> wrote:

> 
>  Hi,
> 
> On Wed, 17 Jun 2015 15:23:49 +0200
> Greg Kurz <gkurz@linux.vnet.ibm.com> wrote:
> 
> > The default behaviour for TAP/MACVTAP is to consider vnet as native endian.
> > 
> > This patch handles the cases when this is not true:
> > - virtio 1.0: always little-endian
> > - legacy cross-endian
> > 
> > Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> > ---
> >  hw/net/vhost_net.c |   33 ++++++++++++++++++++++++++++++++-
> >  1 file changed, 32 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> > index 1c55517e3611..8cbb2f618c1c 100644
> > --- a/hw/net/vhost_net.c
> > +++ b/hw/net/vhost_net.c
> ...
> > @@ -365,6 +394,8 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs,
> >          fflush(stderr);
> >      }
> >      assert(r >= 0);
> > +
> > +    assert(vhost_net_set_vnet_endian(dev, ncs[0].peer, false) >= 0);
> >  }
> 
> Putting the vhost_net_set_vnet_endian() within the assert statement
> looks somewhat wrong to me. assert() gets defined to nothing in case
> NDEBUG is defined, so the call would then simply be dropped.
> I guess you rather want something like this here:
> 
>     r = vhost_net_set_vnet_endian(dev, ncs[0].peer, false);
>     assert(r >= 0);
> 
> ?
> 
>  Thomas
> 

Oops you're right... I'll send a fix.

--
Greg

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-06-19  9:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-17 13:23 [Qemu-devel] [PATCH 0/6] vhost: cross-endian support Greg Kurz
2015-06-17 13:23 ` [Qemu-devel] [PATCH 1/6] linux-headers: sync vhost.h Greg Kurz
2015-06-17 13:23 ` [Qemu-devel] [PATCH 2/6] virtio: introduce virtio_legacy_is_cross_endian() Greg Kurz
2015-06-17 13:23 ` [Qemu-devel] [PATCH 3/6] vhost: set vring endianness for legacy virtio Greg Kurz
2015-06-17 13:23 ` [Qemu-devel] [PATCH 4/6] tap: add VNET_LE/VNET_BE operations Greg Kurz
2015-06-17 13:23 ` [Qemu-devel] [PATCH 5/6] vhost-net: tell tap backend about the vnet endianness Greg Kurz
2015-06-19  9:16   ` Thomas Huth
2015-06-19  9:45     ` Greg Kurz
2015-06-17 13:23 ` [Qemu-devel] [PATCH 6/6] vhost_net: re-enable when cross endian Greg Kurz
2015-06-17 15:10 ` [Qemu-devel] [PATCH 0/6] vhost: cross-endian support Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.