From 4ff969ce8e20586f1cc340c673e346a7d18e80d7 Mon Sep 17 00:00:00 2001 From: Shameer Kolothum Date: Tue, 17 Dec 2024 13:10:46 +0000 Subject: [PATCH 1/8] tests/qtest/migration: Fix compile errors when CONFIG_UADK is set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes accidental inclusion of unrelated functions within CONFIG_UADK as this causes compile errors like: error: redefinition of ‘migrate_hook_start_xbzrle’ Fixes: 932f74f3fe6e ("tests/qtest/migration: Split compression tests from migration-test.c") Signed-off-by: Shameer Kolothum Reviewed-by: Fabiano Rosas Message-Id: <20241217131046.83844-1-shameerali.kolothum.thodi@huawei.com> Signed-off-by: Fabiano Rosas --- tests/qtest/migration/compression-tests.c | 54 ----------------------- 1 file changed, 54 deletions(-) diff --git a/tests/qtest/migration/compression-tests.c b/tests/qtest/migration/compression-tests.c index 6de87bc47d..d78f1f11f1 100644 --- a/tests/qtest/migration/compression-tests.c +++ b/tests/qtest/migration/compression-tests.c @@ -88,59 +88,6 @@ migrate_hook_start_precopy_tcp_multifd_uadk(QTestState *from, return migrate_hook_start_precopy_tcp_multifd_common(from, to, "uadk"); } -static void * -migrate_hook_start_xbzrle(QTestState *from, - QTestState *to) -{ - migrate_set_parameter_int(from, "xbzrle-cache-size", 33554432); - - migrate_set_capability(from, "xbzrle", true); - migrate_set_capability(to, "xbzrle", true); - - return NULL; -} - -static void test_precopy_unix_xbzrle(void) -{ - g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); - MigrateCommon args = { - .connect_uri = uri, - .listen_uri = uri, - .start_hook = migrate_hook_start_xbzrle, - .iterations = 2, - /* - * XBZRLE needs pages to be modified when doing the 2nd+ round - * iteration to have real data pushed to the stream. - */ - .live = true, - }; - - test_precopy_common(&args); -} - -static void * -migrate_hook_start_precopy_tcp_multifd_zlib(QTestState *from, - QTestState *to) -{ - /* - * Overloading this test to also check that set_parameter does not error. - * This is also done in the tests for the other compression methods. - */ - migrate_set_parameter_int(from, "multifd-zlib-level", 2); - migrate_set_parameter_int(to, "multifd-zlib-level", 2); - - return migrate_hook_start_precopy_tcp_multifd_common(from, to, "zlib"); -} - -static void test_multifd_tcp_zlib(void) -{ - MigrateCommon args = { - .listen_uri = "defer", - .start_hook = migrate_hook_start_precopy_tcp_multifd_zlib, - }; - test_precopy_common(&args); -} - static void test_multifd_tcp_uadk(void) { MigrateCommon args = { @@ -151,7 +98,6 @@ static void test_multifd_tcp_uadk(void) } #endif /* CONFIG_UADK */ - static void * migrate_hook_start_xbzrle(QTestState *from, QTestState *to) From cd196679f413c7905143e5eb9b7d63b7a7eea158 Mon Sep 17 00:00:00 2001 From: Fabiano Rosas Date: Mon, 9 Dec 2024 17:44:22 -0300 Subject: [PATCH 2/8] tests/qtest/migration: Do proper cleanup in the dirty_limit test The dirty_limit test does two migrations in a row and is leaking the first 'to' instance. Do proper cleanup. Reviewed-by: Peter Xu Message-Id: <20241209204427.17763-2-farosas@suse.de> Signed-off-by: Fabiano Rosas --- tests/qtest/migration/precopy-tests.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/qtest/migration/precopy-tests.c b/tests/qtest/migration/precopy-tests.c index b709d9051d..23599b29ee 100644 --- a/tests/qtest/migration/precopy-tests.c +++ b/tests/qtest/migration/precopy-tests.c @@ -877,6 +877,11 @@ static void test_dirty_limit(void) migrate_cancel(from); wait_for_migration_status(from, "cancelled", NULL); + /* destination always fails after cancel */ + migration_event_wait(to, "failed"); + qtest_set_expected_status(to, EXIT_FAILURE); + qtest_quit(to); + /* Check if dirty limit throttle switched off, set timeout 1ms */ do { throttle_us_per_full = From 117221ad999a3d027d38ae9ddbaa94d4e1d6a303 Mon Sep 17 00:00:00 2001 From: Fabiano Rosas Date: Mon, 9 Dec 2024 17:44:23 -0300 Subject: [PATCH 3/8] tests/qtest/migration: Initialize buffer in probe_o_direct_support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Valgrind complains about the probe_o_direct_support() function reading from an uninitialized buffer. For probing O_DIRECT support we don't actually need to write to the file, just make sure the pwrite call doesn't reject the write. Still, write zeroes to the buffer to suppress the warning. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Xu Message-Id: <20241209204427.17763-3-farosas@suse.de> Signed-off-by: Fabiano Rosas --- tests/qtest/migration/migration-util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/migration/migration-util.c b/tests/qtest/migration/migration-util.c index 525bf1eed4..401fe27f00 100644 --- a/tests/qtest/migration/migration-util.c +++ b/tests/qtest/migration/migration-util.c @@ -284,6 +284,7 @@ bool probe_o_direct_support(const char *tmpfs) buf = qemu_try_memalign(len, len); g_assert(buf); + memset(buf, 0, len); ret = pwrite(fd, buf, len, offset); unlink(filename); From a475e5de01f3d0938d73a1062d1ec7a3df37d621 Mon Sep 17 00:00:00 2001 From: Fabiano Rosas Date: Mon, 9 Dec 2024 17:44:24 -0300 Subject: [PATCH 4/8] tests/qtest/bios-tables-test: Free tables at dump_aml_files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dump_aml_files() function calls load_expected_aml() to allocate the tables but never frees it. Add the missing call to free_test_data(). Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20241209204427.17763-4-farosas@suse.de> Signed-off-by: Fabiano Rosas --- tests/qtest/bios-tables-test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index 6035ec2c61..0a333ec435 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -292,6 +292,7 @@ static void dump_aml_files(test_data *data, bool rebuild) g_free(aml_file); } + free_test_data(&exp_data); } static bool create_tmp_asl(AcpiSdtTable *sdt) From 9a9320a543704087e3f27f243de6f58af948ce56 Mon Sep 17 00:00:00 2001 From: Fabiano Rosas Date: Mon, 9 Dec 2024 17:44:25 -0300 Subject: [PATCH 5/8] tests/qtest/virtio-iommu-test: Don't pass uninitialized data into qtest_memwrite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Valgrind complains about: Use of uninitialised value of size 8 & Conditional jump or move depends on uninitialised value(s) both at: at 0x5265931: _itoa_word (_itoa.c:180) by 0x527EEC7: __vfprintf_internal (vfprintf-internal.c:1687) by 0x528C8B0: __vsprintf_internal (iovsprintf.c:96) by 0x526B920: sprintf (sprintf.c:30) by 0x1296C7: qtest_memwrite (libqtest.c:1273) by 0x193C04: send_map (virtio-iommu-test.c:125) by 0x194392: test_attach_detach (virtio-iommu-test.c:214) by 0x17BDE7: run_one_test (qos-test.c:181) by 0x4B0699D: test_case_run (gtestutils.c:2900) by 0x4B0699D: g_test_run_suite_internal (gtestutils.c:2988) by 0x4B068B2: g_test_run_suite_internal (gtestutils.c:3005) by 0x4B068B2: g_test_run_suite_internal (gtestutils.c:3005) by 0x4B068B2: g_test_run_suite_internal (gtestutils.c:3005) Uninitialised value was created by a stack allocation at 0x193AFD: send_map (virtio-iommu-test.c:103) Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20241209204427.17763-5-farosas@suse.de> Signed-off-by: Fabiano Rosas --- tests/qtest/virtio-iommu-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qtest/virtio-iommu-test.c b/tests/qtest/virtio-iommu-test.c index afb225971d..98ffa27912 100644 --- a/tests/qtest/virtio-iommu-test.c +++ b/tests/qtest/virtio-iommu-test.c @@ -105,7 +105,7 @@ static int send_map(QTestState *qts, QVirtioIOMMU *v_iommu, QVirtQueue *vq = v_iommu->vq; uint64_t ro_addr, wr_addr; uint32_t free_head; - struct virtio_iommu_req_map req; + struct virtio_iommu_req_map req = {}; size_t ro_size = sizeof(req) - sizeof(struct virtio_iommu_req_tail); size_t wr_size = sizeof(struct virtio_iommu_req_tail); struct virtio_iommu_req_tail buffer; @@ -147,7 +147,7 @@ static int send_unmap(QTestState *qts, QVirtioIOMMU *v_iommu, QVirtQueue *vq = v_iommu->vq; uint64_t ro_addr, wr_addr; uint32_t free_head; - struct virtio_iommu_req_unmap req; + struct virtio_iommu_req_unmap req = {}; size_t ro_size = sizeof(req) - sizeof(struct virtio_iommu_req_tail); size_t wr_size = sizeof(struct virtio_iommu_req_tail); struct virtio_iommu_req_tail buffer; From bc3ace691492a5aefa6e9ad1006879a30502d842 Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Mon, 16 Dec 2024 11:14:13 -0500 Subject: [PATCH 6/8] tests/migration: Drop arch_[source|target] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Coverity complained about them. These two variables are never used now after commit 832c732c5d ("migration-test: Create arch_opts"), and/or commit 34cc54fb35 ("tests/qtest/migration-test: Use custom asm bios for ppc64"). Resolves: Coverity CID 1568379 Resolves: Coverity CID 1568380 Signed-off-by: Peter Xu Reviewed-by: Alex Bennée Message-Id: <20241216161413.1644171-4-peterx@redhat.com> Signed-off-by: Fabiano Rosas --- tests/qtest/migration/framework.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/framework.c index a902936039..47ce07856e 100644 --- a/tests/qtest/migration/framework.c +++ b/tests/qtest/migration/framework.c @@ -197,8 +197,6 @@ static void cleanup(const char *filename) int migrate_start(QTestState **from, QTestState **to, const char *uri, MigrateStart *args) { - g_autofree gchar *arch_source = NULL; - g_autofree gchar *arch_target = NULL; /* options for source and target */ g_autofree gchar *arch_opts = NULL; g_autofree gchar *cmd_source = NULL; @@ -307,12 +305,11 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri, "-name source,debug-threads=on " "-m %s " "-serial file:%s/src_serial " - "%s %s %s %s %s", + "%s %s %s %s", kvm_opts ? kvm_opts : "", machine, machine_opts, memory_size, tmpfs, arch_opts ? arch_opts : "", - arch_source ? arch_source : "", shmem_opts ? shmem_opts : "", args->opts_source ? args->opts_source : "", ignore_stderr); @@ -329,12 +326,11 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri, "-m %s " "-serial file:%s/dest_serial " "-incoming %s " - "%s %s %s %s %s", + "%s %s %s %s", kvm_opts ? kvm_opts : "", machine, machine_opts, memory_size, tmpfs, uri, arch_opts ? arch_opts : "", - arch_target ? arch_target : "", shmem_opts ? shmem_opts : "", args->opts_target ? args->opts_target : "", ignore_stderr); From 06056ef1ff1e457787d277796bff927f51c092c9 Mon Sep 17 00:00:00 2001 From: Fabiano Rosas Date: Wed, 18 Dec 2024 16:22:22 -0300 Subject: [PATCH 7/8] tests/qtest/migration: Re-enable postcopy tests Postcopy tests have been inadvertently disabled since commit 124a3c58b8 ("tests/qtest/migration: Move ufd_version_check to utils"). That commit moved the ufd_version_check() function to another file but failed to make sense of the ifdefs and includes: The include was incorrectly dropped. It is needed to pull in for __NR_userfaultfd. The was moved under the wrong ifdef. Fixes: 124a3c58b8 ("tests/qtest/migration: Move ufd_version_check to utils") Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas Message-Id: <20241218192223.10551-2-farosas@suse.de> --- tests/qtest/migration/migration-util.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/qtest/migration/migration-util.c b/tests/qtest/migration/migration-util.c index 401fe27f00..526bed74ea 100644 --- a/tests/qtest/migration/migration-util.c +++ b/tests/qtest/migration/migration-util.c @@ -22,6 +22,11 @@ #include "migration/bootfile.h" #include "migration/migration-util.h" +#if defined(__linux__) +#include +#include +#endif + /* for uffd_version_check() */ #if defined(__linux__) && defined(__NR_userfaultfd) && defined(CONFIG_EVENTFD) #include @@ -31,7 +36,6 @@ /* For dirty ring test; so far only x86_64 is supported */ #if defined(__linux__) && defined(HOST_X86_64) #include "linux/kvm.h" -#include #endif From d9f2b09dd6c3030cda9af9c29e26a0bdfc02bec6 Mon Sep 17 00:00:00 2001 From: Ani Sinha Date: Wed, 1 Jan 2025 13:45:55 +0530 Subject: [PATCH 8/8] qtest/fw-cfg: remove compiled out code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove code that is already compiled out. This prevents confusion. CC: qemu-trivial@nongnu.org Signed-off-by: Ani Sinha Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20250101081555.1050736-1-anisinha@redhat.com> Signed-off-by: Fabiano Rosas --- tests/qtest/fw_cfg-test.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/qtest/fw_cfg-test.c b/tests/qtest/fw_cfg-test.c index 5dc807ba23..e48b34afa5 100644 --- a/tests/qtest/fw_cfg-test.c +++ b/tests/qtest/fw_cfg-test.c @@ -243,12 +243,6 @@ int main(int argc, char **argv) qtest_add_func("fw_cfg/ram_size", test_fw_cfg_ram_size); qtest_add_func("fw_cfg/nographic", test_fw_cfg_nographic); qtest_add_func("fw_cfg/nb_cpus", test_fw_cfg_nb_cpus); -#if 0 - qtest_add_func("fw_cfg/machine_id", test_fw_cfg_machine_id); - qtest_add_func("fw_cfg/kernel", test_fw_cfg_kernel); - qtest_add_func("fw_cfg/initrd", test_fw_cfg_initrd); - qtest_add_func("fw_cfg/boot_device", test_fw_cfg_boot_device); -#endif qtest_add_func("fw_cfg/max_cpus", test_fw_cfg_max_cpus); qtest_add_func("fw_cfg/numa", test_fw_cfg_numa); qtest_add_func("fw_cfg/boot_menu", test_fw_cfg_boot_menu);