[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 51/54] vhost-user-test: reduce usage of global_qtest
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 51/54] vhost-user-test: reduce usage of global_qtest |
Date: |
Wed, 12 Dec 2018 16:23:12 +0100 |
Whenever the code can run on multiple QTestStates, use them explicitly instead
of
global_qtest.
Reviewed-by: Marc-André Lureau <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
Message-Id: <address@hidden>
---
tests/vhost-user-test.c | 38 +++++++++++++++++---------------------
1 file changed, 17 insertions(+), 21 deletions(-)
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 59e1aec..c3a8af3 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);
--
1.8.3.1
- [Qemu-devel] [PULL 42/54] vhost-net-user: add stubs for when no virtio-net device is present, (continued)
- [Qemu-devel] [PULL 42/54] vhost-net-user: add stubs for when no virtio-net device is present, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 43/54] vhost: restrict Linux dependency to kernel vhost, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 39/54] Remove QEMU_ARTIFICIAL macro, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 54/54] vhost-user-test: create a temporary directory per TestServer, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 49/54] vhost-user-test: support VHOST_USER_PROTOCOL_F_CROSS_ENDIAN, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 53/54] vhost-user-test: small changes to init_hugepagefs, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 52/54] vhost-user-test: create a main loop per TestServer, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 48/54] vhost-user: support cross-endian vnet headers, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 50/54] vhost-user-test: skip if there is no memory at address 0, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 44/54] vhost-net: compile it on all targets that have virtio-net., Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 51/54] vhost-user-test: reduce usage of global_qtest,
Paolo Bonzini <=
- [Qemu-devel] [PULL 45/54] vhost-net: revamp configure logic, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 41/54] vhost-net: move stubs to a separate file, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 47/54] vhost-user-test: signal data_cond when s->rings changes, Paolo Bonzini, 2018/12/12
- Re: [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12, Eric Blake, 2018/12/12
- Re: [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12, no-reply, 2018/12/12