diff options
Diffstat (limited to 'meta/recipes-devtools/qemu/qemu/0005-tpm-backend-Initialize-and-free-data-members-in-it-s.patch')
-rw-r--r-- | meta/recipes-devtools/qemu/qemu/0005-tpm-backend-Initialize-and-free-data-members-in-it-s.patch | 185 |
1 files changed, 0 insertions, 185 deletions
diff --git a/meta/recipes-devtools/qemu/qemu/0005-tpm-backend-Initialize-and-free-data-members-in-it-s.patch b/meta/recipes-devtools/qemu/qemu/0005-tpm-backend-Initialize-and-free-data-members-in-it-s.patch deleted file mode 100644 index 91dd542f45..0000000000 --- a/meta/recipes-devtools/qemu/qemu/0005-tpm-backend-Initialize-and-free-data-members-in-it-s.patch +++ /dev/null | |||
@@ -1,185 +0,0 @@ | |||
1 | From 83ef052c60de271a97abb7eb9b5a8aeee52659e6 Mon Sep 17 00:00:00 2001 | ||
2 | From: Amarnath Valluri <amarnath.valluri@intel.com> | ||
3 | Date: Fri, 31 Mar 2017 10:58:11 +0300 | ||
4 | Subject: [PATCH 05/12] tpm-backend: Initialize and free data members in it's | ||
5 | own methods | ||
6 | MIME-Version: 1.0 | ||
7 | Content-Type: text/plain; charset=UTF-8 | ||
8 | Content-Transfer-Encoding: 8bit | ||
9 | |||
10 | Initialize and free TPMBackend data members in it's own instance_init() and | ||
11 | instance_finalize methods. | ||
12 | |||
13 | Took the opportunity to remove unneeded destroy() method from TpmDriverOps | ||
14 | interface as TPMBackend is a Qemu Object, we can use object_unref() inplace of | ||
15 | tpm_backend_destroy() to free the backend object, hence removed destroy() from | ||
16 | TPMDriverOps interface. | ||
17 | |||
18 | Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com> | ||
19 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
20 | Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> | ||
21 | |||
22 | Upstream-Status: Backport [f35fe5cb97bbdaa6a6967f2fefc3fc1f79680601] | ||
23 | --- | ||
24 | backends/tpm.c | 16 ++++++---------- | ||
25 | hw/tpm/tpm_passthrough.c | 31 ++++++++++++------------------- | ||
26 | include/sysemu/tpm_backend.h | 7 ------- | ||
27 | tpm.c | 2 +- | ||
28 | 4 files changed, 19 insertions(+), 37 deletions(-) | ||
29 | |||
30 | diff --git a/backends/tpm.c b/backends/tpm.c | ||
31 | index ce56c3b74d..cf5abf1582 100644 | ||
32 | --- a/backends/tpm.c | ||
33 | +++ b/backends/tpm.c | ||
34 | @@ -51,15 +51,6 @@ const char *tpm_backend_get_desc(TPMBackend *s) | ||
35 | return k->ops->desc(); | ||
36 | } | ||
37 | |||
38 | -void tpm_backend_destroy(TPMBackend *s) | ||
39 | -{ | ||
40 | - TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s); | ||
41 | - | ||
42 | - k->ops->destroy(s); | ||
43 | - | ||
44 | - tpm_backend_thread_end(s); | ||
45 | -} | ||
46 | - | ||
47 | int tpm_backend_init(TPMBackend *s, TPMState *state, | ||
48 | TPMRecvDataCB *datacb) | ||
49 | { | ||
50 | @@ -182,17 +173,22 @@ static void tpm_backend_prop_set_opened(Object *obj, bool value, Error **errp) | ||
51 | |||
52 | static void tpm_backend_instance_init(Object *obj) | ||
53 | { | ||
54 | + TPMBackend *s = TPM_BACKEND(obj); | ||
55 | + | ||
56 | object_property_add_bool(obj, "opened", | ||
57 | tpm_backend_prop_get_opened, | ||
58 | tpm_backend_prop_set_opened, | ||
59 | NULL); | ||
60 | - | ||
61 | + s->fe_model = -1; | ||
62 | } | ||
63 | |||
64 | static void tpm_backend_instance_finalize(Object *obj) | ||
65 | { | ||
66 | TPMBackend *s = TPM_BACKEND(obj); | ||
67 | |||
68 | + g_free(s->id); | ||
69 | + g_free(s->path); | ||
70 | + g_free(s->cancel_path); | ||
71 | tpm_backend_thread_end(s); | ||
72 | } | ||
73 | |||
74 | diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c | ||
75 | index f50d9cffd7..815a72ef9a 100644 | ||
76 | --- a/hw/tpm/tpm_passthrough.c | ||
77 | +++ b/hw/tpm/tpm_passthrough.c | ||
78 | @@ -417,8 +417,6 @@ static TPMBackend *tpm_passthrough_create(QemuOpts *opts, const char *id) | ||
79 | TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); | ||
80 | |||
81 | tb->id = g_strdup(id); | ||
82 | - /* let frontend set the fe_model to proper value */ | ||
83 | - tb->fe_model = -1; | ||
84 | |||
85 | if (tpm_passthrough_handle_device_opts(opts, tb)) { | ||
86 | goto err_exit; | ||
87 | @@ -432,26 +430,11 @@ static TPMBackend *tpm_passthrough_create(QemuOpts *opts, const char *id) | ||
88 | return tb; | ||
89 | |||
90 | err_exit: | ||
91 | - g_free(tb->id); | ||
92 | + object_unref(obj); | ||
93 | |||
94 | return NULL; | ||
95 | } | ||
96 | |||
97 | -static void tpm_passthrough_destroy(TPMBackend *tb) | ||
98 | -{ | ||
99 | - TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); | ||
100 | - | ||
101 | - tpm_passthrough_cancel_cmd(tb); | ||
102 | - | ||
103 | - qemu_close(tpm_pt->tpm_fd); | ||
104 | - qemu_close(tpm_pt->cancel_fd); | ||
105 | - | ||
106 | - g_free(tb->id); | ||
107 | - g_free(tb->path); | ||
108 | - g_free(tb->cancel_path); | ||
109 | - g_free(tpm_pt->tpm_dev); | ||
110 | -} | ||
111 | - | ||
112 | static const QemuOptDesc tpm_passthrough_cmdline_opts[] = { | ||
113 | TPM_STANDARD_CMDLINE_OPTS, | ||
114 | { | ||
115 | @@ -472,7 +455,6 @@ static const TPMDriverOps tpm_passthrough_driver = { | ||
116 | .opts = tpm_passthrough_cmdline_opts, | ||
117 | .desc = tpm_passthrough_create_desc, | ||
118 | .create = tpm_passthrough_create, | ||
119 | - .destroy = tpm_passthrough_destroy, | ||
120 | .init = tpm_passthrough_init, | ||
121 | .startup_tpm = tpm_passthrough_startup_tpm, | ||
122 | .realloc_buffer = tpm_passthrough_realloc_buffer, | ||
123 | @@ -486,10 +468,21 @@ static const TPMDriverOps tpm_passthrough_driver = { | ||
124 | |||
125 | static void tpm_passthrough_inst_init(Object *obj) | ||
126 | { | ||
127 | + TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(obj); | ||
128 | + | ||
129 | + tpm_pt->tpm_fd = -1; | ||
130 | + tpm_pt->cancel_fd = -1; | ||
131 | } | ||
132 | |||
133 | static void tpm_passthrough_inst_finalize(Object *obj) | ||
134 | { | ||
135 | + TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(obj); | ||
136 | + | ||
137 | + tpm_passthrough_cancel_cmd(TPM_BACKEND(obj)); | ||
138 | + | ||
139 | + qemu_close(tpm_pt->tpm_fd); | ||
140 | + qemu_close(tpm_pt->cancel_fd); | ||
141 | + g_free(tpm_pt->tpm_dev); | ||
142 | } | ||
143 | |||
144 | static void tpm_passthrough_class_init(ObjectClass *klass, void *data) | ||
145 | diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h | ||
146 | index 58308b3687..202ec8d5a2 100644 | ||
147 | --- a/include/sysemu/tpm_backend.h | ||
148 | +++ b/include/sysemu/tpm_backend.h | ||
149 | @@ -78,7 +78,6 @@ struct TPMDriverOps { | ||
150 | const char *(*desc)(void); | ||
151 | |||
152 | TPMBackend *(*create)(QemuOpts *opts, const char *id); | ||
153 | - void (*destroy)(TPMBackend *t); | ||
154 | |||
155 | /* initialize the backend */ | ||
156 | int (*init)(TPMBackend *t); | ||
157 | @@ -118,12 +117,6 @@ enum TpmType tpm_backend_get_type(TPMBackend *s); | ||
158 | const char *tpm_backend_get_desc(TPMBackend *s); | ||
159 | |||
160 | /** | ||
161 | - * tpm_backend_destroy: | ||
162 | - * @s: the backend to destroy | ||
163 | - */ | ||
164 | -void tpm_backend_destroy(TPMBackend *s); | ||
165 | - | ||
166 | -/** | ||
167 | * tpm_backend_init: | ||
168 | * @s: the backend to initialized | ||
169 | * @state: TPMState | ||
170 | diff --git a/tpm.c b/tpm.c | ||
171 | index b7166ca200..7feb3b43c9 100644 | ||
172 | --- a/tpm.c | ||
173 | +++ b/tpm.c | ||
174 | @@ -158,7 +158,7 @@ void tpm_cleanup(void) | ||
175 | |||
176 | QLIST_FOREACH_SAFE(drv, &tpm_backends, list, next) { | ||
177 | QLIST_REMOVE(drv, list); | ||
178 | - tpm_backend_destroy(drv); | ||
179 | + object_unref(OBJECT(drv)); | ||
180 | } | ||
181 | } | ||
182 | |||
183 | -- | ||
184 | 2.11.0 | ||
185 | |||