diff options
| author | Steve Sistare <steven.sistare@oracle.com> | 2025-10-01 08:34:03 -0700 |
|---|---|---|
| committer | Fabiano Rosas <farosas@suse.de> | 2025-10-01 17:09:22 -0300 |
| commit | bf64633510b2a13268425a3eb78500bc88898bb8 (patch) | |
| tree | 291772eae39a141135e6496dcc0ffe39206817c1 /tests | |
| parent | b4a21e457409f972abca2818d78cdf22d59544f5 (diff) | |
| download | focaccia-qemu-bf64633510b2a13268425a3eb78500bc88898bb8.tar.gz focaccia-qemu-bf64633510b2a13268425a3eb78500bc88898bb8.zip | |
tests/qtest: qtest_create_test_state
Refactor qtest_spawn_qemu and create a subroutine to create a QTestState object, to be used in a subsequent patch. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> Reviewed-by: Fabiano Rosas <farosas@suse.de> Link: https://lore.kernel.org/qemu-devel/1759332851-370353-12-git-send-email-steven.sistare@oracle.com Signed-off-by: Fabiano Rosas <farosas@suse.de>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/qtest/libqtest.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 551bc8c1b8..3fa93172c1 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -409,22 +409,29 @@ static pid_t qtest_create_process(char *cmd) } #endif /* _WIN32 */ -static QTestState *qtest_spawn_qemu(const char *qemu_bin, const char *args) +static QTestState *qtest_create_test_state(int pid) { QTestState *s = g_new0(QTestState, 1); + + s->qemu_pid = pid; + qtest_add_abrt_handler(kill_qemu_hook_func, s); + return s; +} + +static QTestState *qtest_spawn_qemu(const char *qemu_bin, const char *args) +{ + int pid; g_autoptr(GString) command = g_string_new(""); g_string_printf(command, CMD_EXEC "%s %s", qemu_bin, args); - qtest_add_abrt_handler(kill_qemu_hook_func, s); - if (!silence_spawn_log) { g_test_message("starting QEMU: %s", command->str); } #ifndef _WIN32 - s->qemu_pid = fork(); - if (s->qemu_pid == 0) { + pid = fork(); + if (pid == 0) { #ifdef __linux__ /* * Although we register a ABRT handler to kill off QEMU @@ -447,10 +454,10 @@ static QTestState *qtest_spawn_qemu(const char *qemu_bin, const char *args) exit(1); } #else - s->qemu_pid = qtest_create_process(command->str); + pid = qtest_create_process(command->str); #endif /* _WIN32 */ - return s; + return qtest_create_test_state(pid); } static char *qtest_socket_path(const char *suffix) |