qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel]  [PATCH V3 0/3] vhost-user: sync backend
@ 2015-07-31 16:38 Marcel Apfelbaum
  2015-07-31 16:38 ` [Qemu-devel] [PATCH V3 1/3] hw/vhost-user: remove unnecessary virtio control bits Marcel Apfelbaum
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Marcel Apfelbaum @ 2015-07-31 16:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcel, jasowang, famz, n.nikolaev, mst

To be used on top of:
 [PATCH 0/4] vhost-user: protocol updates
 https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg03842.html 

v2 -> v3:
 - Addressed Michael S. Tsirkin's comments:
   - Fixed a typo in patch 2/3  message
   - MQ - I left it there for completeness,
     it will be moved once the "protocol" bits
     will be 'active'
   - unit-test - The bits were added to GET_FEATURES,
     not GET_PROTOCOL_FEATURES, no need to make any changes
 - Added a new patch (1/3) that removes the unnecessary
   virtio bits related to vhost-user backend.

v1 -> v2:
 - Addressed Michael S. Tsirkin's comments:
   - Prefer a white-list of supported features
   - Add a unit-test to show the problem we are trying to solve
     (run the unit-test before the patch and it will fail)

Currently the vhost-user supported features are not evaluated.
 The way I see it, and please correct me, the best way to do
 this is to:
  1. Get the backend features on vhost init.
  2. Check them one by one (white-list) against all 
     the currently supported virtio features.
  3. All other code should remain the same.


Marcel Apfelbaum (3):
  hw/vhost-user: remove unnecessary virtio control bits
  hw/vhost-user: sync backend features
  tests/vhost-user: check vhost-user feature negotiation

 hw/net/vhost_net.c      | 22 ----------------------
 hw/virtio/vhost-user.c  | 17 +++++++++++++++++
 tests/vhost-user-test.c | 19 ++++++++++++++++---
 3 files changed, 33 insertions(+), 25 deletions(-)

-- 
2.1.0

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

* [Qemu-devel] [PATCH V3 1/3] hw/vhost-user: remove unnecessary virtio control bits
  2015-07-31 16:38 [Qemu-devel] [PATCH V3 0/3] vhost-user: sync backend Marcel Apfelbaum
@ 2015-07-31 16:38 ` Marcel Apfelbaum
  2015-08-05 11:37   ` Marcel Apfelbaum
  2015-07-31 16:38 ` [Qemu-devel] [PATCH V3 2/3] hw/vhost-user: sync backend features Marcel Apfelbaum
  2015-07-31 16:38 ` [Qemu-devel] [PATCH V3 3/3] tests/vhost-user: check vhost-user feature negotiation Marcel Apfelbaum
  2 siblings, 1 reply; 5+ messages in thread
From: Marcel Apfelbaum @ 2015-07-31 16:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcel, jasowang, famz, n.nikolaev, mst

The backend is interested in negotiating only several
virtio bits, remove the others.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
---
 hw/net/vhost_net.c | 22 ----------------------
 1 file changed, 22 deletions(-)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index c864237..90f97d2 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -59,31 +59,9 @@ static const int kernel_feature_bits[] = {
 
 /* Features supported by others. */
 static const int user_feature_bits[] = {
-    VIRTIO_F_NOTIFY_ON_EMPTY,
-    VIRTIO_RING_F_INDIRECT_DESC,
-    VIRTIO_RING_F_EVENT_IDX,
-
     VIRTIO_F_ANY_LAYOUT,
     VIRTIO_F_VERSION_1,
-    VIRTIO_NET_F_CSUM,
-    VIRTIO_NET_F_GUEST_CSUM,
-    VIRTIO_NET_F_GSO,
-    VIRTIO_NET_F_GUEST_TSO4,
-    VIRTIO_NET_F_GUEST_TSO6,
-    VIRTIO_NET_F_GUEST_ECN,
-    VIRTIO_NET_F_GUEST_UFO,
-    VIRTIO_NET_F_HOST_TSO4,
-    VIRTIO_NET_F_HOST_TSO6,
-    VIRTIO_NET_F_HOST_ECN,
-    VIRTIO_NET_F_HOST_UFO,
     VIRTIO_NET_F_MRG_RXBUF,
-    VIRTIO_NET_F_STATUS,
-    VIRTIO_NET_F_CTRL_VQ,
-    VIRTIO_NET_F_CTRL_RX,
-    VIRTIO_NET_F_CTRL_VLAN,
-    VIRTIO_NET_F_CTRL_RX_EXTRA,
-    VIRTIO_NET_F_CTRL_MAC_ADDR,
-    VIRTIO_NET_F_CTRL_GUEST_OFFLOADS,
 
     VIRTIO_NET_F_MQ,
 
-- 
2.1.0

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

* [Qemu-devel]  [PATCH V3 2/3] hw/vhost-user: sync backend features
  2015-07-31 16:38 [Qemu-devel] [PATCH V3 0/3] vhost-user: sync backend Marcel Apfelbaum
  2015-07-31 16:38 ` [Qemu-devel] [PATCH V3 1/3] hw/vhost-user: remove unnecessary virtio control bits Marcel Apfelbaum
