Merge tpm 2023/01/17 v1
Hello,
this PR addresses issues where QEMU may hang during test runs.
Regards,
Stefan
The following changes since commit fb7e7990342e59cf67dbd895c1a1e3fb1741df7a:
tests/qtest/qom-test: Do not print tested properties by default (2023-01-16 15:00:57 +0000)
are available in the Git repository at:
https://github.com/stefanberger/qemu-tpm.git pull-tpm-2023-01-17-1
for you to fetch changes up to 255b00b4def7bac1fd313adca931426f4eb10b05:
tests/qtest/tpm-emu: Avoid hangs using abort handlers closing channels (2023-01-16 17:19:52 -0500)
Stefan Berger (2):
tests/qtest: Poll on waitpid() for a while before sending SIGKILL tests/qtest/tpm-emu: Avoid hangs using abort handlers closing channels
tests/qtest/libqtest.c | 20 +++++++++++++++++++- tests/qtest/tpm-emu.c | 10 ++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-)
Signature · 1 line
2.39.0
[PULL v1 2/2] tests/qtest/tpm-emu: Avoid hangs using abort handlers closing channels
Install abort handlers that close the TPM control and data channels in case an abort occurs. The purpose of this is to have QEMU terminate under abnormal test case failures to resolve intermittent hangs on s390x hosts running TPM tests for QEMU/x86_64.
Message-id: [email protected]
--- tests/qtest/tpm-emu.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
tests/qtest/tpm-emu.c +10 -0
@@ -36,11 +36,18 @@ void tpm_emu_test_wait_cond(TPMTestState *s)g_mutex_unlock (&s->data_mutex); } +static void tpm_emu_close_ioc (void *ioc) +{ +qio_channel_close (ioc,NULL ); +} +static void *tpm_emu_tpm_thread (void *data) {TPMTestState *s = data;QIOChannel *ioc = s->tpm_ioc; +qtest_add_abrt_handler (tpm_emu_close_ioc, ioc); + s->tpm_msg = g_new(struct tpm_hdr, 1);while (true) {int minhlen =sizeof (s->tpm_msg->tag) +sizeof (s->tpm_msg->len);
@@ -77,6 +84,7 @@ static void *tpm_emu_tpm_thread(void *data) &error_abort); } +qtest_remove_abrt_handler (ioc);g_free (s->tpm_msg); s->tpm_msg =NULL ;object_unref (OBJECT (s->tpm_ioc));
@@ -99,6 +107,7 @@ void *tpm_emu_ctrl_thread(void *data)qio_channel_wait (QIO_CHANNEL (lioc),G_IO_IN ); ioc =QIO_CHANNEL (qio_channel_socket_accept (lioc, &error_abort));g_assert (ioc); +qtest_add_abrt_handler (tpm_emu_close_ioc, ioc); {uint32_t cmd =0 ;
@@ -190,6 +199,7 @@ void *tpm_emu_ctrl_thread(void *data) } } +qtest_remove_abrt_handler (ioc);object_unref (OBJECT (ioc));object_unref (OBJECT (lioc));return NULL ;
Signature · 1 line
2.39.0
[PULL v1 1/2] tests/qtest: Poll on waitpid() for a while before sending SIGKILL
In reply to Stefan BergerTo prevent getting stuck on waitpid() in case the target process does not terminate on SIGTERM, poll on waitpid() for 30s and if the target process has not changed state until then send a SIGKILL to it.
Message-id: [email protected] [PMM: changed TFR to RETRY_ON_EINTR]
--- tests/qtest/libqtest.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
tests/qtest/libqtest.c +19 -1
@@ -49,6 +49,8 @@# define DEV_NULL "nul"#endif +#define WAITPID_TIMEOUT 30 +typedef void (*QTestSendFn )(QTestState *s,const char *buf);typedef void (*ExternalSendFn )(void *s,const char *buf);typedef GString * (*QTestRecvFn )(QTestState *);
@@ -202,8 +204,24 @@ void qtest_wait_qemu(QTestState *s) {#ifndef _WIN32pid_t pid; +uint64_t end; + +/* poll for a while until sending SIGKILL */ + end =g_get_monotonic_time () +WAITPID_TIMEOUT *G_TIME_SPAN_SECOND ; + +do { + pid =waitpid (s->qemu_pid, &s->wstatus,WNOHANG ); +if (pid !=0 ) { +break ; + } +g_usleep (100 *1000 ); + }while (g_get_monotonic_time () < end); + +if (pid ==0 ) { +kill (s->qemu_pid,SIGKILL ); + pid =RETRY_ON_EINTR (waitpid (s->qemu_pid, &s->wstatus,0 )); + } - pid =RETRY_ON_EINTR (waitpid (s->qemu_pid, &s->wstatus,0 ));assert (pid == s->qemu_pid);#else DWORD ret;
Signature · 1 line
2.39.0
Peter Maydell
AppliedQuoted 12 lines · Stefan Berger
Hello,
this PR addresses issues where QEMU may hang during test runs.
Regards,
StefanThe following changes since commit
fb7e7990342e59cf67dbd895c1a1e3fb1741df7a:tests/qtest/qom-test: Do not print tested properties by default (2023-01-16 15:00:57 +0000)
Quoted 8 lines
are available in the Git repository at:
https://github.com/stefanberger/qemu-tpm.git pull-tpm-2023-01-17-1
for you to fetch changes up to
255b00b4def7bac1fd313adca931426f4eb10b05:tests/qtest/tpm-emu: Avoid hangs using abort handlers closing channels (2023-01-16 17:19:52 -0500)
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/8.0
for any user-visible changes.
-- PMM