diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2018-12-03 16:32:24 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-02-05 16:50:16 +0100 |
commit | bae6b59d46f9cb5e8a4f4cc07c5b2528b198b06b (patch) | |
tree | e2a1bdece3835ca292e1b3b446e6aeeb9d6539d2 /tests | |
parent | 3b72ca381f22393a564b6a8f3b831a3dd0a88d65 (diff) |
vhost-user-test: reduce usage of global_qtest
Whenever the code can run on multiple QTestStates, use them explicitly instead of
global_qtest.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1543851204-41186-12-git-send-email-pbonzini@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/vhost-user-test.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index a0da5c320a..7d5f234646 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -187,12 +187,12 @@ static char *get_qemu_cmd(TestServer *s, } } -static void init_virtio_dev(TestServer *s, uint32_t features_mask) +static void init_virtio_dev(QTestState *qts, TestServer *s, uint32_t features_mask) { uint32_t features; int i; - s->bus = qpci_init_pc(global_qtest, NULL); + s->bus = qpci_init_pc(qts, NULL); g_assert_nonnull(s->bus); s->dev = qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET); @@ -203,7 +203,7 @@ static void init_virtio_dev(TestServer *s, uint32_t features_mask) qvirtio_set_acknowledge(&s->dev->vdev); qvirtio_set_driver(&s->dev->vdev); - s->alloc = pc_alloc_init(global_qtest); + s->alloc = pc_alloc_init(qts); for (i = 0; i < s->queues * 2; i++) { s->vq[i] = qvirtqueue_setup(&s->dev->vdev, s->alloc, i); @@ -265,7 +265,7 @@ static bool wait_for_fds(TestServer *s) return got_region; } -static void read_guest_mem_server(TestServer *s) +static void read_guest_mem_server(QTestState *qts, TestServer *s) { uint8_t *guest_mem; int i, j; @@ -293,7 +293,7 @@ static void read_guest_mem_server(TestServer *s) guest_mem += (s->memory.regions[i].mmap_offset / sizeof(*guest_mem)); for (j = 0; j < 1024; j++) { - uint32_t a = readb(s->memory.regions[i].guest_phys_addr + j); + uint32_t a = qtest_readb(qts, s->memory.regions[i].guest_phys_addr + j); uint32_t b = guest_mem[j]; g_assert_cmpint(a, ==, b); @@ -670,13 +670,13 @@ static void test_read_guest_mem(const void *arg) s = qtest_start(qemu_cmd); g_free(qemu_cmd); - init_virtio_dev(server, 1u << VIRTIO_NET_F_MAC); + init_virtio_dev(global_qtest, server, 1u << VIRTIO_NET_F_MAC); if (!wait_for_fds(server)) { goto exit; } - read_guest_mem_server(server); + read_guest_mem_server(global_qtest, server); exit: uninit_virtio_dev(server); @@ -690,7 +690,7 @@ static void test_migrate(void) TestServer *s = test_server_new("src"); TestServer *dest = test_server_new("dest"); char *uri = g_strdup_printf("%s%s", "unix:", dest->mig_path); - QTestState *global = global_qtest, *from, *to; + QTestState *from, *to; GSource *source; gchar *cmd, *tmp; QDict *rsp; @@ -704,7 +704,7 @@ static void test_migrate(void) from = qtest_start(cmd); g_free(cmd); - init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC); + init_virtio_dev(from, s, 1u << VIRTIO_NET_F_MAC); if (!wait_for_fds(s)) { goto exit; } @@ -717,7 +717,7 @@ static void test_migrate(void) g_free(tmp); to = qtest_init(cmd); g_free(cmd); - init_virtio_dev(dest, 1u << VIRTIO_NET_F_MAC); + init_virtio_dev(to, dest, 1u << VIRTIO_NET_F_MAC); source = g_source_new(&test_migrate_source_funcs, sizeof(TestMigrateSource)); @@ -753,12 +753,10 @@ static void test_migrate(void) qobject_unref(rsp); qmp_eventwait("STOP"); + qtest_qmp_eventwait(to, "RESUME"); - global_qtest = to; - qmp_eventwait("RESUME"); - - g_assert(wait_for_fds(s)); - read_guest_mem_server(dest); + g_assert(wait_for_fds(dest)); + read_guest_mem_server(to, dest); uninit_virtio_dev(dest); qtest_quit(to); @@ -773,8 +771,6 @@ exit: qtest_quit(from); test_server_free(s); g_free(uri); - - global_qtest = global; } static void wait_for_rings_started(TestServer *s, size_t count) @@ -831,7 +827,7 @@ static void test_reconnect_subprocess(void) qtest_start(cmd); g_free(cmd); - init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC); + init_virtio_dev(global_qtest, s, 1u << VIRTIO_NET_F_MAC); if (!wait_for_fds(s)) { goto exit; } @@ -873,7 +869,7 @@ static void test_connect_fail_subprocess(void) qtest_start(cmd); g_free(cmd); - init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC); + init_virtio_dev(global_qtest, s, 1u << VIRTIO_NET_F_MAC); if (!wait_for_fds(s)) { goto exit; } @@ -906,7 +902,7 @@ static void test_flags_mismatch_subprocess(void) qtest_start(cmd); g_free(cmd); - init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC); + init_virtio_dev(global_qtest, s, 1u << VIRTIO_NET_F_MAC); if (!wait_for_fds(s)) { goto exit; } @@ -957,7 +953,7 @@ static void test_multiqueue(void) qtest_start(cmd); g_free(cmd); - init_virtio_dev(s, features_mask); + init_virtio_dev(global_qtest, s, features_mask); wait_for_rings_started(s, s->queues * 2); |