All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/5] vhost-user-test: Fixes & code clean-up
@ 2017-12-21 17:07 Maxime Coquelin
  2017-12-21 17:07 ` [Qemu-devel] [PATCH 1/5] vhost-user-test: extract read-guest-mem test from main loop Maxime Coquelin
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Maxime Coquelin @ 2017-12-21 17:07 UTC (permalink / raw)
  To: qemu-devel, stefanha, mst; +Cc: mlureau, Maxime Coquelin

This series fixes two issues in vhost-user-test:
1. Setup virtqueues in all tests
2. Fix features mask for all but test_multiqueue()

The clean-ups comprises making read-guest-mem test consistent
with other tests by initializing the device in the qtest thread.
Also, some code factorization is done with regard to device
initialization so that all tests share the same init.

Maxime Coquelin (5):
  vhost-user-test: extract read-guest-mem test from main loop
  vhost-user-test: setup virtqueues in all tests
  vhost-user-test: make features mask an init_virtio_dev() argument
  vhost-user-test: fix features mask
  vhost-user-test: use init_virtio_dev in multiqueue test

 tests/vhost-user-test.c | 171 ++++++++++++++++++++++--------------------------
 1 file changed, 79 insertions(+), 92 deletions(-)

-- 
2.14.3

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

* [Qemu-devel] [PATCH 1/5] vhost-user-test: extract read-guest-mem test from main loop
  2017-12-21 17:07 [Qemu-devel] [PATCH 0/5] vhost-user-test: Fixes & code clean-up Maxime Coquelin
@ 2017-12-21 17:07 ` Maxime Coquelin
  2017-12-21 17:16   ` Marc-André Lureau
  2017-12-21 17:07 ` [Qemu-devel] [PATCH 2/5] vhost-user-test: setup virtqueues in all tests Maxime Coquelin
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Maxime Coquelin @ 2017-12-21 17:07 UTC (permalink / raw)
  To: qemu-devel, stefanha, mst; +Cc: mlureau, Maxime Coquelin

This patch makes read-guest-test consistent with other tests,
i.e. create the test server in the test thread.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 tests/vhost-user-test.c | 41 +++++++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index e2c89ed376..11796e6562 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -617,6 +617,28 @@ GSourceFuncs test_migrate_source_funcs = {
     .check = test_migrate_source_check,
 };
 
