[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/49] vhost-user-test: reduce usage of global_qtest
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 13/49] vhost-user-test: reduce usage of global_qtest |
Date: |
Mon, 21 Jan 2019 19:05:44 +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 30b0aba..15e3bbf 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -190,12 +190,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);
@@ -206,7 +206,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);
@@ -268,7 +268,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;
@@ -296,7 +296,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);
@@ -675,13 +675,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);
@@ -695,7 +695,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;
@@ -709,7 +709,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;
}
@@ -722,7 +722,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));
@@ -758,12 +758,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);
@@ -778,8 +776,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)
@@ -836,7 +832,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;
}
@@ -878,7 +874,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;
}
@@ -911,7 +907,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;
}
@@ -962,7 +958,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 07/49] vhost-net: revamp configure logic, (continued)
- [Qemu-devel] [PULL 07/49] vhost-net: revamp configure logic, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 10/49] vhost-user: support cross-endian vnet headers, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 01/49] scripts/update-linux-headers.sh: adjust for Linux 4.21-rc1 (or 5.0-rc1), Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 11/49] vhost-user-test: support VHOST_USER_PROTOCOL_F_CROSS_ENDIAN, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 17/49] tap: flush STDOUT on newline, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 19/49] cpu-exec: add assert_no_pages_locked() after longjmp, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 14/49] vhost-user-test: create a main loop per TestServer, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 20/49] cpu-exec: reset BQL after longjmp in cpu_exec_step_atomic, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 12/49] vhost-user-test: skip if there is no memory at address 0, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 03/49] vhost-net: move stubs to a separate file, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 13/49] vhost-user-test: reduce usage of global_qtest,
Paolo Bonzini <=
- [Qemu-devel] [PULL 05/49] vhost: restrict Linux dependency to kernel vhost, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 15/49] vhost-user-test: small changes to init_hugepagefs, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 16/49] vhost-user-test: create a temporary directory per TestServer, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 18/49] tests/hexloader-test: Don't pass -nographic to the QEMU under test, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 21/49] configure: Add a proper check for openpty() in libutil, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 22/49] cpus: ignore ESRCH in qemu_cpu_kick_thread(), Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 24/49] elf-ops.h: Add get_elf_note_type(), Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 25/49] pvh: Add x86/HVM direct boot ABI header file, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 28/49] linuxboot_dma: remove duplicate definitions of FW_CFG, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 23/49] elf: Add optional function ptr to load_elf() to parse ELF notes, Paolo Bonzini, 2019/01/21