Skip to content

Commit 5a6791c

Browse files
Markus Armbrusterstefanberger
authored andcommitted
tpm: Improve help on TPM types when none are available
Help is a bit awkward when no TPM types are built into QEMU: $ qemu-system-x86_64 -tpmdev nonexistent,id=tpm0 qemu-system-x86_64: -tpmdev nonexistent,id=tpm0: Parameter 'type' expects a TPM backend type Supported TPM types (choose only one): Improve to qemu-system-x86_64: -tpmdev nonexistent,id=tpm0: Parameter 'type' expects a TPM backend type No TPM backend types are available Signed-off-by: Markus Armbruster <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Stefan Berger <[email protected]> Signed-off-by: Stefan Berger <[email protected]>
1 parent d64072c commit 5a6791c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tpm.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,23 @@ tpm_be_find_by_type(enum TpmType type)
4747
*/
4848
static void tpm_display_backend_drivers(void)
4949
{
50+
bool got_one = false;
5051
int i;
5152

52-
fprintf(stderr, "Supported TPM types (choose only one):\n");
53-
5453
for (i = 0; i < TPM_TYPE__MAX; i++) {
5554
const TPMBackendClass *bc = tpm_be_find_by_type(i);
5655
if (!bc) {
5756
continue;
5857
}
59-
fprintf(stderr, "%12s %s\n", TpmType_str(i), bc->desc);
58+
if (!got_one) {
59+
error_printf("Supported TPM types (choose only one):\n");
60+
got_one = true;
61+
}
62+
error_printf("%12s %s\n", TpmType_str(i), bc->desc);
63+
}
64+
if (!got_one) {
65+
error_printf("No TPM backend types are available\n");
6066
}
61-
fprintf(stderr, "\n");
6267
}
6368

6469
/*

0 commit comments

Comments
 (0)