return k->ops->desc();
}
-void tpm_backend_destroy(TPMBackend *s)
-{
- TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
-
- k->ops->destroy(s);
-
- tpm_backend_thread_end(s);
-}
-
int tpm_backend_init(TPMBackend *s, TPMState *state,
TPMRecvDataCB *datacb)
{
static void tpm_backend_instance_init(Object *obj)
{
+ TPMBackend *s = TPM_BACKEND(obj);
+
object_property_add_bool(obj, "opened",
tpm_backend_prop_get_opened,
tpm_backend_prop_set_opened,
NULL);
-
+ s->fe_model = -1;
}
static void tpm_backend_instance_finalize(Object *obj)
{
TPMBackend *s = TPM_BACKEND(obj);
+ g_free(s->id);
+ g_free(s->path);
+ g_free(s->cancel_path);
tpm_backend_thread_end(s);
}
TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
tb->id = g_strdup(id);
- /* let frontend set the fe_model to proper value */
- tb->fe_model = -1;
if (tpm_passthrough_handle_device_opts(opts, tb)) {
goto err_exit;
return tb;
err_exit:
- g_free(tb->id);
+ object_unref(obj);
return NULL;
}
-static void tpm_passthrough_destroy(TPMBackend *tb)
-{
- TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
-
- tpm_passthrough_cancel_cmd(tb);
-
- qemu_close(tpm_pt->tpm_fd);
- qemu_close(tpm_pt->cancel_fd);
-
- g_free(tb->id);
- g_free(tb->path);
- g_free(tb->cancel_path);
- g_free(tpm_pt->tpm_dev);
-}
-
static const QemuOptDesc tpm_passthrough_cmdline_opts[] = {
TPM_STANDARD_CMDLINE_OPTS,
{
.opts = tpm_passthrough_cmdline_opts,
.desc = tpm_passthrough_create_desc,
.create = tpm_passthrough_create,
- .destroy = tpm_passthrough_destroy,
.init = tpm_passthrough_init,
.startup_tpm = tpm_passthrough_startup_tpm,
.realloc_buffer = tpm_passthrough_realloc_buffer,
static void tpm_passthrough_inst_init(Object *obj)
{
+ TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(obj);
+
+ tpm_pt->tpm_fd = -1;
+ tpm_pt->cancel_fd = -1;
}
static void tpm_passthrough_inst_finalize(Object *obj)
{
+ TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(obj);
+
+ tpm_passthrough_cancel_cmd(TPM_BACKEND(obj));
+
+ qemu_close(tpm_pt->tpm_fd);
+ qemu_close(tpm_pt->cancel_fd);
+ g_free(tpm_pt->tpm_dev);
}
static void tpm_passthrough_class_init(ObjectClass *klass, void *data)
const char *(*desc)(void);
TPMBackend *(*create)(QemuOpts *opts, const char *id);
- void (*destroy)(TPMBackend *t);
/* initialize the backend */
int (*init)(TPMBackend *t);
*/
const char *tpm_backend_get_desc(TPMBackend *s);
-/**
- * tpm_backend_destroy:
- * @s: the backend to destroy
- */
-void tpm_backend_destroy(TPMBackend *s);
-
/**
* tpm_backend_init:
* @s: the backend to initialized