+static void test_read_guest_mem(void)
+{
+    TestServer *server = NULL;
+    char *qemu_cmd = NULL;
+    QTestState *s = NULL;
+
+    server = test_server_new("test");
+    test_server_listen(server);
+
+    qemu_cmd = GET_QEMU_CMD(server);
+
+    s = qtest_start(qemu_cmd);
+    g_free(qemu_cmd);
+
+    init_virtio_dev(server);
+
+    read_guest_mem(server);
+
+    qtest_quit(s);
+    test_server_free(server);
+}
+
 static void test_migrate(void)
 {
     TestServer *s = test_server_new("src");
@@ -919,10 +941,7 @@ static void test_multiqueue(void)
 
 int main(int argc, char **argv)
 {
-    QTestState *s = NULL;
-    TestServer *server = NULL;
     const char *hugefs;
-    char *qemu_cmd = NULL;
     int ret;
     char template[] = "/tmp/vhost-test-XXXXXX";
     GMainLoop *loop;
@@ -947,20 +966,11 @@ int main(int argc, char **argv)
         root = tmpfs;
     }
 
-    server = test_server_new("test");
-    test_server_listen(server);
-
     loop = g_main_loop_new(NULL, FALSE);
     /* run the main loop thread so the chardev may operate */
     thread = g_thread_new(NULL, thread_function, loop);
 
-    qemu_cmd = GET_QEMU_CMD(server);
-
-    s = qtest_start(qemu_cmd);
-    g_free(qemu_cmd);
-    init_virtio_dev(server);
-
-    qtest_add_data_func("/vhost-user/read-guest-mem", server, read_guest_mem);
+    qtest_add_func("/vhost-user/read-guest-mem", test_read_guest_mem);
     qtest_add_func("/vhost-user/migrate", test_migrate);
     qtest_add_func("/vhost-user/multiqueue", test_multiqueue);
 
@@ -978,12 +988,7 @@ int main(int argc, char **argv)
 
     ret = g_test_run();
 
-    if (s) {
-        qtest_quit(s);
-    }
-
     /* cleanup */
-    test_server_free(server);
 
     /* finish the helper thread and dispatch pending sources */
     g_main_loop_quit(loop);
-- 
2.14.3

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

* [Qemu-devel] [PATCH 2/5] vhost-user-test: setup virtqueues in all tests
  2017-12-21 17:07 [Qemu-devel] [PATCH 0/5] vhost-user-test: Fixes & code clean-up Maxime Coquelin
  2017-12-21 17:07 ` [Qemu-devel] [PATCH 1/5] vhost-user-test: extract read-guest-mem test from main loop Maxime Coquelin
@ 2017-12-21 17:07 ` Maxime Coquelin
  2017-12-21 17:07 ` [Qemu-devel] [PATCH 3/5] vhost-user-test: make features mask an init_virtio_dev() argument Maxime Coquelin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Maxime Coquelin @ 2017-12-21 17:07 UTC (permalink / raw)
  To: qemu-devel, stefanha, mst; +Cc: mlureau, Maxime Coquelin

Only the multiqueue test setups the virtqueues.
This patch generalizes the setup of virtqueues for all tests.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 tests/vhost-user-test.c | 53 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 42 insertions(+), 11 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 11796e6562..be463fe7f2 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -55,6 +55,7 @@
 /*********** FROM hw/virtio/vhost-user.c *************************************/
 
 #define VHOST_MEMORY_MAX_NREGIONS    8
+#define VHOST_MAX_VIRTQUEUES    0x100
 
 #define VHOST_USER_F_PROTOCOL_FEATURES 30
 #define VHOST_USER_PROTOCOL_F_MQ 0
@@ -141,6 +142,8 @@ enum {
 
 typedef struct TestServer {
     QPCIBus *bus;
+    QVirtioPCIDevice *dev;
+    QVirtQueue *vq[VHOST_MAX_VIRTQUEUES];
     gchar *socket_path;
     gchar *mig_path;
     gchar *chr_name;
@@ -155,6 +158,7 @@ typedef struct TestServer {
     bool test_fail;
     int test_flags;
     int queues;
+    QGuestAllocator *alloc;
 } TestServer;
 
 static const char *tmpfs;
@@ -162,26 +166,43 @@ static const char *root;
 
 static void init_virtio_dev(TestServer *s)
 {
-    QVirtioPCIDevice *dev;
     uint32_t features;
+    int i;
 
     s->bus = qpci_init_pc(NULL);
     g_assert_nonnull(s->bus);
 
-    dev = qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET);
-    g_assert_nonnull(dev);
+    s->dev = qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET);
+    g_assert_nonnull(s->dev);
 
-    qvirtio_pci_device_enable(dev);
-    qvirtio_reset(&dev->vdev);
-    qvirtio_set_acknowledge(&dev->vdev);
-    qvirtio_set_driver(&dev->vdev);
+    qvirtio_pci_device_enable(s->dev);
+    qvirtio_reset(&s->dev->vdev);
+    qvirtio_set_acknowledge(&s->dev->vdev);
+    qvirtio_set_driver(&s->dev->vdev);
+
+    s->alloc = pc_alloc_init();
 
-    features = qvirtio_get_features(&dev->vdev);
+    for (i = 0; i < s->queues * 2; i++) {
+        s->vq[i] = qvirtqueue_setup(&s->dev->vdev, s->alloc, i);
+    }
+
+    features = qvirtio_get_features(&s->dev->vdev);
     features = features & VIRTIO_NET_F_MAC;
-    qvirtio_set_features(&dev->vdev, features);
+    qvirtio_set_features(&s->dev->vdev, features);
 
-    qvirtio_set_driver_ok(&dev->vdev);
-    qvirtio_pci_device_free(dev);
+    qvirtio_set_driver_ok(&s->dev->vdev);
+}
+
+static void uninit_virtio_dev(TestServer *s)
+{
+    int i;
+
+    for (i = 0; i < s->queues * 2; i++) {
+        qvirtqueue_cleanup(s->dev->vdev.bus, s->vq[i], s->alloc);
+    }
+    pc_alloc_uninit(s->alloc);
+
+    qvirtio_pci_device_free(s->dev);
 }
 
 static void wait_for_fds(TestServer *s)
@@ -635,6 +656,8 @@ static void test_read_guest_mem(void)
 
     read_guest_mem(server);
 
+    uninit_virtio_dev(server);
+
     qtest_quit(s);
     test_server_free(server);
 }
@@ -711,6 +734,8 @@ static void test_migrate(void)
 
     read_guest_mem(dest);
 
+    uninit_virtio_dev(s);
+
     g_source_destroy(source);
     g_source_unref(source);
 
@@ -789,6 +814,8 @@ static void test_reconnect_subprocess(void)
     wait_for_fds(s);
     wait_for_rings_started(s, 2);
 
+    uninit_virtio_dev(s);
+
     qtest_end();
     test_server_free(s);
     return;
@@ -818,6 +845,8 @@ static void test_connect_fail_subprocess(void)
     wait_for_fds(s);
     wait_for_rings_started(s, 2);
 
+    uninit_virtio_dev(s);
+
     qtest_end();
     test_server_free(s);
 }
@@ -846,6 +875,8 @@ static void test_flags_mismatch_subprocess(void)
     wait_for_fds(s);
     wait_for_rings_started(s, 2);
 
+    uninit_virtio_dev(s);
+
     qtest_end();
     test_server_free(s);
 }
-- 
2.14.3

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

* [Qemu-devel] [PATCH 3/5] vhost-user-test: make features mask an init_virtio_dev() argument
  2017-12-21 17:07 [Qemu-devel] [PATCH 0/5] vhost-user-test: Fixes & code clean-up Maxime Coquelin
  2017-12-21 17:07 ` [Qemu-devel] [PATCH 1/5] vhost-user-test: extract read-guest-mem test from main loop Maxime Coquelin
  2017-12-21 17:07 ` [Qemu-devel] [PATCH 2/5] vhost-user-test: setup virtqueues in all tests Maxime Coquelin
@ 2017-12-21 17:07 ` Maxime Coquelin
  2017-12-21 17:07 ` [Qemu-devel] [PATCH 4/5] vhost-user-test: fix features mask Maxime Coquelin
  2017-12-21 17:07 ` [Qemu-devel] [PATCH 5/5] vhost-user-test: use init_virtio_dev in multiqueue test Maxime Coquelin
  4 siblings, 0 replies; 9+ messages in thread
From: Maxime Coquelin @ 2017-12-21 17:07 UTC (permalink / raw)
  To: qemu-devel, stefanha, mst; +Cc: mlureau, Maxime Coquelin

The goal is to generalize the use of [un]init_virtio_dev() to
all tests, which does not necessarily expose the same features
set.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 tests/vhost-user-test.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index be463fe7f2..be7a401789 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -164,7 +164,7 @@ typedef struct TestServer {
 static const char *tmpfs;
 static const char *root;
 
-static void init_virtio_dev(TestServer *s)
+static void init_virtio_dev(TestServer *s, uint32_t features_mask)
 {
     uint32_t features;
     int i;
@@ -187,7 +187,7 @@ static void init_virtio_dev(TestServer *s)
     }
 
     features = qvirtio_get_features(&s->dev->vdev);
-    features = features & VIRTIO_NET_F_MAC;
+    features = features & features_mask;
     qvirtio_set_features(&s->dev->vdev, features);
 
     qvirtio_set_driver_ok(&s->dev->vdev);
@@ -652,7 +652,7 @@ static void test_read_guest_mem(void)
     s = qtest_start(qemu_cmd);
     g_free(qemu_cmd);
 
-    init_virtio_dev(server);
+    init_virtio_dev(server, VIRTIO_NET_F_MAC);
 
     read_guest_mem(server);
 
@@ -681,7 +681,7 @@ static void test_migrate(void)
     from = qtest_start(cmd);
     g_free(cmd);
 
-    init_virtio_dev(s);
+    init_virtio_dev(s, VIRTIO_NET_F_MAC);
     wait_for_fds(s);
     size = get_log_size(s);
     g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));
