aboutsummaryrefslogtreecommitdiff
path: root/hw/tpm
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2017-11-06 19:39:09 +0100
committerStefan Berger <stefanb@linux.vnet.ibm.com>2017-12-14 23:39:14 -0500
commit9f7c0ef2ffa02b3bf6bc630496b8df67c750edd3 (patch)
tree4f0e33016f740c60277132c4cb73e31b8970a2aa /hw/tpm
parent803de211aa1447585b91354aa2ae8dddd4ff68e0 (diff)
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>
Diffstat (limited to 'hw/tpm')
-rw-r--r--hw/tpm/tpm_emulator.c12
-rw-r--r--hw/tpm/tpm_passthrough.c9
2 files changed, 6 insertions, 15 deletions
diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c
index 47f37d6cac..94e6660a5a 100644
--- a/hw/tpm/tpm_emulator.c
+++ b/hw/tpm/tpm_emulator.c
@@ -463,22 +463,16 @@ err:
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));
- tb->id = g_strdup(id);
-
if (tpm_emulator_handle_device_opts(TPM_EMULATOR(tb), opts)) {
- goto err_exit;
+ object_unref(OBJECT(tb));
+ return NULL;
}
return tb;
-
-err_exit:
- object_unref(OBJECT(tb));
-
- return NULL;
}
static TpmTypeOptions *tpm_emulator_get_tpm_options(TPMBackend *tb)
diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index 9326cbfdc9..7371d50739 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -284,13 +284,10 @@ tpm_passthrough_handle_device_opts(TPMPassthruState *tpm_pt, QemuOpts *opts)
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);
- TPMBackend *tb = TPM_BACKEND(obj);
- TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
-
- tb->id = g_strdup(id);
+ TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(obj);
if (tpm_passthrough_handle_device_opts(tpm_pt, opts)) {
goto err_exit;
@@ -301,7 +298,7 @@ static TPMBackend *tpm_passthrough_create(QemuOpts *opts, const char *id)
goto err_exit;
}
- return tb;
+ return TPM_BACKEND(obj);
err_exit:
object_unref(obj);