tpm: Fix compilation with --disable-tpm
PATCH v2 1/1 tpm: Fix compilation with --disable-tpm
Commit
c37cacabf2285b0731b44c1f667781fdd4f2b658
broke compilation without tpm. Just add an #ifdef
--- tpm.c | 6 +++++- vl.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-)
tpm.c +5 -1
@@ -223,8 +223,11 @@ TPMInfoList *qmp_query_tpm(Error **errp)TpmTypeList *qmp_query_tpm_types (Error **errp) { +TpmTypeList *head =NULL ; + +#ifdef CONFIG_TPM unsigned int i =0 ; -TpmTypeList *head =NULL , *prev =NULL , *cur_item; +TpmTypeList *prev =NULL , *cur_item;for (i =0 ; i <TPM_TYPE__MAX ; i++) {if (!tpm_be_find_by_type (i)) {
@@ -241,6 +244,7 @@ TpmTypeList *qmp_query_tpm_types(Error **errp) } prev = cur_item; } +#endif return head; }
vl.c +2 -0
@@ -4905,7 +4905,9 @@ int main(int argc, char **argv, char **envp)res_free ();/* vhost-user must be cleaned up before chardevs. */ +#ifdef CONFIG_TPM tpm_cleanup (); +#endif net_cleanup ();audio_cleanup ();monitor_cleanup ();
Signature · 1 line
2.13.6
Quoted 34 lines · Juan Quintela
Commit
c37cacabf2285b0731b44c1f667781fdd4f2b658broke compilation without tpm. Just add an #ifdef
CC Amarnath Valluri <[email protected]>Signed-off-by Juan Quintela <[email protected]>---
tpm.c | 6 +++++-
vl.c | 2 ++2 files changed, 7 insertions(+), 1 deletion(-)tpm.c +0
-0@@ -223,8 +223,11 @@ TPMInfoList *qmp_query_tpm(Error **errp)
TpmTypeList *qmp_query_tpm_types(Error **errp)
{
+ TpmTypeList *head = NULL;tpm.c +2
-0+ +#ifdef CONFIG_TPM unsigned int i = 0;
- TpmTypeList *head = NULL, *prev = NULL,*cur_item; + TpmTypeList *prev = NULL,*cur_item;
for (i = 0; i <TPM_TYPE__MAX; i++) {
if (!tpm_be_find_by_type(i)) {tpm.c +1
-0@@ -241,6 +244,7 @@ TpmTypeList *qmp_query_tpm_types(Error **errp) } prev = cur_item; } +#endif
Quoted 3 lines
return head;
}
I would prefer to bring everything in tpm.c under #ifdef CONFIG_TPM. and provide dummy implementations only for qmp commands:
qmp_query_{tpm,_models,_types} in disable-tpm case.
- Amarnath
Quoted 33 lines · Amarnath
Quoted 32 lines · Juan Quintela
Commit
c37cacabf2285b0731b44c1f667781fdd4f2b658broke compilation without tpm. Just add an #ifdef
CC Amarnath Valluri <[email protected]>Signed-off-by Juan Quintela <[email protected]>---
tpm.c | 6 +++++-
vl.c | 2 ++2 files changed, 7 insertions(+), 1 deletion(-)tpm.c +0
-0@@ -223,8 +223,11 @@ TPMInfoList *qmp_query_tpm(Error **errp)
TpmTypeList *qmp_query_tpm_types(Error **errp)
{
+ TpmTypeList *head = NULL;tpm.c +2
-0+ +#ifdef CONFIG_TPM unsigned int i = 0;
- TpmTypeList *head = NULL, *prev = NULL,*cur_item; + TpmTypeList *prev = NULL,*cur_item;
for (i = 0; i <TPM_TYPE__MAX; i++) {
if (!tpm_be_find_by_type(i)) {tpm.c +0
-0@@ -241,6 +244,7 @@ TpmTypeList *qmp_query_tpm_types(Error **errp) } prev = cur_item;
Quoted 8 lines
Quoted 5 lines
tpm.c +1
-0} +#endif
return head;
}I would prefer to bring everything in
tpm.cunder #ifdefCONFIG_TPM. and provide dummy implementations only for qmp commands:
qmp_query_{tpm,_models,_types} in disable-tpm case.
Hi
We can't compile out tpm.c in case of disable CONFIG_TPM, but then it makes no sense at all to have CONFIG_TPM on vl.c. We go for stubs or CONFIG_TPM, both of them look bad, no?
Later, Juan.