@@ -803,7 +803,7 @@ static void test_reconnect_subprocess(void)
     qtest_start(cmd);
     g_free(cmd);
 
-    init_virtio_dev(s);
+    init_virtio_dev(s, VIRTIO_NET_F_MAC);
     wait_for_fds(s);
     wait_for_rings_started(s, 2);
 
@@ -841,7 +841,7 @@ static void test_connect_fail_subprocess(void)
     qtest_start(cmd);
     g_free(cmd);
 
-    init_virtio_dev(s);
+    init_virtio_dev(s, VIRTIO_NET_F_MAC);
     wait_for_fds(s);
     wait_for_rings_started(s, 2);
 
@@ -871,7 +871,7 @@ static void test_flags_mismatch_subprocess(void)
     qtest_start(cmd);
     g_free(cmd);
 
-    init_virtio_dev(s);
+    init_virtio_dev(s, VIRTIO_NET_F_MAC);
     wait_for_fds(s);
     wait_for_rings_started(s, 2);
 
-- 
2.14.3

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

* [Qemu-devel] [PATCH 4/5] vhost-user-test: fix features mask
  2017-12-21 17:07 [Qemu-devel] [PATCH 0/5] vhost-user-test: Fixes & code clean-up Maxime Coquelin
                   ` (2 preceding siblings ...)
  2017-12-21 17:07 ` [Qemu-devel] [PATCH 3/5] vhost-user-test: make features mask an init_virtio_dev() argument Maxime Coquelin
