aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-02-05 19:39:22 +0000
committerPeter Maydell <peter.maydell@linaro.org>2019-02-05 19:39:22 +0000
commit3e29da9fd81002a0c03041aaa26dea6d9dd9bd65 (patch)
treeacd21f31ace26a41b261fe462ae26c782ffb42d2 /tests
parent47994e16b1d66411953623e7c0bf0cdcd50bd507 (diff)
parent5ed76a4c63db9295c6c5d67895925810050d4a46 (diff)
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* cpu-exec fixes (Emilio, Laurent) * TCG bugfix in queue.h (Paolo) * high address load for linuxboot (Zhijian) * PVH support (Liam, Stefano) * misc i386 changes (Paolo, Robert, Doug) * configure tweak for openpty (Thomas) * elf2dmp port to Windows (Viktor) * initial improvements to Makefile infrastructure (Yang + GSoC 2013) # gpg: Signature made Tue 05 Feb 2019 17:34:42 GMT # gpg: using RSA key BFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: (76 commits) queue: fix QTAILQ_FOREACH_REVERSE_SAFE scsi-generic: Convert from DPRINTF() macro to trace events scsi-disk: Convert from DPRINTF() macro to trace events pc: Use hotplug_handler_(plug|unplug|unplug_request) i386: hvf: Fix smp boot hangs hw/vfio/Makefile.objs: Create new CONFIG_* variables for VFIO core and PCI hw/i2c/Makefile.objs: Create new CONFIG_* variables for EEPROM and ACPI controller hw/tricore/Makefile.objs: Create CONFIG_* for tricore hw/openrisc/Makefile.objs: Create CONFIG_* for openrisc hw/moxie/Makefile.objs: Conditionally build moxie hw/hppa/Makefile.objs: Create CONFIG_* for hppa hw/cris/Makefile.objs: Create CONFIG_* for cris hw/alpha/Makefile.objs: Create CONFIG_* for alpha hw/sparc64/Makefile.objs: Create CONFIG_* for sparc64 hw/riscv/Makefile.objs: Create CONFIG_* for riscv boards hw/nios2/Makefile.objs: Conditionally build nios2 hw/xtensa/Makefile.objs: Build xtensa_sim and xtensa_fpga conditionally hw/lm32/Makefile.objs: Conditionally build lm32 and milkmyst hw/sparc/Makefile.objs: CONFIG_* for sun4m and leon3 created hw/s390/Makefile.objs: Create new CONFIG_* variables for s390x boards and devices ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org> # Conflicts: # qemu-deprecated.texi
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.include4
-rw-r--r--tests/docker/dockerfiles/centos7.docker5
-rw-r--r--tests/vhost-user-test.c104
3 files changed, 71 insertions, 42 deletions
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 75ad9c0dd3..b39e989f72 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -798,10 +798,6 @@ tests/migration/initrd-stress.img: tests/migration/stress$(EXESUF)
rm $(INITRD_WORK_DIR)/init
rmdir $(INITRD_WORK_DIR)
-ifeq ($(CONFIG_POSIX),y)
-LIBS += -lutil
-endif
-
# QTest rules
TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGET_DIRS)))
diff --git a/tests/docker/dockerfiles/centos7.docker b/tests/docker/dockerfiles/centos7.docker
index e0f18f5a41..e0b9d7dbe9 100644
--- a/tests/docker/dockerfiles/centos7.docker
+++ b/tests/docker/dockerfiles/centos7.docker
@@ -1,5 +1,6 @@
FROM centos:7
-RUN yum install -y epel-release centos-release-xen
+RUN yum install -y epel-release centos-release-xen-48
+
RUN yum -y update
ENV PACKAGES \
bison \
@@ -8,7 +9,7 @@ ENV PACKAGES \
ccache \
csnappy-devel \
flex \
- g++ \
+ gcc-c++ \
gcc \
gettext \
git \
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 84e50d84e7..7d5f234646 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -51,6 +51,7 @@
#define VHOST_USER_F_PROTOCOL_FEATURES 30
#define VHOST_USER_PROTOCOL_F_MQ 0
#define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1
+#define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN 6
#define VHOST_LOG_PAGE 0x1000
@@ -186,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);
@@ -202,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);
@@ -227,9 +228,11 @@ static void uninit_virtio_dev(TestServer *s)
qvirtio_pci_device_free(s->dev);
}
-static void wait_for_fds(TestServer *s)
+static bool wait_for_fds(TestServer *s)
{
gint64 end_time;
+ bool got_region;
+ int i;
g_mutex_lock(&s->data_mutex);
@@ -247,16 +250,27 @@ static void wait_for_fds(TestServer *s)
g_assert_cmpint(s->fds_num, ==, s->memory.nregions);
g_mutex_unlock(&s->data_mutex);
+
+ got_region = false;
+ for (i = 0; i < s->memory.nregions; ++i) {
+ VhostUserMemoryRegion *reg = &s->memory.regions[i];
+ if (reg->guest_phys_addr == 0) {
+ got_region = true;
+ break;
+ }
+ }
+ if (!got_region) {
+ g_test_skip("No memory at address 0x0");
+ }
+ return got_region;
}
-static void read_guest_mem_server(TestServer *s)
+static void read_guest_mem_server(QTestState *qts, TestServer *s)
{
- uint32_t *guest_mem;
+ uint8_t *guest_mem;
int i, j;
size_t size;
- wait_for_fds(s);
-
g_mutex_lock(&s->data_mutex);
/* iterate all regions */
@@ -278,8 +292,8 @@ static void read_guest_mem_server(TestServer *s)
g_assert(guest_mem != MAP_FAILED);
guest_mem += (s->memory.regions[i].mmap_offset / sizeof(*guest_mem));
- for (j = 0; j < 256; j++) {
- uint32_t a = readl(s->memory.regions[i].guest_phys_addr + j*4);
+ for (j = 0; j < 1024; 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);
@@ -367,6 +381,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
msg.flags |= VHOST_USER_REPLY_MASK;
msg.size = sizeof(m.payload.u64);
msg.payload.u64 = 1 << VHOST_USER_PROTOCOL_F_LOG_SHMFD;
+ msg.payload.u64 |= 1 << VHOST_USER_PROTOCOL_F_CROSS_ENDIAN;
if (s->queues > 1) {
msg.payload.u64 |= 1 << VHOST_USER_PROTOCOL_F_MQ;
}
@@ -384,6 +399,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
assert(msg.payload.state.index < s->queues * 2);
s->rings &= ~(0x1ULL << msg.payload.state.index);
+ g_cond_broadcast(&s->data_cond);
break;
case VHOST_USER_SET_MEM_TABLE:
@@ -393,7 +409,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
G_N_ELEMENTS(s->fds));
/* signal the test that it can continue */
- g_cond_signal(&s->data_cond);
+ g_cond_broadcast(&s->data_cond);
break;
case VHOST_USER_SET_VRING_KICK:
@@ -419,12 +435,13 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
p = (uint8_t *) &msg;
qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE);
- g_cond_signal(&s->data_cond);
+ g_cond_broadcast(&s->data_cond);
break;
case VHOST_USER_SET_VRING_BASE:
assert(msg.payload.state.index < s->queues * 2);
s->rings |= 0x1ULL << msg.payload.state.index;
+ g_cond_broadcast(&s->data_cond);
break;
case VHOST_USER_GET_QUEUE_NUM:
@@ -573,8 +590,6 @@ static void write_guest_mem(TestServer *s, uint32_t seed)
int i, j;
size_t size;
- wait_for_fds(s);
-
/* iterate all regions */
for (i = 0; i < s->fds_num; i++) {
@@ -655,10 +670,15 @@ 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);
qtest_quit(s);
@@ -670,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;
@@ -684,9 +704,11 @@ static void test_migrate(void)
from = qtest_start(cmd);
g_free(cmd);
- init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
- init_virtio_dev(dest, 1u << VIRTIO_NET_F_MAC);
- wait_for_fds(s);
+ init_virtio_dev(from, s, 1u << VIRTIO_NET_F_MAC);
+ if (!wait_for_fds(s)) {
+ goto exit;
+ }
+
size = get_log_size(s);
g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));
@@ -695,6 +717,7 @@ static void test_migrate(void)
g_free(tmp);
to = qtest_init(cmd);
g_free(cmd);
+ init_virtio_dev(to, dest, 1u << VIRTIO_NET_F_MAC);
source = g_source_new(&test_migrate_source_funcs,
sizeof(TestMigrateSource));
@@ -730,25 +753,24 @@ 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(dest));
+ read_guest_mem_server(to, dest);
- read_guest_mem_server(dest);
-
- uninit_virtio_dev(s);
uninit_virtio_dev(dest);
+ qtest_quit(to);
g_source_destroy(source);
g_source_unref(source);
- qtest_quit(to);
+exit:
+ uninit_virtio_dev(s);
+
test_server_free(dest);
qtest_quit(from);
test_server_free(s);
g_free(uri);
-
- global_qtest = global;
}
static void wait_for_rings_started(TestServer *s, size_t count)
@@ -805,17 +827,21 @@ static void test_reconnect_subprocess(void)
qtest_start(cmd);
g_free(cmd);
- init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
- wait_for_fds(s);
+ init_virtio_dev(global_qtest, s, 1u << VIRTIO_NET_F_MAC);
+ if (!wait_for_fds(s)) {
+ goto exit;
+ }
+
wait_for_rings_started(s, 2);
/* reconnect */
s->fds_num = 0;
s->rings = 0;
g_idle_add(reconnect_cb, s);
- wait_for_fds(s);
+ g_assert(wait_for_fds(s));
wait_for_rings_started(s, 2);
+exit:
uninit_virtio_dev(s);
qtest_end();
@@ -843,10 +869,13 @@ static void test_connect_fail_subprocess(void)
qtest_start(cmd);
g_free(cmd);
- init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
- wait_for_fds(s);
+ init_virtio_dev(global_qtest, s, 1u << VIRTIO_NET_F_MAC);
+ if (!wait_for_fds(s)) {
+ goto exit;
+ }
wait_for_rings_started(s, 2);
+exit:
uninit_virtio_dev(s);
qtest_end();
@@ -873,10 +902,13 @@ static void test_flags_mismatch_subprocess(void)
qtest_start(cmd);
g_free(cmd);
- init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
- wait_for_fds(s);
+ init_virtio_dev(global_qtest, s, 1u << VIRTIO_NET_F_MAC);
+ if (!wait_for_fds(s)) {
+ goto exit;
+ }
wait_for_rings_started(s, 2);
+exit:
uninit_virtio_dev(s);
qtest_end();
@@ -921,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);