[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/34] tests/qtest/migration-test: Fix bootfile cleanup handling
From: |
Fabiano Rosas |
Subject: |
[PULL 03/34] tests/qtest/migration-test: Fix bootfile cleanup handling |
Date: |
Wed, 4 Sep 2024 09:43:46 -0300 |
From: Peter Maydell <peter.maydell@linaro.org>
If you invoke the migration-test binary in such a way that it doesn't run
any tests, then we never call bootfile_create(), and at the end of
main() bootfile_delete() will try to unlink(NULL), which is not valid.
This can happen if for instance you tell the test binary to run a
subset of tests that turns out to be empty, like this:
(cd build/asan && QTEST_QEMU_BINARY=./qemu-system-x86_64
./tests/qtest/migration-test --tap -k -p bang)
# random seed: R02S6501b289ff8ced4231ba452c3a87bc6f
# Skipping test: userfaultfd not available
1..0
../../tests/qtest/migration-test.c:182:12: runtime error: null pointer passed
as argument 1, which is declared to never be null
/usr/include/unistd.h:858:48: note: nonnull attribute specified here
Handle this by making bootfile_delete() not needing to do anything
because bootfile_create() was never called.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
[fixed conflict with aee07f2563]
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
tests/qtest/migration-test.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 334b63cbaa..37ef99c980 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -145,6 +145,9 @@ static char *bootpath;
static void bootfile_delete(void)
{
+ if (!bootpath) {
+ return;
+ }
unlink(bootpath);
g_free(bootpath);
bootpath = NULL;
@@ -156,10 +159,7 @@ static void bootfile_create(char *dir, bool suspend_me)
unsigned char *content;
size_t len;
- if (bootpath) {
- bootfile_delete();
- }
-
+ bootfile_delete();
bootpath = g_strdup_printf("%s/bootsect", dir);
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
/* the assembled x86 boot sector should be exactly one sector large */
--
2.35.3
- [PULL 00/34] Migration patches for 2024-09-04, Fabiano Rosas, 2024/09/04
- [PULL 01/34] migration: delete unused parameter mis, Fabiano Rosas, 2024/09/04
- [PULL 02/34] tests/qtest/migration: Remove vmstate-static-checker test, Fabiano Rosas, 2024/09/04
- [PULL 03/34] tests/qtest/migration-test: Fix bootfile cleanup handling,
Fabiano Rosas <=
- [PULL 04/34] tests/qtest/migration-test: Don't leak resp in multifd_mapped_ram_fdset_end(), Fabiano Rosas, 2024/09/04
- [PULL 05/34] tests/qtest/migration-test: Fix leaks in calc_dirtyrate_ready(), Fabiano Rosas, 2024/09/04
- [PULL 06/34] tests/qtest/migration-helpers: Fix migrate_get_socket_address() leak, Fabiano Rosas, 2024/09/04
- [PULL 07/34] tests/qtest/migration-test: Free QCRyptoTLSTestCertReq objects, Fabiano Rosas, 2024/09/04
- [PULL 08/34] tests/unit/crypto-tls-x509-helpers: deinit privkey in test_tls_cleanup, Fabiano Rosas, 2024/09/04
- [PULL 09/34] tests/qtest/migration-helpers: Don't dup argument to qdict_put_str(), Fabiano Rosas, 2024/09/04
- [PULL 11/34] tests/qtest/migration-test: Don't leak QTestState in test_multifd_tcp_cancel(), Fabiano Rosas, 2024/09/04
- [PULL 10/34] tests/qtest/migration-test: Don't strdup in get_dirty_rate(), Fabiano Rosas, 2024/09/04
- [PULL 15/34] migration/multifd: Pass in MultiFDPages_t to file_write_ramblock_iov, Fabiano Rosas, 2024/09/04
- [PULL 16/34] migration/multifd: Introduce MultiFDSendData, Fabiano Rosas, 2024/09/04