From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: philmd@redhat.com, stefanb@linux.ibm.com
Subject: [PATCH for-5.1 2/2] tpm: Improve help on TPM types when none are available
Date: Thu, 23 Jul 2020 13:58:45 +0200 [thread overview]
Message-ID: <20200723115845.1865886-3-armbru@redhat.com> (raw)
In-Reply-To: <20200723115845.1865886-1-armbru@redhat.com>
Help is a bit awkward when no TPM types are built into QEMU:
$ upstream-qemu -tpmdev nonexistent,id=tpm0
upstream-qemu: -tpmdev nonexistent,id=tpm0: Parameter 'type' expects a TPM backend type
Supported TPM types (choose only one):
Improve to
upstream-qemu: -tpmdev nonexistent,id=tpm0: Parameter 'type' expects a TPM backend type
No TPM backend types are available
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
tpm.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/tpm.c b/tpm.c
index f6045bb6da..cab206355a 100644
--- a/tpm.c
+++ b/tpm.c
@@ -47,18 +47,23 @@ tpm_be_find_by_type(enum TpmType type)
*/
static void tpm_display_backend_drivers(void)
{
+ bool got_one = false;
int i;
- fprintf(stderr, "Supported TPM types (choose only one):\n");
-
for (i = 0; i < TPM_TYPE__MAX; i++) {
const TPMBackendClass *bc = tpm_be_find_by_type(i);
if (!bc) {
continue;
}
- fprintf(stderr, "%12s %s\n", TpmType_str(i), bc->desc);
+ if (!got_one) {
+ error_printf("Supported TPM types (choose only one):\n");
+ got_one = true;
+ }
+ error_printf("%12s %s\n", TpmType_str(i), bc->desc);
+ }
+ if (!got_one) {
+ error_printf("No TPM backend types are available\n");
}
- fprintf(stderr, "\n");
}
/*
--
2.26.2
next prev parent reply other threads:[~2020-07-23 12:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-23 11:58 [PATCH for-5.1 0/2] tpm: Fix error reporting, improve help Markus Armbruster
2020-07-23 11:58 ` [PATCH for-5.1 1/2] Revert "tpm: Clean up error reporting in tpm_init_tpmdev()" Markus Armbruster
2020-07-23 12:50 ` Philippe Mathieu-Daudé
2020-07-23 14:20 ` Stefan Berger
2020-07-23 11:58 ` Markus Armbruster [this message]
2020-07-23 12:49 ` [PATCH for-5.1 2/2] tpm: Improve help on TPM types when none are available Philippe Mathieu-Daudé
2020-07-23 14:22 ` Stefan Berger
2020-07-24 0:56 ` Stefan Berger
2020-07-24 6:42 ` 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=20200723115845.1865886-3-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=philmd@redhat.com \
--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).