mirror of https://gitee.com/openkylin/qemu.git
tpm-backend: move set 'id' to common code
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This commit is contained in:
parent
803de211aa
commit
9f7c0ef2ff
|
@ -463,22 +463,16 @@ err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TPMBackend *tpm_emulator_create(QemuOpts *opts, const char *id)
|
static TPMBackend *tpm_emulator_create(QemuOpts *opts)
|
||||||
{
|
{
|
||||||
TPMBackend *tb = TPM_BACKEND(object_new(TYPE_TPM_EMULATOR));
|
TPMBackend *tb = TPM_BACKEND(object_new(TYPE_TPM_EMULATOR));
|
||||||
|
|
||||||
tb->id = g_strdup(id);
|
|
||||||
|
|
||||||
if (tpm_emulator_handle_device_opts(TPM_EMULATOR(tb), opts)) {
|
if (tpm_emulator_handle_device_opts(TPM_EMULATOR(tb), opts)) {
|
||||||
goto err_exit;
|
object_unref(OBJECT(tb));
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tb;
|
return tb;
|
||||||
|
|
||||||
err_exit:
|
|
||||||
object_unref(OBJECT(tb));
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static TpmTypeOptions *tpm_emulator_get_tpm_options(TPMBackend *tb)
|
static TpmTypeOptions *tpm_emulator_get_tpm_options(TPMBackend *tb)
|
||||||
|
|
|
@ -284,13 +284,10 @@ tpm_passthrough_handle_device_opts(TPMPassthruState *tpm_pt, QemuOpts *opts)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TPMBackend *tpm_passthrough_create(QemuOpts *opts, const char *id)
|
static TPMBackend *tpm_passthrough_create(QemuOpts *opts)
|
||||||
{
|
{
|
||||||
Object *obj = object_new(TYPE_TPM_PASSTHROUGH);
|
Object *obj = object_new(TYPE_TPM_PASSTHROUGH);
|
||||||
TPMBackend *tb = TPM_BACKEND(obj);
|
TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(obj);
|
||||||
TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
|
|
||||||
|
|
||||||
tb->id = g_strdup(id);
|
|
||||||
|
|
||||||
if (tpm_passthrough_handle_device_opts(tpm_pt, opts)) {
|
if (tpm_passthrough_handle_device_opts(tpm_pt, opts)) {
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
|
@ -301,7 +298,7 @@ static TPMBackend *tpm_passthrough_create(QemuOpts *opts, const char *id)
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tb;
|
return TPM_BACKEND(obj);
|
||||||
|
|
||||||
err_exit:
|
err_exit:
|
||||||
object_unref(obj);
|
object_unref(obj);
|
||||||
|
|
|
@ -63,7 +63,7 @@ struct TPMBackendClass {
|
||||||
/* 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;
|
const char *desc;
|
||||||
|
|
||||||
TPMBackend *(*create)(QemuOpts *opts, const char *id);
|
TPMBackend *(*create)(QemuOpts *opts);
|
||||||
|
|
||||||
/* start up the TPM on the backend - optional */
|
/* start up the TPM on the backend - optional */
|
||||||
int (*startup_tpm)(TPMBackend *t);
|
int (*startup_tpm)(TPMBackend *t);
|
||||||
|
|
3
tpm.c
3
tpm.c
|
@ -127,11 +127,12 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
drv = be->create(opts, id);
|
drv = be->create(opts);
|
||||||
if (!drv) {
|
if (!drv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drv->id = g_strdup(id);
|
||||||
QLIST_INSERT_HEAD(&tpm_backends, drv, list);
|
QLIST_INSERT_HEAD(&tpm_backends, drv, list);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue