tests: fix tpm-crb tpm-tis tests race
PATCH 1/1 tests: fix tpm-crb tpm-tis tests race
No need to close the TPM data socket on the emulator end, qemu will close it after a SHUTDOWN. This avoids a race between close() and read() in the TPM data thread.
--- tests/tpm-emu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/tpm-emu.c +1 -1
@@ -125,7 +125,7 @@ void *tpm_emu_ctrl_thread(void *data)case CMD_SHUTDOWN : {ptm_res res =0 ;qio_channel_write (ioc, (char *)&res,sizeof (res), &error_abort); -qio_channel_close (s->tpm_ioc, &error_abort); +/* the tpm data thread is expected to finish now */ g_thread_join (s->emu_tpm_thread);break ; }
Signature · 1 line
2.16.2.521.g9aa15f885a
Quoted 15 lines · Marc-André Lureau
No need to close the TPM data socket on the emulator end, qemu will close it after a SHUTDOWN. This avoids a race between
close()andread()in the TPM data thread.Reported-by Peter Maydell <[email protected]>Signed-off-by Marc-André Lureau <[email protected]>--- tests/tpm-emu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/tpm-emu.c +0
-0
tests/tpm-emu.c void *tpm_emu_ctrl_thread(void *data) · line 129
Quoted 6 lines
tests/tpm-emu.c +1
-1@@ -125,7 +125,7 @@ void *tpm_emu_ctrl_thread(void *data)case CMD_SHUTDOWN : {ptm_res res =0 ;qio_channel_write (ioc, (char *)&res,sizeof (res), &error_abort); -qio_channel_close (s->tpm_ioc, &error_abort); +/* the tpm data thread is expected to finish now */ g_thread_join (s->emu_tpm_thread);
Won't this leave an orphaed FD open in the test suite ? Is it perhaps sufficient to just swap the order of the g_thread_join and qio_channel_close calls, so that we join the thread before we close the channel that the thread is using ?
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Hi
Quoted 11 lines · Daniel P. Berrangé
Quoted 10 lines · Marc-André Lureau
No need to close the TPM data socket on the emulator end, qemu will close it after a SHUTDOWN. This avoids a race between
close()andread()in the TPM data thread.Reported-by Peter Maydell <[email protected]>Signed-off-by Marc-André Lureau <[email protected]>--- tests/tpm-emu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
tests/tpm-emu.c void *tpm_emu_ctrl_thread(void *data) · line 129
Quoted 11 lines
tests/tpm-emu.c +1
-1@@ -125,7 +125,7 @@ void *tpm_emu_ctrl_thread(void *data)case CMD_SHUTDOWN : {ptm_res res =0 ;qio_channel_write (ioc, (char *)&res,sizeof (res), &error_abort); -qio_channel_close (s->tpm_ioc, &error_abort); +/* the tpm data thread is expected to finish now */ g_thread_join (s->emu_tpm_thread);Won't this leave an orphaed FD open in the test suite ? Is it perhaps sufficient to just swap the order of the
g_thread_joinandqio_channel_closecalls, so that we join the thread before we close the channel that the thread is using ?
Isn't the socket close on the last unref? (at end of tpm_emu_tpm_thread())
Quoted 8 lines
Regards,
Daniel
--|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Signature · 1 line
Marc-André Lureau
Daniel P. Berrangé
Reviewed-byQuoted 31 lines · Marc-André Lureau
Hi
Quoted 11 lines · Daniel P. Berrangé
Quoted 10 lines · Marc-André Lureau
No need to close the TPM data socket on the emulator end, qemu will close it after a SHUTDOWN. This avoids a race between
close()andread()in the TPM data thread.Reported-by Peter Maydell <[email protected]>Signed-off-by Marc-André Lureau <[email protected]>--- tests/tpm-emu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 16 lines
tests/tpm-emu.c void *tpm_emu_ctrl_thread(void *data) · line 129
Quoted 11 lines
tests/tpm-emu.c +1
-1@@ -125,7 +125,7 @@ void *tpm_emu_ctrl_thread(void *data)case CMD_SHUTDOWN : {ptm_res res =0 ;qio_channel_write (ioc, (char *)&res,sizeof (res), &error_abort); -qio_channel_close (s->tpm_ioc, &error_abort); +/* the tpm data thread is expected to finish now */ g_thread_join (s->emu_tpm_thread);Won't this leave an orphaed FD open in the test suite ? Is it perhaps sufficient to just swap the order of the
g_thread_joinandqio_channel_closecalls, so that we join the thread before we close the channel that the thread is using ?
Quoted 1 line
Isn't the socket close on the last unref? (at end of
tpm_emu_tpm_thread())
Oh yes, that is true. I should have looked at more than just diff context. In that case
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Stefan Berger
Reviewed-byQuoted 30 lines · Daniel P. Berrangé
Quoted 29 lines · Marc-André Lureau
Hi
Quoted 26 lines · Daniel P. Berrangé
Quoted 15 lines · Marc-André Lureau
No need to close the TPM data socket on the emulator end, qemu will close it after a SHUTDOWN. This avoids a race between
close()andread()in the TPM data thread.Reported-by Peter Maydell <[email protected]>Signed-off-by Marc-André Lureau <[email protected]>--- tests/tpm-emu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/tpm-emu.c +0
-0tests/tpm-emu.c void *tpm_emu_ctrl_thread(void *data) · line 129
Quoted 6 lines
tests/tpm-emu.c +1
-1@@ -125,7 +125,7 @@ void *tpm_emu_ctrl_thread(void *data)case CMD_SHUTDOWN : {ptm_res res =0 ;qio_channel_write (ioc, (char *)&res,sizeof (res), &error_abort); -qio_channel_close (s->tpm_ioc, &error_abort); +/* the tpm data thread is expected to finish now */ g_thread_join (s->emu_tpm_thread);Won't this leave an orphaed FD open in the test suite ? Is it perhaps sufficient to just swap the order of the
g_thread_joinandqio_channel_closecalls, so that we join the thread before we close the channel that the thread is using ?
Quoted 5 lines
Quoted 1 line
Isn't the socket close on the last unref? (at end of
tpm_emu_tpm_thread())Oh yes, that is true. I should have looked at more than just diff context. In that case
Reviewed-by Daniel P. Berrangé <[email protected]>
Ha. It's already done :-)
Quoted 3 lines
Regards,
Daniel
Quoted 6 lines · Marc-André Lureau
No need to close the TPM data socket on the emulator end, qemu will close it after a SHUTDOWN. This avoids a race between
close()andread()in the TPM data thread.Reported-by Peter Maydell <[email protected]>Signed-off-by Marc-André Lureau <[email protected]>
Quoted 9 lines
--- tests/tpm-emu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/tpm-emu.c +0
-0
tests/tpm-emu.c void *tpm_emu_ctrl_thread(void *data) · line 131
Quoted 8 lines
tests/tpm-emu.c +1
-1@@ -125,7 +125,7 @@ void *tpm_emu_ctrl_thread(void *data)case CMD_SHUTDOWN : {ptm_res res =0 ;qio_channel_write (ioc, (char *)&res,sizeof (res), &error_abort); -qio_channel_close (s->tpm_ioc, &error_abort); +/* the tpm data thread is expected to finish now */ g_thread_join (s->emu_tpm_thread);break ; }
--
Alex Bennée