* [Qemu-devel] [PATCH] tests: fix tpm-crb tpm-tis tests race
@ 2018-03-16 14:22 Marc-André Lureau
2018-03-16 14:25 ` Daniel P. Berrangé
2018-05-18 16:12 ` Alex Bennée
0 siblings, 2 replies; 9+ messages in thread
From: Marc-André Lureau @ 2018-03-16 14:22 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, berrange, stefanb, 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() and
read() in the TPM data thread.
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
tests/tpm-emu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/tpm-emu.c b/tests/tpm-emu.c
index 4dada76834..8c2bd53cad 100644
--- a/tests/tpm-emu.c
+++ b/tests/tpm-emu.c
@@ -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;
}
--
2.16.2.521.g9aa15f885a
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] tests: fix tpm-crb tpm-tis tests race
2018-03-16 14:22 Marc-André Lureau
@ 2018-03-16 14:25 ` Daniel P. Berrangé
2018-03-16 14:29 ` Marc-André Lureau
2018-05-18 16:12 ` Alex Bennée
1 sibling, 1 reply; 9+ messages in thread
From: Daniel P. Berrangé @ 2018-03-16 14:25 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel, peter.maydell, stefanb
On Fri, Mar 16, 2018 at 03:22:23PM +0100, Marc-André Lureau wrote:
> 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.
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> tests/tpm-emu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/tpm-emu.c b/tests/tpm-emu.c
> index 4dada76834..8c2bd53cad 100644
> --- a/tests/tpm-emu.c
> +++ b/tests/tpm-emu.c
> @@ -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
--
|: 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 :|
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] tests: fix tpm-crb tpm-tis tests race
2018-03-16 14:25 ` Daniel P. Berrangé
@ 2018-03-16 14:29 ` Marc-André Lureau
2018-03-16 14:30 ` Daniel P. Berrangé
0 siblings, 1 reply; 9+ messages in thread
From: Marc-André Lureau @ 2018-03-16 14:29 UTC (permalink / raw)
To: Daniel P. Berrangé; +Cc: Peter Maydell, QEMU, Stefan Berger
Hi
On Fri, Mar 16, 2018 at 3:25 PM, Daniel P. Berrangé <berrange@redhat.com> wrote:
> On Fri, Mar 16, 2018 at 03:22:23PM +0100, Marc-André Lureau wrote:
>> 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.
>>
>> Reported-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> ---
>> tests/tpm-emu.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tests/tpm-emu.c b/tests/tpm-emu.c
>> index 4dada76834..8c2bd53cad 100644
>> --- a/tests/tpm-emu.c
>> +++ b/tests/tpm-emu.c
>> @@ -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 ?
Isn't the socket close on the last unref? (at end of tpm_emu_tpm_thread())
>
> 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 :|
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] tests: fix tpm-crb tpm-tis tests race
2018-03-16 14:29 ` Marc-André Lureau
@ 2018-03-16 14:30 ` Daniel P. Berrangé
2018-03-16 14:40 ` Stefan Berger
0 siblings, 1 reply; 9+ messages in thread
From: Daniel P. Berrangé @ 2018-03-16 14:30 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: Peter Maydell, QEMU, Stefan Berger
On Fri, Mar 16, 2018 at 03:29:04PM +0100, Marc-André Lureau wrote:
> Hi
>
> On Fri, Mar 16, 2018 at 3:25 PM, Daniel P. Berrangé <berrange@redhat.com> wrote:
> > On Fri, Mar 16, 2018 at 03:22:23PM +0100, Marc-André Lureau wrote:
> >> 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.
> >>
> >> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> >> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> >> ---
> >> tests/tpm-emu.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/tests/tpm-emu.c b/tests/tpm-emu.c
> >> index 4dada76834..8c2bd53cad 100644
> >> --- a/tests/tpm-emu.c
> >> +++ b/tests/tpm-emu.c
> >> @@ -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 ?
>
> 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é <berrange@redhat.com>
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 :|
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] tests: fix tpm-crb tpm-tis tests race
2018-03-16 14:30 ` Daniel P. Berrangé
@ 2018-03-16 14:40 ` Stefan Berger
0 siblings, 0 replies; 9+ messages in thread
From: Stefan Berger @ 2018-03-16 14:40 UTC (permalink / raw)
To: qemu-devel
On 03/16/2018 10:30 AM, Daniel P. Berrangé wrote:
> On Fri, Mar 16, 2018 at 03:29:04PM +0100, Marc-André Lureau wrote:
>> Hi
>>
>> On Fri, Mar 16, 2018 at 3:25 PM, Daniel P. Berrangé <berrange@redhat.com> wrote:
>>> On Fri, Mar 16, 2018 at 03:22:23PM +0100, Marc-André Lureau wrote:
>>>> 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.
>>>>
>>>> Reported-by: Peter Maydell <peter.maydell@linaro.org>
>>>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>>> ---
>>>> tests/tpm-emu.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/tests/tpm-emu.c b/tests/tpm-emu.c
>>>> index 4dada76834..8c2bd53cad 100644
>>>> --- a/tests/tpm-emu.c
>>>> +++ b/tests/tpm-emu.c
>>>> @@ -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 ?
>> 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é <berrange@redhat.com>
Ha. It's already done :-)
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
>
> Regards,
> Daniel
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH] tests: fix tpm-crb tpm-tis tests race
@ 2018-05-08 15:29 Stefan Berger
2018-05-08 15:30 ` Daniel P. Berrangé
0 siblings, 1 reply; 9+ messages in thread
From: Stefan Berger @ 2018-05-08 15:29 UTC (permalink / raw)
To: qemu-trivial
Cc: qemu-devel, f4bug, berrange, Marc-André Lureau,
Stefan Berger
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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.
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
tests/tpm-emu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/tpm-emu.c b/tests/tpm-emu.c
index 4dada76..8c2bd53 100644
--- a/tests/tpm-emu.c
+++ b/tests/tpm-emu.c
@@ -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;
}
--
2.5.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] tests: fix tpm-crb tpm-tis tests race
2018-05-08 15:29 [Qemu-devel] [PATCH] tests: fix tpm-crb tpm-tis tests race Stefan Berger
@ 2018-05-08 15:30 ` Daniel P. Berrangé
0 siblings, 0 replies; 9+ messages in thread
From: Daniel P. Berrangé @ 2018-05-08 15:30 UTC (permalink / raw)
To: Stefan Berger; +Cc: qemu-trivial, qemu-devel, f4bug, Marc-André Lureau
On Tue, May 08, 2018 at 11:29:35AM -0400, Stefan Berger wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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.
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> ---
> tests/tpm-emu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>
> diff --git a/tests/tpm-emu.c b/tests/tpm-emu.c
> index 4dada76..8c2bd53 100644
> --- a/tests/tpm-emu.c
> +++ b/tests/tpm-emu.c
> @@ -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;
> }
> --
> 2.5.5
>
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 :|
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] tests: fix tpm-crb tpm-tis tests race
2018-03-16 14:22 Marc-André Lureau
2018-03-16 14:25 ` Daniel P. Berrangé
@ 2018-05-18 16:12 ` Alex Bennée
1 sibling, 0 replies; 9+ messages in thread
From: Alex Bennée @ 2018-05-18 16:12 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel, peter.maydell, stefanb
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> 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.
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> tests/tpm-emu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/tpm-emu.c b/tests/tpm-emu.c
> index 4dada76834..8c2bd53cad 100644
> --- a/tests/tpm-emu.c
> +++ b/tests/tpm-emu.c
> @@ -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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH] tests: fix tpm-crb tpm-tis tests race
@ 2018-05-31 17:28 Stefan Berger
0 siblings, 0 replies; 9+ messages in thread
From: Stefan Berger @ 2018-05-31 17:28 UTC (permalink / raw)
To: qemu-stable, Michael Roth; +Cc: qemu-devel
Please apply the following commit to QEMU 2.12:
commit 7647d5c6b5e3b3f36a6e0441c81ae3fe797eb233
Author: Marc-André Lureau <marcandre.lureau@redhat.com>
Date: Tue May 8 11:29:35 2018 -0400
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.
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/tests/tpm-emu.c b/tests/tpm-emu.c
index 4dada76834..8c2bd53cad 100644
--- a/tests/tpm-emu.c
+++ b/tests/tpm-emu.c
@@ -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;
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-05-31 17:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-08 15:29 [Qemu-devel] [PATCH] tests: fix tpm-crb tpm-tis tests race Stefan Berger
2018-05-08 15:30 ` Daniel P. Berrangé
-- strict thread matches above, loose matches on Subject: below --
2018-05-31 17:28 Stefan Berger
2018-03-16 14:22 Marc-André Lureau
2018-03-16 14:25 ` Daniel P. Berrangé
2018-03-16 14:29 ` Marc-André Lureau
2018-03-16 14:30 ` Daniel P. Berrangé
2018-03-16 14:40 ` Stefan Berger
2018-05-18 16:12 ` Alex Bennée
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).