@ 2015-07-31 16:38 ` Marcel Apfelbaum
  2015-07-31 16:38 ` [Qemu-devel] [PATCH V3 3/3] tests/vhost-user: check vhost-user feature negotiation Marcel Apfelbaum
  2 siblings, 0 replies; 5+ messages in thread
From: Marcel Apfelbaum @ 2015-07-31 16:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcel, jasowang, famz, n.nikolaev, mst

Complete vhost-user negotiation by synching the features
supported by the backend.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
---
 hw/virtio/vhost-user.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index c4428a1..b522437 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -22,6 +22,7 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <linux/vhost.h>
+#include <linux/virtio_net.h>
 
 #define VHOST_MEMORY_MAX_NREGIONS    8
 
@@ -358,6 +359,22 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque)
         return err;
     }
 
+    if (__virtio_has_feature(msg.u64, VIRTIO_F_ANY_LAYOUT)) {
+        dev->backend_features |= 1ULL << VIRTIO_F_ANY_LAYOUT;
+    }
+
+    if (__virtio_has_feature(msg.u64, VIRTIO_F_VERSION_1)) {
+        dev->backend_features |= 1ULL << VIRTIO_F_VERSION_1;
+    }
+
+    if (__virtio_has_feature(msg.u64, VIRTIO_NET_F_MRG_RXBUF)) {
+        dev->backend_features |= 1ULL << VIRTIO_NET_F_MRG_RXBUF;
+    }
+
+    if (__virtio_has_feature(msg.u64, VIRTIO_NET_F_MQ)) {
+        dev->backend_features |= 1ULL << VIRTIO_NET_F_MQ;
+    }
+
     if (__virtio_has_feature(msg.u64, VHOST_USER_F_PROTOCOL_FEATURES)) {
         dev->backend_features |= 1ULL << VHOST_USER_F_PROTOCOL_FEATURES;
 
-- 
2.1.0

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

* [Qemu-devel] [PATCH V3 3/3] tests/vhost-user: check vhost-user feature negotiation
  2015-07-31 16:38 [Qemu-devel] [PATCH V3 0/3] vhost-user: sync backend Marcel Apfelbaum
  2015-07-31 16:38 ` [Qemu-devel] [PATCH V3 1/3] hw/vhost-user: remove unnecessary virtio control bits Marcel Apfelbaum
  2015-07-31 16:38 ` [Qemu-devel] [PATCH V3 2/3] hw/vhost-user: sync backend features Marcel Apfelbaum
@ 2015-07-31 16:38 ` Marcel Apfelbaum
  2 siblings, 0 replies; 5+ messages in thread
From: Marcel Apfelbaum @ 2015-07-31 16:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcel, jasowang, famz, n.nikolaev, mst

Check the backend receives all declared virtio features
that are also supported by QEMU virtio.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
---
 tests/vhost-user-test.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 228acb6..019b880 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -17,6 +17,7 @@
 #include "sysemu/sysemu.h"
 
 #include <linux/vhost.h>
+#include <linux/virtio_net.h>
 #include <sys/mman.h>
 #include <sys/vfs.h>
 #include <qemu/sockets.h>
@@ -297,14 +298,26 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
         /* send back features to qemu */
         msg.flags |= VHOST_USER_REPLY_MASK;
         msg.size = sizeof(m.u64);
-        msg.u64 = 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES;
+        msg.u64 = (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES) |
+                  (0x1ULL << VIRTIO_F_ANY_LAYOUT) |
+                  (0x1ULL << VIRTIO_F_VERSION_1)  |
+                  (0x1ULL << VIRTIO_NET_F_MRG_RXBUF) |
+                  (0x1ULL << VIRTIO_NET_F_MQ);
         p = (uint8_t *) &msg;
         qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size);
         break;
 
     case VHOST_USER_SET_FEATURES:
-	g_assert_cmpint(msg.u64 & (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES),
-			!=, 0ULL);
+        g_assert_cmpint(msg.u64 & (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES),
+            !=, 0ULL);
+        g_assert_cmpint(msg.u64 & (0x1ULL << VIRTIO_F_ANY_LAYOUT),
+            !=, 0ULL);
+        g_assert_cmpint(msg.u64 & (0x1ULL << VIRTIO_F_VERSION_1),
+            !=, 0ULL);
+        g_assert_cmpint(msg.u64 & (0x1ULL << VIRTIO_NET_F_MRG_RXBUF),
+            !=, 0ULL);
+        g_assert_cmpint(msg.u64 & (0x1ULL << VIRTIO_NET_F_MQ),
+            !=, 0ULL);
         break;
 
     case VHOST_USER_GET_PROTOCOL_FEATURES:
-- 
2.1.0

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

* Re: [Qemu-devel] [PATCH V3 1/3] hw/vhost-user: remove unnecessary virtio control bits
  2015-07-31 16:38 ` [Qemu-devel] [PATCH V3 1/3] hw/vhost-user: remove unnecessary virtio control bits Marcel Apfelbaum
@ 2015-08-05 11:37   ` Marcel Apfelbaum
  0 siblings, 0 replies; 5+ messages in thread
From: Marcel Apfelbaum @ 2015-08-05 11:37 UTC (permalink / raw)
  To: Marcel Apfelbaum, qemu-devel; +Cc: jasowang, famz, n.nikolaev, mst

On 07/31/2015 07:38 PM, Marcel Apfelbaum wrote:
> The backend is interested in negotiating only several
> virtio bits, remove the others.
>
> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
> ---
>   hw/net/vhost_net.c | 22 ----------------------
>   1 file changed, 22 deletions(-)
>
> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> index c864237..90f97d2 100644
> --- a/hw/net/vhost_net.c
> +++ b/hw/net/vhost_net.c
> @@ -59,31 +59,9 @@ static const int kernel_feature_bits[] = {
>
>   /* Features supported by others. */
>   static const int user_feature_bits[] = {
> -    VIRTIO_F_NOTIFY_ON_EMPTY,
> -    VIRTIO_RING_F_INDIRECT_DESC,
> -    VIRTIO_RING_F_EVENT_IDX,
> -
>       VIRTIO_F_ANY_LAYOUT,
>       VIRTIO_F_VERSION_1,
> -    VIRTIO_NET_F_CSUM,
> -    VIRTIO_NET_F_GUEST_CSUM,
> -    VIRTIO_NET_F_GSO,
> -    VIRTIO_NET_F_GUEST_TSO4,
> -    VIRTIO_NET_F_GUEST_TSO6,
> -    VIRTIO_NET_F_GUEST_ECN,
> -    VIRTIO_NET_F_GUEST_UFO,
> -    VIRTIO_NET_F_HOST_TSO4,
> -    VIRTIO_NET_F_HOST_TSO6,
> -    VIRTIO_NET_F_HOST_ECN,
> -    VIRTIO_NET_F_HOST_UFO,
>       VIRTIO_NET_F_MRG_RXBUF,
> -    VIRTIO_NET_F_STATUS,
> -    VIRTIO_NET_F_CTRL_VQ,
> -    VIRTIO_NET_F_CTRL_RX,
> -    VIRTIO_NET_F_CTRL_VLAN,
> -    VIRTIO_NET_F_CTRL_RX_EXTRA,
> -    VIRTIO_NET_F_CTRL_MAC_ADDR,
> -    VIRTIO_NET_F_CTRL_GUEST_OFFLOADS,
>
>       VIRTIO_NET_F_MQ,
>
>

Hi,

Please do not take this patch, I think that some bits I deleted are still required by the backend.

The others are OK in my opinion (at least until we change the MQ handshake)
Thanks,
Marcel

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

end of thread, other threads:[~2015-08-05 11:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-31 16:38 [Qemu-devel] [PATCH V3 0/3] vhost-user: sync backend Marcel Apfelbaum
2015-07-31 16:38 ` [Qemu-devel] [PATCH V3 1/3] hw/vhost-user: remove unnecessary virtio control bits Marcel Apfelbaum
2015-08-05 11:37   ` Marcel Apfelbaum
2015-07-31 16:38 ` [Qemu-devel] [PATCH V3 2/3] hw/vhost-user: sync backend features Marcel Apfelbaum
2015-07-31 16:38 ` [Qemu-devel] [PATCH V3 3/3] tests/vhost-user: check vhost-user feature negotiation Marcel Apfelbaum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).