@ 2017-12-21 17:07 ` Maxime Coquelin
  2017-12-21 17:18   ` Marc-André Lureau
  2017-12-21 17:07 ` [Qemu-devel] [PATCH 5/5] vhost-user-test: use init_virtio_dev in multiqueue test Maxime Coquelin
  4 siblings, 1 reply; 9+ messages in thread
From: Maxime Coquelin @ 2017-12-21 17:07 UTC (permalink / raw)
  To: qemu-devel, stefanha, mst; +Cc: mlureau, Maxime Coquelin

VIRTIO_NET_F_MAC is a bit position, not a bit mask.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 tests/vhost-user-test.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index be7a401789..6a144e8d7e 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -652,7 +652,7 @@ static void test_read_guest_mem(void)
     s = qtest_start(qemu_cmd);
     g_free(qemu_cmd);
 
-    init_virtio_dev(server, VIRTIO_NET_F_MAC);
+    init_virtio_dev(server, 1u << VIRTIO_NET_F_MAC);
 
     read_guest_mem(server);
 
@@ -681,7 +681,7 @@ static void test_migrate(void)
     from = qtest_start(cmd);
     g_free(cmd);
 
-    init_virtio_dev(s, VIRTIO_NET_F_MAC);
+    init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
     wait_for_fds(s);
     size = get_log_size(s);
     g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));
@@ -803,7 +803,7 @@ static void test_reconnect_subprocess(void)
     qtest_start(cmd);
     g_free(cmd);
 
-    init_virtio_dev(s, VIRTIO_NET_F_MAC);
+    init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
     wait_for_fds(s);
     wait_for_rings_started(s, 2);
 
@@ -841,7 +841,7 @@ static void test_connect_fail_subprocess(void)
     qtest_start(cmd);
     g_free(cmd);
 
-    init_virtio_dev(s, VIRTIO_NET_F_MAC);
+    init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
     wait_for_fds(s);
     wait_for_rings_started(s, 2);
 
@@ -871,7 +871,7 @@ static void test_flags_mismatch_subprocess(void)
     qtest_start(cmd);
     g_free(cmd);
 
-    init_virtio_dev(s, VIRTIO_NET_F_MAC);
+    init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
     wait_for_fds(s);
     wait_for_rings_started(s, 2);
 
-- 
2.14.3

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

* [Qemu-devel] [PATCH 5/5] vhost-user-test: use init_virtio_dev in multiqueue test
  2017-12-21 17:07 [Qemu-devel] [PATCH 0/5] vhost-user-test: Fixes & code clean-up Maxime Coquelin
                   ` (3 preceding siblings ...)
  2017-12-21 17:07 ` [Qemu-devel] [PATCH 4/5] vhost-user-test: fix features mask Maxime Coquelin
@ 2017-12-21 17:07 ` Maxime Coquelin
  4 siblings, 0 replies; 9+ messages in thread
