qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH-for-5.1 1/2] tpm: Display when no backend is available
Date: Wed, 22 Jul 2020 10:57:56 -0400	[thread overview]
Message-ID: <d828c539-2ca4-5e33-bccf-5ad047d48eae@linux.ibm.com> (raw)
In-Reply-To: <20200722112333.29966-2-philmd@redhat.com>

On 7/22/20 7:23 AM, Philippe Mathieu-Daudé wrote:
> Display "No TPM backend available in this binary." error when
> no backend is available.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>   tpm.c | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
>
> diff --git a/tpm.c b/tpm.c
> index fe03b24858..e36803a64d 100644
> --- a/tpm.c
> +++ b/tpm.c
> @@ -41,6 +41,22 @@ tpm_be_find_by_type(enum TpmType type)
>       return TPM_BACKEND_CLASS(oc);
>   }
>   
> +/*
> + * Walk the list of available TPM backend drivers and count them.
> + */
> +static int tpm_backend_drivers_count(void)
> +{
> +    int count = 0, i;
> +
> +    for (i = 0; i < TPM_TYPE__MAX; i++) {
> +        const TPMBackendClass *bc = tpm_be_find_by_type(i);
> +        if (bc) {
> +            count++;
> +        }
> +    }
> +    return count;
> +}
> +
>   /*
>    * Walk the list of available TPM backend drivers and display them on the
>    * screen.
> @@ -87,6 +103,11 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp)
>       TPMBackend *drv;
>       int i;
>   
> +    if (!tpm_backend_drivers_count()) {
> +        error_setg(errp, "No TPM backend available in this binary.");
> +        return 1;
> +    }
> +
>       if (!QLIST_EMPTY(&tpm_backends)) {
>           error_setg(errp, "Only one TPM is allowed.");
>           return 1;


Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>




  reply	other threads:[~2020-07-22 14:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22 11:23 [PATCH-for-5.1 0/2] tpm: Improve error reporting Philippe Mathieu-Daudé
2020-07-22 11:23 ` [PATCH-for-5.1 1/2] tpm: Display when no backend is available Philippe Mathieu-Daudé
2020-07-22 14:57   ` Stefan Berger [this message]
2020-07-23 10:40   ` Markus Armbruster
2020-07-22 11:23 ` [RFC PATCH-for-5.1 2/2] tpm: List the available TPM backends Philippe Mathieu-Daudé
2020-07-22 21:44   ` Stefan Berger
2020-07-23 10:34     ` Philippe Mathieu-Daudé
2020-07-23 10:59   ` Markus Armbruster

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=d828c539-2ca4-5e33-bccf-5ad047d48eae@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=armbru@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).