diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/acpi-test-data/pc/FACP | bin | 116 -> 116 bytes | |||
-rw-r--r-- | tests/acpi-test-data/q35/FACP | bin | 116 -> 244 bytes | |||
-rw-r--r-- | tests/bios-tables-test.c | 35 | ||||
-rw-r--r-- | tests/vhost-user-test.c | 90 |
4 files changed, 59 insertions, 66 deletions
diff --git a/tests/acpi-test-data/pc/FACP b/tests/acpi-test-data/pc/FACP Binary files differindex 0639999..261ebdc 100644 --- a/tests/acpi-test-data/pc/FACP +++ b/tests/acpi-test-data/pc/FACP diff --git a/tests/acpi-test-data/q35/FACP b/tests/acpi-test-data/q35/FACP Binary files differindex 19f3ac3..72c9d97 100644 --- a/tests/acpi-test-data/q35/FACP +++ b/tests/acpi-test-data/q35/FACP diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index b354aaa..2b332ed 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -194,6 +194,35 @@ static void test_acpi_fadt_table(test_data *data) le32_to_cpu(fadt_table->length))); } +static void sanitize_fadt_ptrs(test_data *data) +{ + /* fixup pointers in FADT */ + int i; + + for (i = 0; i < data->tables->len; i++) { + AcpiSdtTable *sdt = &g_array_index(data->tables, AcpiSdtTable, i); + + if (memcmp(&sdt->header.signature, "FACP", 4)) { + continue; + } + + /* sdt->aml field offset := spec offset - header size */ + memset(sdt->aml + 0, 0, 4); /* sanitize FIRMWARE_CTRL(36) ptr */ + memset(sdt->aml + 4, 0, 4); /* sanitize DSDT(40) ptr */ + if (sdt->header.revision >= 3) { + memset(sdt->aml + 96, 0, 8); /* sanitize X_FIRMWARE_CTRL(132) ptr */ + memset(sdt->aml + 104, 0, 8); /* sanitize X_DSDT(140) ptr */ + } + + /* update checksum */ + sdt->header.checksum = 0; + sdt->header.checksum -= + acpi_calc_checksum((uint8_t *)sdt, sizeof(AcpiTableHeader)) + + acpi_calc_checksum((uint8_t *)sdt->aml, sdt->aml_len); + break; + } +} + static void test_acpi_facs_table(test_data *data) { AcpiFacsDescriptorRev1 *facs_table = &data->facs_table; @@ -248,14 +277,14 @@ static void test_acpi_dsdt_table(test_data *data) /* Load all tables and add to test list directly RSDT referenced tables */ static void fetch_rsdt_referenced_tables(test_data *data) { - int tables_nr = data->rsdt_tables_nr - 1; /* fadt is first */ + int tables_nr = data->rsdt_tables_nr; int i; for (i = 0; i < tables_nr; i++) { AcpiSdtTable ssdt_table; uint32_t addr; - addr = le32_to_cpu(data->rsdt_tables_addr[i + 1]); /* fadt is first */ + addr = le32_to_cpu(data->rsdt_tables_addr[i]); fetch_table(&ssdt_table, addr); /* Add table to ASL test tables list */ @@ -650,6 +679,8 @@ static void test_acpi_one(const char *params, test_data *data) test_acpi_dsdt_table(data); fetch_rsdt_referenced_tables(data); + sanitize_fadt_ptrs(data); + if (iasl) { if (getenv(ACPI_REBUILD_EXPECTED_AML)) { dump_aml_files(data, true); diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 128fce3..a217353 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -18,7 +18,6 @@ #include "qemu/range.h" #include "qemu/sockets.h" #include "chardev/char-fe.h" -#include "qemu/memfd.h" #include "sysemu/sysemu.h" #include "libqos/libqos.h" #include "libqos/pci-pc.h" @@ -41,14 +40,23 @@ #define HAVE_MONOTONIC_TIME #endif -#define QEMU_CMD_MEM " -m %d -object memory-backend-file,id=mem,size=%dM," \ +#define QEMU_CMD_MEM " -m %d -object memory-backend-file,id=mem,size=%dM,"\ "mem-path=%s,share=on -numa node,memdev=mem" -#define QEMU_CMD_MEMFD " -m %d -object memory-backend-memfd,id=mem,size=%dM," \ - " -numa node,memdev=mem" #define QEMU_CMD_CHR " -chardev socket,id=%s,path=%s%s" #define QEMU_CMD_NETDEV " -netdev vhost-user,id=net0,chardev=%s,vhostforce" #define QEMU_CMD_NET " -device virtio-net-pci,netdev=net0" +#define QEMU_CMD QEMU_CMD_MEM QEMU_CMD_CHR \ + QEMU_CMD_NETDEV QEMU_CMD_NET + +#define GET_QEMU_CMD(s) \ + g_strdup_printf(QEMU_CMD, 512, 512, (root), (s)->chr_name, \ + (s)->socket_path, "", (s)->chr_name) + +#define GET_QEMU_CMDE(s, mem, chr_opts, extra, ...) \ + g_strdup_printf(QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name, \ + (s)->socket_path, (chr_opts), (s)->chr_name, ##__VA_ARGS__) + #define HUGETLBFS_MAGIC 0x958458f6 /*********** FROM hw/virtio/vhost-user.c *************************************/ @@ -167,33 +175,6 @@ static void test_server_listen(TestServer *server); static const char *tmpfs; static const char *root; -enum test_memfd { - TEST_MEMFD_AUTO, - TEST_MEMFD_YES, - TEST_MEMFD_NO, -}; - -static char *get_qemu_cmd(TestServer *s, - int mem, enum test_memfd memfd, const char *mem_path, - const char *chr_opts, const char *extra) -{ - if (memfd == TEST_MEMFD_AUTO && qemu_memfd_check()) { - memfd = TEST_MEMFD_YES; - } - - if (memfd == TEST_MEMFD_YES) { - return g_strdup_printf(QEMU_CMD_MEMFD QEMU_CMD_CHR - QEMU_CMD_NETDEV QEMU_CMD_NET "%s", mem, mem, - s->chr_name, s->socket_path, - chr_opts, s->chr_name, extra); - } else { - return g_strdup_printf(QEMU_CMD_MEM QEMU_CMD_CHR - QEMU_CMD_NETDEV QEMU_CMD_NET "%s", mem, mem, - mem_path, s->chr_name, s->socket_path, - chr_opts, s->chr_name, extra); - } -} - static void init_virtio_dev(TestServer *s, uint32_t features_mask) { uint32_t features; @@ -659,9 +640,8 @@ GSourceFuncs test_migrate_source_funcs = { .check = test_migrate_source_check, }; -static void test_read_guest_mem(const void *arg) +static void test_read_guest_mem(void) { - enum test_memfd memfd = GPOINTER_TO_INT(arg); TestServer *server = NULL; char *qemu_cmd = NULL; QTestState *s = NULL; @@ -669,7 +649,7 @@ static void test_read_guest_mem(const void *arg) server = test_server_new("test"); test_server_listen(server); - qemu_cmd = get_qemu_cmd(server, 512, memfd, root, "", ""); + qemu_cmd = GET_QEMU_CMD(server); s = qtest_start(qemu_cmd); g_free(qemu_cmd); @@ -691,7 +671,7 @@ static void test_migrate(void) char *uri = g_strdup_printf("%s%s", "unix:", dest->mig_path); QTestState *global = global_qtest, *from, *to; GSource *source; - gchar *cmd, *tmp; + gchar *cmd; QDict *rsp; guint8 *log; guint64 size; @@ -699,7 +679,7 @@ static void test_migrate(void) test_server_listen(s); test_server_listen(dest); - cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, "", ""); + cmd = GET_QEMU_CMDE(s, 2, "", ""); from = qtest_start(cmd); g_free(cmd); @@ -708,9 +688,7 @@ static void test_migrate(void) size = get_log_size(s); g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8)); - tmp = g_strdup_printf(" -incoming %s", uri); - cmd = get_qemu_cmd(dest, 2, TEST_MEMFD_AUTO, root, "", tmp); - g_free(tmp); + cmd = GET_QEMU_CMDE(dest, 2, "", " -incoming %s", uri); to = qtest_init(cmd); g_free(cmd); @@ -823,7 +801,7 @@ static void test_reconnect_subprocess(void) char *cmd; g_thread_new("connect", connect_thread, s); - cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, ",server", ""); + cmd = GET_QEMU_CMDE(s, 2, ",server", ""); qtest_start(cmd); g_free(cmd); @@ -861,7 +839,7 @@ static void test_connect_fail_subprocess(void) s->test_fail = true; g_thread_new("connect", connect_thread, s); - cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, ",server", ""); + cmd = GET_QEMU_CMDE(s, 2, ",server", ""); qtest_start(cmd); g_free(cmd); @@ -891,7 +869,7 @@ static void test_flags_mismatch_subprocess(void) s->test_flags = TEST_FLAGS_DISCONNECT; g_thread_new("connect", connect_thread, s); - cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, ",server", ""); + cmd = GET_QEMU_CMDE(s, 2, ",server", ""); qtest_start(cmd); g_free(cmd); @@ -926,21 +904,11 @@ static void test_multiqueue(void) s->queues = 2; test_server_listen(s); - if (qemu_memfd_check()) { - cmd = g_strdup_printf( - QEMU_CMD_MEMFD QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=%d " - "-device virtio-net-pci,netdev=net0,mq=on,vectors=%d", - 512, 512, s->chr_name, - s->socket_path, "", s->chr_name, - s->queues, s->queues * 2 + 2); - } else { - 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, - s->queues, s->queues * 2 + 2); - } + 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, + s->queues, s->queues * 2 + 2); qtest_start(cmd); g_free(cmd); @@ -986,13 +954,7 @@ int main(int argc, char **argv) /* run the main loop thread so the chardev may operate */ thread = g_thread_new(NULL, thread_function, loop); - if (qemu_memfd_check()) { - qtest_add_data_func("/vhost-user/read-guest-mem/memfd", - GINT_TO_POINTER(TEST_MEMFD_YES), - test_read_guest_mem); - } - qtest_add_data_func("/vhost-user/read-guest-mem/memfile", - GINT_TO_POINTER(TEST_MEMFD_NO), test_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); |