From: Maxime Coquelin @ 2017-12-21 17:07 UTC (permalink / raw)
  To: qemu-devel, stefanha, mst; +Cc: mlureau, Maxime Coquelin

Now that init_virtio_dev() has been generalized to all cases,
use it in test_multiqueue() to avoid code duplication.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 tests/vhost-user-test.c | 65 ++++++-------------------------------------------
 1 file changed, 8 insertions(+), 57 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 6a144e8d7e..ec6ac9dc9e 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -892,79 +892,30 @@ static void test_flags_mismatch(void)
 
 #endif
 
-static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus, int slot)
-{
-    QVirtioPCIDevice *dev;
-
-    dev = qvirtio_pci_device_find(bus, VIRTIO_ID_NET);
-    g_assert(dev != NULL);
-    g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_NET);
-
-    qvirtio_pci_device_enable(dev);
-    qvirtio_reset(&dev->vdev);
-    qvirtio_set_acknowledge(&dev->vdev);
-    qvirtio_set_driver(&dev->vdev);
-
-    return dev;
-}
-
-static void driver_init(QVirtioDevice *dev)
-{
-    uint32_t features;
-
-    features = qvirtio_get_features(dev);
-    features = features & ~(QVIRTIO_F_BAD_FEATURE |
-                            (1u << VIRTIO_RING_F_INDIRECT_DESC) |
-                            (1u << VIRTIO_RING_F_EVENT_IDX));
-    qvirtio_set_features(dev, features);
-
-    qvirtio_set_driver_ok(dev);
-}
-
-#define PCI_SLOT                0x04
-
 static void test_multiqueue(void)
 {
-    const int queues = 2;
     TestServer *s = test_server_new("mq");
-    QVirtioPCIDevice *dev;
-    QPCIBus *bus;
-    QVirtQueuePCI *vq[queues * 2];
-    QGuestAllocator *alloc;
     char *cmd;
-    int i;
-
-    s->queues = queues;
+    uint32_t features_mask = ~(QVIRTIO_F_BAD_FEATURE |
+                            (1u << VIRTIO_RING_F_INDIRECT_DESC) |
+                            (1u << VIRTIO_RING_F_EVENT_IDX));
+    s->queues = 2;
     test_server_listen(s);
 
     cmd = g_strdup_printf(QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=%d "
                           "-device virtio-net-pci,netdev=net0,mq=on,vectors=%d",
                           512, 512, root, s->chr_name,
                           s->socket_path, "", s->chr_name,
-                          queues, queues * 2 + 2);
+                          s->queues, s->queues * 2 + 2);
     qtest_start(cmd);
     g_free(cmd);
 
-    bus = qpci_init_pc(NULL);
-    dev = virtio_net_pci_init(bus, PCI_SLOT);
+    init_virtio_dev(s, features_mask);
 
-    alloc = pc_alloc_init();
-    for (i = 0; i < queues * 2; i++) {
-        vq[i] = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, alloc, i);
-    }
+    wait_for_rings_started(s, s->queues * 2);
 
-    driver_init(&dev->vdev);
-    wait_for_rings_started(s, queues * 2);
+    uninit_virtio_dev(s);
 
-    /* End test */
-    for (i = 0; i < queues * 2; i++) {
-        qvirtqueue_cleanup(dev->vdev.bus, &vq[i]->vq, alloc);
-    }
-    pc_alloc_uninit(alloc);
-    qvirtio_pci_device_disable(dev);
-    g_free(dev->pdev);
-    g_free(dev);
-    qpci_free_pc(bus);
     qtest_end();
 
     test_server_free(s);
-- 
2.14.3

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

