X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=tpm.c;h=9c9e20bbb7e070e864d5d36e99bebafe0ee37dee;hb=6b7ac49d570c66754fad1b80cc200c7596d1facd;hp=61a434185abd69cffd6de2be80e21722ea78e621;hpb=d3fd953f06700ebe2d15825d4399f7cd3e31af34;p=mirror_qemu.git diff --git a/tpm.c b/tpm.c index 61a434185a..9c9e20bbb7 100644 --- a/tpm.c +++ b/tpm.c @@ -11,14 +11,16 @@ * * Based on net.c */ + #include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-tpm.h" #include "qapi/qmp/qerror.h" #include "sysemu/tpm_backend.h" #include "sysemu/tpm.h" #include "qemu/config-file.h" #include "qemu/error-report.h" -#include "qmp-commands.h" static QLIST_HEAD(, TPMBackend) tpm_backends = QLIST_HEAD_INITIALIZER(tpm_backends); @@ -87,19 +89,19 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp) int i; if (!QLIST_EMPTY(&tpm_backends)) { - error_report("Only one TPM is allowed."); + error_setg(errp, "Only one TPM is allowed."); return 1; } id = qemu_opts_id(opts); if (id == NULL) { - error_report(QERR_MISSING_PARAMETER, "id"); + error_setg(errp, QERR_MISSING_PARAMETER, "id"); return 1; } value = qemu_opt_get(opts, "type"); if (!value) { - error_report(QERR_MISSING_PARAMETER, "type"); + error_setg(errp, QERR_MISSING_PARAMETER, "type"); tpm_display_backend_drivers(); return 1; } @@ -107,8 +109,8 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp) i = qapi_enum_parse(&TpmType_lookup, value, -1, NULL); be = i >= 0 ? tpm_be_find_by_type(i) : NULL; if (be == NULL) { - error_report(QERR_INVALID_PARAMETER_VALUE, - "type", "a TPM backend type"); + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", + "a TPM backend type"); tpm_display_backend_drivers(); return 1; } @@ -116,7 +118,7 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp) /* validate backend specific opts */ qemu_opts_validate(opts, be->opts, &local_err); if (local_err) { - error_report_err(local_err); + error_propagate(errp, local_err); return 1; } @@ -149,14 +151,10 @@ void tpm_cleanup(void) * Initialize the TPM. Process the tpmdev command line options describing the * TPM backend. */ -int tpm_init(void) +void tpm_init(void) { - if (qemu_opts_foreach(qemu_find_opts("tpmdev"), - tpm_init_tpmdev, NULL, NULL)) { - return -1; - } - - return 0; + qemu_opts_foreach(qemu_find_opts("tpmdev"), + tpm_init_tpmdev, NULL, &error_fatal); } /* @@ -179,8 +177,7 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg) } /* - * Walk the list of active TPM backends and collect information about them - * following the schema description in qapi-schema.json. + * Walk the list of active TPM backends and collect information about them. */ TPMInfoList *qmp_query_tpm(Error **errp) {