diff options
| author | Stefan Hajnoczi <stefanha@redhat.com> | 2021-02-23 14:46:44 +0000 |
|---|---|---|
| committer | Kevin Wolf <kwolf@redhat.com> | 2021-03-08 14:55:19 +0100 |
| commit | 7a23c523762371fd26a7a9ecfa8f16b64618a1ad (patch) | |
| tree | 23ad3d2f2b05a905a0b532b643c90df73946713d /tests/qtest/libqtest.c | |
| parent | 9fb7bb06986741b7fd8427fac9f22177ca38dcff (diff) | |
| download | focaccia-qemu-7a23c523762371fd26a7a9ecfa8f16b64618a1ad.tar.gz focaccia-qemu-7a23c523762371fd26a7a9ecfa8f16b64618a1ad.zip | |
libqtest: add qtest_kill_qemu()
Tests that manage multiple processes may wish to kill QEMU before destroying the QTestState. Expose a function to do that. The vhost-user-blk-test testcase will need this. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Message-Id: <20210223144653.811468-4-stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests/qtest/libqtest.c')
| -rw-r--r-- | tests/qtest/libqtest.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index b19d2ebda0..2a98de2907 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -133,7 +133,7 @@ void qtest_set_expected_status(QTestState *s, int status) s->expected_status = status; } -static void kill_qemu(QTestState *s) +void qtest_kill_qemu(QTestState *s) { pid_t pid = s->qemu_pid; int wstatus; @@ -143,6 +143,7 @@ static void kill_qemu(QTestState *s) kill(pid, SIGTERM); TFR(pid = waitpid(s->qemu_pid, &s->wstatus, 0)); assert(pid == s->qemu_pid); + s->qemu_pid = -1; } /* @@ -169,7 +170,7 @@ static void kill_qemu(QTestState *s) static void kill_qemu_hook_func(void *s) { - kill_qemu(s); + qtest_kill_qemu(s); } static void sigabrt_handler(int signo) @@ -373,7 +374,7 @@ void qtest_quit(QTestState *s) /* Uninstall SIGABRT handler on last instance */ cleanup_sigabrt_handler(); - kill_qemu(s); + qtest_kill_qemu(s); close(s->fd); close(s->qmp_fd); g_string_free(s->rx, true); |