提交 bb716238 编写于 作者: S Stefan Berger 提交者: Anthony Liguori

Move TPM passthrough specific command line options to backend structure

Move the TPM passthrough specific command line options to the passthrough
backend implementation and attach them to the backend's interface structure.

Add code to tpm.c for validating the TPM command line options.
Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: NCorey Bryan <coreyb@linux.vnet.ibm.com>
Message-id: 1366641699-21420-1-git-send-email-stefanb@linux.vnet.ibm.com
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 13daf6ca
...@@ -33,6 +33,13 @@ struct TPMState { ...@@ -33,6 +33,13 @@ struct TPMState {
#define TPM(obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS) #define TPM(obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS)
#define TPM_STANDARD_CMDLINE_OPTS \
{ \
.name = "type", \
.type = QEMU_OPT_STRING, \
.help = "Type of TPM backend", \
}
struct tpm_req_hdr { struct tpm_req_hdr {
uint16_t tag; uint16_t tag;
uint32_t len; uint32_t len;
......
...@@ -488,8 +488,24 @@ static void tpm_passthrough_destroy(TPMBackend *tb) ...@@ -488,8 +488,24 @@ static void tpm_passthrough_destroy(TPMBackend *tb)
g_free(tpm_pt->tpm_dev); g_free(tpm_pt->tpm_dev);
} }
static const QemuOptDesc tpm_passthrough_cmdline_opts[] = {
TPM_STANDARD_CMDLINE_OPTS,
{
.name = "cancel-path",
.type = QEMU_OPT_STRING,
.help = "Sysfs file entry for canceling TPM commands",
},
{
.name = "path",
.type = QEMU_OPT_STRING,
.help = "Path to TPM device on the host",
},
{ /* end of list */ },
};
static const TPMDriverOps tpm_passthrough_driver = { static const TPMDriverOps tpm_passthrough_driver = {
.type = TPM_TYPE_PASSTHROUGH, .type = TPM_TYPE_PASSTHROUGH,
.opts = tpm_passthrough_cmdline_opts,
.desc = tpm_passthrough_create_desc, .desc = tpm_passthrough_create_desc,
.create = tpm_passthrough_create, .create = tpm_passthrough_create,
.destroy = tpm_passthrough_destroy, .destroy = tpm_passthrough_destroy,
......
...@@ -65,6 +65,7 @@ typedef struct TPMSizedBuffer { ...@@ -65,6 +65,7 @@ typedef struct TPMSizedBuffer {
struct TPMDriverOps { struct TPMDriverOps {
enum TpmType type; enum TpmType type;
const QemuOptDesc *opts;
/* get a descriptive text of the backend to display to the user */ /* get a descriptive text of the backend to display to the user */
const char *(*desc)(void); const char *(*desc)(void);
......
...@@ -159,6 +159,14 @@ static int configure_tpm(QemuOpts *opts) ...@@ -159,6 +159,14 @@ static int configure_tpm(QemuOpts *opts)
return 1; return 1;
} }
/* validate backend specific opts */
qemu_opts_validate(opts, be->opts, &local_err);
if (error_is_set(&local_err)) {
qerror_report_err(local_err);
error_free(local_err);
return 1;
}
drv = be->create(opts, id); drv = be->create(opts, id);
if (!drv) { if (!drv) {
return 1; return 1;
......
...@@ -502,21 +502,7 @@ static QemuOptsList qemu_tpmdev_opts = { ...@@ -502,21 +502,7 @@ static QemuOptsList qemu_tpmdev_opts = {
.implied_opt_name = "type", .implied_opt_name = "type",
.head = QTAILQ_HEAD_INITIALIZER(qemu_tpmdev_opts.head), .head = QTAILQ_HEAD_INITIALIZER(qemu_tpmdev_opts.head),
.desc = { .desc = {
{ /* options are defined in the TPM backends */
.name = "type",
.type = QEMU_OPT_STRING,
.help = "Type of TPM backend",
},
{
.name = "cancel-path",
.type = QEMU_OPT_STRING,
.help = "Sysfs file entry for canceling TPM commands",
},
{
.name = "path",
.type = QEMU_OPT_STRING,
.help = "Path to TPM device on the host",
},
{ /* end of list */ } { /* end of list */ }
}, },
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册