* [Qemu-devel] [PATCH V2 0/2] vhost-user: sync backend @ 2015-07-29 20:06 Marcel Apfelbaum 2015-07-29 20:06 ` [Qemu-devel] [PATCH V2 1/2] vhost-user: sync backend features Marcel Apfelbaum 2015-07-29 20:06 ` [Qemu-devel] [PATCH V2 2/2] tests/vhost-user: check vhost-user feature negotiation Marcel Apfelbaum 0 siblings, 2 replies; 7+ messages in thread From: Marcel Apfelbaum @ 2015-07-29 20:06 UTC (permalink / raw) To: qemu-devel; +Cc: marcel, jasowang, famz, 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 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 (2): vhost-user: sync backend features tests/vhost-user: check vhost-user feature negotiation hw/virtio/vhost-user.c | 17 +++++++++++++++++ tests/vhost-user-test.c | 19 ++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) -- 2.1.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH V2 1/2] vhost-user: sync backend features 2015-07-29 20:06 [Qemu-devel] [PATCH V2 0/2] vhost-user: sync backend Marcel Apfelbaum @ 2015-07-29 20:06 ` Marcel Apfelbaum 2015-07-30 6:47 ` Michael S. Tsirkin 2015-07-29 20:06 ` [Qemu-devel] [PATCH V2 2/2] tests/vhost-user: check vhost-user feature negotiation Marcel Apfelbaum 1 sibling, 1 reply; 7+ messages in thread From: Marcel Apfelbaum @ 2015-07-29 20:06 UTC (permalink / raw) To: qemu-devel; +Cc: marcel, jasowang, famz, mst Complete vhost-user negotiation by syncing 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] 7+ messages in thread
* Re: [Qemu-devel] [PATCH V2 1/2] vhost-user: sync backend features 2015-07-29 20:06 ` [Qemu-devel] [PATCH V2 1/2] vhost-user: sync backend features Marcel Apfelbaum @ 2015-07-30 6:47 ` Michael S. Tsirkin 2015-07-30 7:27 ` Marcel Apfelbaum 0 siblings, 1 reply; 7+ messages in thread From: Michael S. Tsirkin @ 2015-07-30 6:47 UTC (permalink / raw) To: Marcel Apfelbaum; +Cc: jasowang, famz, qemu-devel On Wed, Jul 29, 2015 at 11:06:48PM +0300, Marcel Apfelbaum wrote: > Complete vhost-user negotiation by syncing 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; > + } > + A bit too early for MQ, isn't it? > 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 [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH V2 1/2] vhost-user: sync backend features 2015-07-30 6:47 ` Michael S. Tsirkin @ 2015-07-30 7:27 ` Marcel Apfelbaum 0 siblings, 0 replies; 7+ messages in thread From: Marcel Apfelbaum @ 2015-07-30 7:27 UTC (permalink / raw) To: Michael S. Tsirkin; +Cc: jasowang, famz, qemu-devel On 07/30/2015 09:47 AM, Michael S. Tsirkin wrote: > On Wed, Jul 29, 2015 at 11:06:48PM +0300, Marcel Apfelbaum wrote: >> Complete vhost-user negotiation by syncing > > synching. OK, thanks > >> 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; >> + } >> + > > A bit too early for MQ, isn't it? For a complete solution, until we have it in protocol features > >> 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 [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH V2 2/2] tests/vhost-user: check vhost-user feature negotiation 2015-07-29 20:06 [Qemu-devel] [PATCH V2 0/2] vhost-user: sync backend Marcel Apfelbaum 2015-07-29 20:06 ` [Qemu-devel] [PATCH V2 1/2] vhost-user: sync backend features Marcel Apfelbaum @ 2015-07-29 20:06 ` Marcel Apfelbaum 2015-07-30 6:47 ` Michael S. Tsirkin 1 sibling, 1 reply; 7+ messages in thread From: Marcel Apfelbaum @ 2015-07-29 20:06 UTC (permalink / raw) To: qemu-devel; +Cc: marcel, jasowang, famz, 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] 7+ messages in thread
* Re: [Qemu-devel] [PATCH V2 2/2] tests/vhost-user: check vhost-user feature negotiation 2015-07-29 20:06 ` [Qemu-devel] [PATCH V2 2/2] tests/vhost-user: check vhost-user feature negotiation Marcel Apfelbaum @ 2015-07-30 6:47 ` Michael S. Tsirkin 2015-07-30 7:30 ` Marcel Apfelbaum 0 siblings, 1 reply; 7+ messages in thread From: Michael S. Tsirkin @ 2015-07-30 6:47 UTC (permalink / raw) To: Marcel Apfelbaum; +Cc: jasowang, famz, qemu-devel On Wed, Jul 29, 2015 at 11:06:49PM +0300, Marcel Apfelbaum wrote: > 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; > No, this mixes protocol features and virtio features. It's not what was intended. > 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 [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH V2 2/2] tests/vhost-user: check vhost-user feature negotiation 2015-07-30 6:47 ` Michael S. Tsirkin @ 2015-07-30 7:30 ` Marcel Apfelbaum 0 siblings, 0 replies; 7+ messages in thread From: Marcel Apfelbaum @ 2015-07-30 7:30 UTC (permalink / raw) To: Michael S. Tsirkin; +Cc: jasowang, famz, qemu-devel On 07/30/2015 09:47 AM, Michael S. Tsirkin wrote: > On Wed, Jul 29, 2015 at 11:06:49PM +0300, Marcel Apfelbaum wrote: >> 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; >> > > No, this mixes protocol features and virtio features. > It's not what was intended. You asked for a test that shows the problem, here it is. We can change it as you wish, if you have a better idea, just say, "no" doesn't help. Thanks, Marcel > >> 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 [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-07-30 7:30 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-07-29 20:06 [Qemu-devel] [PATCH V2 0/2] vhost-user: sync backend Marcel Apfelbaum 2015-07-29 20:06 ` [Qemu-devel] [PATCH V2 1/2] vhost-user: sync backend features Marcel Apfelbaum 2015-07-30 6:47 ` Michael S. Tsirkin 2015-07-30 7:27 ` Marcel Apfelbaum 2015-07-29 20:06 ` [Qemu-devel] [PATCH V2 2/2] tests/vhost-user: check vhost-user feature negotiation Marcel Apfelbaum 2015-07-30 6:47 ` Michael S. Tsirkin 2015-07-30 7:30 ` 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).