virtio test support for virtio 1.0. Probably a good idea to include for 3.19. Michael S. Tsirkin (6): tools/virtio: more stubs tools/virtio: fix vringh test tools/virtio: 64 bit features tools/virtio: enable -Werror tools/virtio: add virtio 1.0 in virtio_test tools/virtio: add virtio 1.0 in vringh_test tools/virtio/linux/virtio.h | 1 + tools/virtio/linux/virtio_byteorder.h | 8 ++++++++ tools/virtio/linux/virtio_config.h | 25 +++++++++++++++++++++++-- tools/virtio/uapi/linux/virtio_types.h | 1 + tools/virtio/virtio_test.c | 14 +++++++++++++- tools/virtio/vringh_test.c | 5 ++++- tools/virtio/Makefile | 2 +- 7 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 tools/virtio/linux/virtio_byteorder.h create mode 100644 tools/virtio/uapi/linux/virtio_types.h -- MST
As usual, add more stubs to fix test build after main codebase changes. Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- tools/virtio/linux/virtio.h | 1 + tools/virtio/linux/virtio_byteorder.h | 8 ++++++++ tools/virtio/linux/virtio_config.h | 25 +++++++++++++++++++++++-- tools/virtio/uapi/linux/virtio_types.h | 1 + 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 tools/virtio/linux/virtio_byteorder.h create mode 100644 tools/virtio/uapi/linux/virtio_types.h diff --git a/tools/virtio/linux/virtio.h b/tools/virtio/linux/virtio.h index 8eb6421..a3e0701 100644 --- a/tools/virtio/linux/virtio.h +++ b/tools/virtio/linux/virtio.h @@ -6,6 +6,7 @@ /* TODO: empty stubs for now. Broken but enough for virtio_ring.c */ #define list_add_tail(a, b) do {} while (0) #define list_del(a) do {} while (0) +#define list_for_each_entry(a, b, c) while (0) /* end of stubs */ struct virtio_device { diff --git a/tools/virtio/linux/virtio_byteorder.h b/tools/virtio/linux/virtio_byteorder.h new file mode 100644 index 0000000..9de9e6a --- /dev/null +++ b/tools/virtio/linux/virtio_byteorder.h @@ -0,0 +1,8 @@ +#ifndef _LINUX_VIRTIO_BYTEORDER_STUB_H +#define _LINUX_VIRTIO_BYTEORDER_STUB_H + +#include <asm/byteorder.h> +#include "../../include/linux/byteorder/generic.h" +#include "../../include/linux/virtio_byteorder.h" + +#endif diff --git a/tools/virtio/linux/virtio_config.h b/tools/virtio/linux/virtio_config.h index dafe1c9..806d683 100644 --- a/tools/virtio/linux/virtio_config.h +++ b/tools/virtio/linux/virtio_config.h @@ -1,8 +1,7 @@ #include <linux/virtio_byteorder.h> #include <linux/virtio.h> +#include <uapi/linux/virtio_config.h> -#define VIRTIO_TRANSPORT_F_START 28 -#define VIRTIO_TRANSPORT_F_END 32 /* * __virtio_test_bit - helper to test feature bits. For use by transports. * Devices should normally use virtio_has_feature, @@ -16,6 +15,28 @@ static inline bool __virtio_test_bit(const struct virtio_device *vdev, return vdev->features & (1ULL << fbit); } +/** + * __virtio_set_bit - helper to set feature bits. For use by transports. + * @vdev: the device + * @fbit: the feature bit + */ +static inline void __virtio_set_bit(struct virtio_device *vdev, + unsigned int fbit) +{ + vdev->features |= (1ULL << fbit); +} + +/** + * __virtio_clear_bit - helper to clear feature bits. For use by transports. + * @vdev: the device + * @fbit: the feature bit + */ +static inline void __virtio_clear_bit(struct virtio_device *vdev, + unsigned int fbit) +{ + vdev->features &= ~(1ULL << fbit); +} + #define virtio_has_feature(dev, feature) \ (__virtio_test_bit((dev), feature)) diff --git a/tools/virtio/uapi/linux/virtio_types.h b/tools/virtio/uapi/linux/virtio_types.h new file mode 100644 index 0000000..e7a1096 --- /dev/null +++ b/tools/virtio/uapi/linux/virtio_types.h @@ -0,0 +1 @@ +#include "../../include/uapi/linux/virtio_types.h" -- MST
Include missing virtio_config.h Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- tools/virtio/vringh_test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/virtio/vringh_test.c b/tools/virtio/vringh_test.c index 9d4b1bc..13e0a76 100644 --- a/tools/virtio/vringh_test.c +++ b/tools/virtio/vringh_test.c @@ -7,6 +7,7 @@ #include <linux/virtio.h> #include <linux/vringh.h> #include <linux/virtio_ring.h> +#include <linux/virtio_config.h> #include <linux/uaccess.h> #include <sys/types.h> #include <sys/stat.h> -- MST
Missed one place where vringh_test used long to pass features. Fix it up to u64. Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- tools/virtio/vringh_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virtio/vringh_test.c b/tools/virtio/vringh_test.c index 13e0a76..51d922f 100644 --- a/tools/virtio/vringh_test.c +++ b/tools/virtio/vringh_test.c @@ -132,7 +132,7 @@ static inline int vringh_get_head(struct vringh *vrh, u16 *head) return 1; } -static int parallel_test(unsigned long features, +static int parallel_test(u64 features, bool (*getrange)(struct vringh *vrh, u64 addr, struct vringh_range *r), bool fast_vringh) -- MST
Seems to mostly be a positive. Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- tools/virtio/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virtio/Makefile b/tools/virtio/Makefile index 9325f46..505ad51 100644 --- a/tools/virtio/Makefile +++ b/tools/virtio/Makefile @@ -3,7 +3,7 @@ test: virtio_test vringh_test virtio_test: virtio_ring.o virtio_test.o vringh_test: vringh_test.o vringh.o virtio_ring.o -CFLAGS += -g -O2 -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE +CFLAGS += -g -O2 -Werror -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE vpath %.c ../../drivers/virtio ../../drivers/vhost mod: ${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test -- MST
Michael S. Tsirkin
2014-Dec-14 22:04 UTC
[PATCH 5/6] tools/virtio: add virtio 1.0 in virtio_test
Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- tools/virtio/virtio_test.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c index 67873c3..e044589 100644 --- a/tools/virtio/virtio_test.c +++ b/tools/virtio/virtio_test.c @@ -228,6 +228,14 @@ const struct option longopts[] = { .val = 'i', }, { + .name = "virtio-1", + .val = '1', + }, + { + .name = "no-virtio-1", + .val = '0', + }, + { .name = "delayed-interrupt", .val = 'D', }, @@ -244,6 +252,7 @@ static void help(void) fprintf(stderr, "Usage: virtio_test [--help]" " [--no-indirect]" " [--no-event-idx]" + " [--no-virtio-1]" " [--delayed-interrupt]" "\n"); } @@ -252,7 +261,7 @@ int main(int argc, char **argv) { struct vdev_info dev; unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | - (1ULL << VIRTIO_RING_F_EVENT_IDX); + (1ULL << VIRTIO_RING_F_EVENT_IDX) | (1ULL << VIRTIO_F_VERSION_1); int o; bool delayed = false; @@ -273,6 +282,9 @@ int main(int argc, char **argv) case 'i': features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC); break; + case '0': + features &= ~(1ULL << VIRTIO_F_VERSION_1); + break; case 'D': delayed = true; break; -- MST
Michael S. Tsirkin
2014-Dec-14 22:04 UTC
[PATCH 6/6] tools/virtio: add virtio 1.0 in vringh_test
Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- tools/virtio/vringh_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/virtio/vringh_test.c b/tools/virtio/vringh_test.c index 51d922f..5f94f51 100644 --- a/tools/virtio/vringh_test.c +++ b/tools/virtio/vringh_test.c @@ -457,6 +457,8 @@ int main(int argc, char *argv[]) __virtio_set_bit(&vdev, VIRTIO_RING_F_INDIRECT_DESC); else if (strcmp(argv[1], "--eventidx") == 0) __virtio_set_bit(&vdev, VIRTIO_RING_F_EVENT_IDX); + else if (strcmp(argv[1], "--virtio-1") == 0) + __virtio_set_bit(&vdev, VIRTIO_F_VERSION_1); else if (strcmp(argv[1], "--slow-range") == 0) getrange = getrange_slow; else if (strcmp(argv[1], "--fast-vringh") == 0) -- MST
"Michael S. Tsirkin" <mst at redhat.com> writes:> As usual, add more stubs to fix test build after main > codebase changes.This doesn't apply, since:> diff --git a/tools/virtio/linux/virtio_config.h b/tools/virtio/linux/virtio_config.h > index dafe1c9..806d683 100644 > --- a/tools/virtio/linux/virtio_config.h > +++ b/tools/virtio/linux/virtio_config.h > @@ -1,8 +1,7 @@ > #include <linux/virtio_byteorder.h> > #include <linux/virtio.h> > +#include <uapi/linux/virtio_config.h> > > -#define VIRTIO_TRANSPORT_F_START 28 > -#define VIRTIO_TRANSPORT_F_END 32 > /*Version in master has no headers in this file. What's this based on? Thanks, Rusty.