qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Stefan Berger <stefanb@linux.ibm.com>
Cc: qemu-devel@nongnu.org, marcandre.lureau@redhat.com,
	peter.maydell@linaro.org
Subject: Re: [PATCH] tests/qtest/tpm-emu: Avoid hangs using abort handlers closing channels
Date: Wed, 11 Jan 2023 13:32:24 +0000	[thread overview]
Message-ID: <Y766aNAJqcIhg+yw@redhat.com> (raw)
In-Reply-To: <20230111133023.3958587-1-stefanb@linux.ibm.com>

On Wed, Jan 11, 2023 at 08:30:23AM -0500, Stefan Berger wrote:
> 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.
> 
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
>  tests/qtest/tpm-emu.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/tests/qtest/tpm-emu.c b/tests/qtest/tpm-emu.c
> index 2994d1cf42..5740cab950 100644
> --- a/tests/qtest/tpm-emu.c
> +++ b/tests/qtest/tpm-emu.c
> @@ -36,11 +36,18 @@ void tpm_emu_test_wait_cond(TPMTestState *s)
>      g_mutex_unlock(&s->data_mutex);
>  }
>  
> +static void tpm_emu_close_data_ioc(void *ioc)
> +{
> +    qio_channel_close(ioc, NULL);
> +}

We could actually just call it tpm_emu_close_ioc and
refer to it from both places....

> +
>  static void *tpm_emu_tpm_thread(void *data)
>  {
>      TPMTestState *s = data;
>      QIOChannel *ioc = s->tpm_ioc;
>  
> +    qtest_add_abrt_handler(tpm_emu_close_data_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,12 +84,18 @@ 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));
>      return NULL;
>  }
>  
> +static void tpm_emu_close_ctrl_ioc(void *ioc)
> +{
> +    qio_channel_close(ioc, NULL);
> +}

... as this code is identical.

> +
>  void *tpm_emu_ctrl_thread(void *data)
>  {
>      TPMTestState *s = data;
> @@ -99,6 +112,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_ctrl_ioc, ioc);
>  
>      {
>          uint32_t cmd = 0;
> @@ -190,6 +204,7 @@ void *tpm_emu_ctrl_thread(void *data)
>          }
>      }
>  
> +    qtest_remove_abrt_handler(ioc);
>      object_unref(OBJECT(ioc));
>      object_unref(OBJECT(lioc));
>      return NULL;
> -- 
> 2.39.0
> 

With 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 :|



      reply	other threads:[~2023-01-11 13:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11 13:30 [PATCH] tests/qtest/tpm-emu: Avoid hangs using abort handlers closing channels Stefan Berger
2023-01-11 13:32 ` Daniel P. Berrangé [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y766aNAJqcIhg+yw@redhat.com \
    --to=berrange@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanb@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).