Message ID | 1438200409-27381-3-git-send-email-marcel@redhat.com |
---|---|
State | New |
Headers | show |
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
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
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:
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(-)