* Re: [Qemu-devel] [PATCH 1/5] vhost-user-test: extract read-guest-mem test from main loop
  2017-12-21 17:07 ` [Qemu-devel] [PATCH 1/5] vhost-user-test: extract read-guest-mem test from main loop Maxime Coquelin
@ 2017-12-21 17:16   ` Marc-André Lureau
  0 siblings, 0 replies; 9+ messages in thread
From: Marc-André Lureau @ 2017-12-21 17:16 UTC (permalink / raw)
  To: Maxime Coquelin; +Cc: qemu-devel, stefanha, mst

Hi

----- Original Message -----
> This patch makes read-guest-test consistent with other tests,
> i.e. create the test server in the test thread.

test thread? test function perhaps.

> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>

I think the original idea was to reuse the same server for multiple test function, but that never happened.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  tests/vhost-user-test.c | 41 +++++++++++++++++++++++------------------
>  1 file changed, 23 insertions(+), 18 deletions(-)
> 
> diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> index e2c89ed376..11796e6562 100644
> --- a/tests/vhost-user-test.c
> +++ b/tests/vhost-user-test.c
> @@ -617,6 +617,28 @@ GSourceFuncs test_migrate_source_funcs = {
>      .check = test_migrate_source_check,
>  };
>  
> +static void test_read_guest_mem(void)
> +{
> +    TestServer *server = NULL;
> +    char *qemu_cmd = NULL;
> +    QTestState *s = NULL;
> +
> +    server = test_server_new("test");
> +    test_server_listen(server);
> +
> +    qemu_cmd = GET_QEMU_CMD(server);
> +
> +    s = qtest_start(qemu_cmd);
> +    g_free(qemu_cmd);
> +
> +    init_virtio_dev(server);
> +
> +    read_guest_mem(server);
> +
> +    qtest_quit(s);
> +    test_server_free(server);
> +}
> +
>  static void test_migrate(void)
>  {
>      TestServer *s = test_server_new("src");
> @@ -919,10 +941,7 @@ static void test_multiqueue(void)
>  
>  int main(int argc, char **argv)
>  {
> -    QTestState *s = NULL;
> -    TestServer *server = NULL;
>      const char *hugefs;
> -    char *qemu_cmd = NULL;
>      int ret;
>      char template[] = "/tmp/vhost-test-XXXXXX";
>      GMainLoop *loop;
> @@ -947,20 +966,11 @@ int main(int argc, char **argv)
>          root = tmpfs;
>      }
>  
> -    server = test_server_new("test");
> -    test_server_listen(server);
> -
>      loop = g_main_loop_new(NULL, FALSE);
>      /* run the main loop thread so the chardev may operate */
>      thread = g_thread_new(NULL, thread_function, loop);
>  
> -    qemu_cmd = GET_QEMU_CMD(server);
> -
> -    s = qtest_start(qemu_cmd);
> -    g_free(qemu_cmd);
> -    init_virtio_dev(server);
> -
> -    qtest_add_data_func("/vhost-user/read-guest-mem", server,
> read_guest_mem);
> +    qtest_add_func("/vhost-user/read-guest-mem", test_read_guest_mem);
>      qtest_add_func("/vhost-user/migrate", test_migrate);
>      qtest_add_func("/vhost-user/multiqueue", test_multiqueue);
>  
> @@ -978,12 +988,7 @@ int main(int argc, char **argv)
>  
>      ret = g_test_run();
>  
> -    if (s) {
> -        qtest_quit(s);
> -    }
> -
>      /* cleanup */
> -    test_server_free(server);
>  
>      /* finish the helper thread and dispatch pending sources */
>      g_main_loop_quit(loop);
> --
> 2.14.3
> 
> 

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

* Re: [Qemu-devel] [PATCH 4/5] vhost-user-test: fix features mask
  2017-12-21 17:07 ` [Qemu-devel] [PATCH 4/5] vhost-user-test: fix features mask Maxime Coquelin
@ 2017-12-21 17:18   ` Marc-André Lureau
  2017-12-21 17:29     ` Maxime Coquelin
  0 siblings, 1 reply; 9+ messages in thread
From: Marc-André Lureau @ 2017-12-21 17:18 UTC (permalink / raw)
  To: Maxime Coquelin; +Cc: qemu-devel, stefanha, mst

Hi

----- Original Message -----
> VIRTIO_NET_F_MAC is a bit position, not a bit mask.
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Fixing this before patch 3 would make sense.

> ---
>  tests/vhost-user-test.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> index be7a401789..6a144e8d7e 100644
> --- a/tests/vhost-user-test.c
> +++ b/tests/vhost-user-test.c
> @@ -652,7 +652,7 @@ static void test_read_guest_mem(void)
>      s = qtest_start(qemu_cmd);
>      g_free(qemu_cmd);
>  
> -    init_virtio_dev(server, VIRTIO_NET_F_MAC);
> +    init_virtio_dev(server, 1u << VIRTIO_NET_F_MAC);
>  
>      read_guest_mem(server);
>  
> @@ -681,7 +681,7 @@ static void test_migrate(void)
>      from = qtest_start(cmd);
>      g_free(cmd);
>  
> -    init_virtio_dev(s, VIRTIO_NET_F_MAC);
> +    init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
>      wait_for_fds(s);
>      size = get_log_size(s);
>      g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));
> @@ -803,7 +803,7 @@ static void test_reconnect_subprocess(void)
>      qtest_start(cmd);
>      g_free(cmd);
>  
> -    init_virtio_dev(s, VIRTIO_NET_F_MAC);
> +    init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
>      wait_for_fds(s);
>      wait_for_rings_started(s, 2);
>  
> @@ -841,7 +841,7 @@ static void test_connect_fail_subprocess(void)
>      qtest_start(cmd);
>      g_free(cmd);
>  
> -    init_virtio_dev(s, VIRTIO_NET_F_MAC);
> +    init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
>      wait_for_fds(s);
>      wait_for_rings_started(s, 2);
>  
> @@ -871,7 +871,7 @@ static void test_flags_mismatch_subprocess(void)
>      qtest_start(cmd);
>      g_free(cmd);
>  
> -    init_virtio_dev(s, VIRTIO_NET_F_MAC);
> +    init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
>      wait_for_fds(s);
>      wait_for_rings_started(s, 2);
>  
> --
> 2.14.3
> 
> 

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

* Re: [Qemu-devel] [PATCH 4/5] vhost-user-test: fix features mask
  2017-12-21 17:18   ` Marc-André Lureau
@ 2017-12-21 17:29     ` Maxime Coquelin
  0 siblings, 0 replies; 9+ messages in thread
From: Maxime Coquelin @ 2017-12-21 17:29 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, stefanha, mst



On 12/21/2017 06:18 PM, Marc-André Lureau wrote:
> Hi
> 
> ----- Original Message -----
>> VIRTIO_NET_F_MAC is a bit position, not a bit mask.
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> 
> Fixing this before patch 3 would make sense.

Yes, you're right.
I'll make it patch #1 in v2.

Thanks,
Maxime

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

end of thread, other threads:[~2017-12-21 17:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-21 17:07 [Qemu-devel] [PATCH 0/5] vhost-user-test: Fixes & code clean-up Maxime Coquelin
2017-12-21 17:07 ` [Qemu-devel] [PATCH 1/5] vhost-user-test: extract read-guest-mem test from main loop Maxime Coquelin
2017-12-21 17:16   ` Marc-André Lureau
2017-12-21 17:07 ` [Qemu-devel] [PATCH 2/5] vhost-user-test: setup virtqueues in all tests Maxime Coquelin
2017-12-21 17:07 ` [Qemu-devel] [PATCH 3/5] vhost-user-test: make features mask an init_virtio_dev() argument Maxime Coquelin
2017-12-21 17:07 ` [Qemu-devel] [PATCH 4/5] vhost-user-test: fix features mask Maxime Coquelin
2017-12-21 17:18   ` Marc-André Lureau
2017-12-21 17:29     ` Maxime Coquelin
2017-12-21 17:07 ` [Qemu-devel] [PATCH 5/5] vhost-user-test: use init_virtio_dev in multiqueue test Maxime Coquelin

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.