Skip to contentSkip to conversation

tpm: add stubs to fix compiling with --disable-tpm

PATCH In review Philippe Mathieu-Daudé 5 participants 16 messages Oct 24, 2017 – Oct 26, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

v2 cover tpm: add stubs to fix compiling with --disable-tpm

This fixes building with --disable-tpm as reported by Zoltan:
http://lists.nongnu.org/archive/html/qemu-devel/2017-10/msg05369.html

Cc'ing Peter in case this enters as a build fix instead of via trivial.

v2:
- added Richard W.M. Jones Tested-by tag
- remove #ifdef CONFIG_TPM in tpm.c (Stefan Berger)

Regards,

Phil.

PD: I missed Amarnath Valluri in my first series, you might want to add yourself
a R: tag in MAINTAINTERS.

Philippe Mathieu-Daudé (4):
tpm: add missing include
tpm: add stubs
tpm: remove unnecessary #ifdef CONFIG_TPM
vl: remove unnecessary #ifdef CONFIG_TPM

 Makefile.objs        |  2 +-
 include/sysemu/tpm.h |  1 +
 stubs/tpm.c          | 33 +++++++++++++++++++++++++++++++++
 tpm.c                |  4 ----
 vl.c                 |  2 --
 MAINTAINERS          |  1 +
 stubs/Makefile.objs  |  1 +
 7 files changed, 37 insertions(+), 7 deletions(-)
 create mode 100644 stubs/tpm.c
Signature · 1 line
2.15.0.rc1
#1 lore raw

PATCH v2 1/4 tpm: add missing include

else file including "sysemu/tpm.h" fails to compile:

In file included from qemu/stubs/tpm.c:2:0:
qemu/include/sysemu/tpm.h:36:19: error: implicit declaration of function ‘object_resolve_path_type’ [-Werror=implicit-function-declaration]

       Object *obj = object_resolve_path_type("", TYPE_TPM_TIS, NULL);
                     ^~~~~~~~~~~~~~~~~~~~~~~~
---
 include/sysemu/tpm.h | 1 +
 1 file changed, 1 insertion(+)
include/sysemu/tpm.h +1 -0
index c8afa179e5..d7a2bd8556 100644
@@ -13,6 +13,7 @@
 #define QEMU_TPM_H
 
 #include "qemu/option.h"
+#include "qom/object.h"
 
 typedef struct TPMState TPMState;
 
Signature · 1 line
2.15.0.rc1
#2 lore raw

PATCH v2 2/4 tpm: add stubs

In reply to Philippe Mathieu-Daudé

Commit c37cacabf22 moved tpm_cleanup() in the main loop exit, however this function is not available when compiling with --disable-tpm.

Provides necessary stubs to keep code clean of #ifdef'fery.

Message-Id: <[email protected]>

---
 Makefile.objs       |  2 +-
 stubs/tpm.c         | 33 +++++++++++++++++++++++++++++++++
 MAINTAINERS         |  1 +
 stubs/Makefile.objs |  1 +
 4 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 stubs/tpm.c
Makefile.objs +1 -1
index d4f973a8fc..285c6f3c15 100644
@@ -62,7 +62,7 @@ bt-host.o-cflags := $(BLUEZ_CFLAGS)
 common-obj-y += dma-helpers.o
 common-obj-y += vl.o
 vl.o-cflags := $(GPROF_CFLAGS) $(SDL_CFLAGS)
-common-obj-y += tpm.o
+common-obj-$(CONFIG_TPM) += tpm.o
 
 common-obj-$(CONFIG_SLIRP) += slirp/
 
stubs/tpm.c new file +33 -0
new file mode 100644
index 0000000000..c18aac1c73
@@ -0,0 +1,33 @@
+/*
+ * TPM stubs
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "qemu/osdep.h"
+#include "sysemu/tpm.h"
+#include "qmp-commands.h"
+
+int tpm_init(void)
+{
+    return 0;
+}
+
+void tpm_cleanup(void)
+{
+}
+
+TPMInfoList *qmp_query_tpm(Error **errp)
+{
+    return NULL;
+}
+
+TpmTypeList *qmp_query_tpm_types(Error **errp)
+{
+    return NULL;
+}
+
+TpmModelList *qmp_query_tpm_models(Error **errp)
+{
+    return NULL;
+}
MAINTAINERS +1 -0
index 12175425a7..2650063242 100644
@@ -1544,6 +1544,7 @@ TPM
 M: Stefan Berger <[email protected]>
 S: Maintained
 F: tpm.c
+F: stubs/tpm.c
 F: hw/tpm/*
 F: include/hw/acpi/tpm.h
 F: include/sysemu/tpm*
stubs/Makefile.objs +1 -0
index c7594796c3..8cfe34328a 100644
@@ -28,6 +28,7 @@ stub-obj-y += runstate-check.o
 stub-obj-y += set-fd-handler.o
 stub-obj-y += slirp.o
 stub-obj-y += sysbus.o
+stub-obj-y += tpm.o
 stub-obj-y += trace-control.o
 stub-obj-y += uuid.o
 stub-obj-y += vm-stop.o
Signature · 1 line
2.15.0.rc1
Reviewed-by on v2 2/4
#3 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] tpm: add stubs

Quoted 9 lines · Philippe Mathieu-Daudé

Commit c37cacabf22 moved tpm_cleanup() in the main loop exit, however this function is not available when compiling with --disable-tpm.

Provides necessary stubs to keep code clean of #ifdef'fery.

Message-Id: <[email protected]>

Reviewed-by on v2 2/4
#4 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] tpm: add stubs

In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

Commit c37cacabf22 moved tpm_cleanup() in the main loop exit, however this
function is not available when compiling with --disable-tpm.

Provides necessary stubs to keep code clean of #ifdef'fery.

Message-Id: <[email protected]>

---

#5 lore raw

PATCH v2 3/4 tpm: remove unnecessary #ifdef CONFIG_TPM

In reply to Philippe Mathieu-Daudé

Makefile.objs now checks for $(CONFIG_TPM).

---
 tpm.c | 4 ----
 1 file changed, 4 deletions(-)
tpm.c +0 -4
index 45520f555d..ab5d29e91e 100644
@@ -30,8 +30,6 @@ void tpm_register_model(enum TpmModel model)
     tpm_models[model] = true;
 }
 
-#ifdef CONFIG_TPM
-
 static const TPMBackendClass *
 tpm_be_find_by_type(enum TpmType type)
 {
@@ -192,8 +190,6 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg)
     return 0;
 }
 
-#endif /* CONFIG_TPM */
-
 /*
  * Walk the list of active TPM backends and collect information about them
  * following the schema description in qapi-schema.json.
Signature · 1 line
2.15.0.rc1
Reviewed-by on v2 3/4
#6 lore raw

Re: [Qemu-devel] [PATCH v2 3/4] tpm: remove unnecessary #ifdef CONFIG_TPM

Quoted 4 lines · Philippe Mathieu-Daudé

Makefile.objs now checks for $(CONFIG_TPM).

Quoted 26 lines
---
  tpm.c | 4 ----
  1 file changed, 4 deletions(-)
tpm.c +0 -4
index 45520f555d..ab5d29e91e 100644
@@ -30,8 +30,6 @@ void tpm_register_model(enum TpmModel model)
      tpm_models[model] = true;
  }
 
-#ifdef CONFIG_TPM
-
  static const TPMBackendClass *
  tpm_be_find_by_type(enum TpmType type)
  {
@@ -192,8 +190,6 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg)
      return 0;
  }
 
-#endif /* CONFIG_TPM */
-
  /*
   * Walk the list of active TPM backends and collect information about them
   * following the schema description in qapi-schema.json.
Reviewed-by on v2 3/4
#8 lore raw

Re: [Qemu-devel] [PATCH v2 3/4] tpm: remove unnecessary #ifdef CONFIG_TPM

In reply to Philippe Mathieu-Daudé
Quoted 5 lines · Philippe Mathieu-Daudé

Makefile.objs now checks for $(CONFIG_TPM).

---

Quoted 27 lines

 tpm.c | 4 ----

 1 file changed, 4 deletions(-)
tpm.c +0 -0
index 45520f555d..ab5d29e91e 100644
@@ -30,8 +30,6 @@ void tpm_register_model(enum TpmModel model)
      tpm_models[model] = true;
  }

tpm.c +0 -2
-#ifdef CONFIG_TPM
-

 static const TPMBackendClass *
 tpm_be_find_by_type(enum TpmType type)
 {

tpm.c +0 -0
@@ -192,8 +190,6 @@ int tpm_config_parse(QemuOptsList *opts_list,
 const char *optarg)
      return 0;
  }

tpm.c +0 -2
-#endif /* CONFIG_TPM */
-

 /*
  * Walk the list of active TPM backends and collect information about them
  * following the schema description in qapi-schema.json.

#9 lore raw

PATCH v2 4/4 vl: remove unnecessary #ifdef CONFIG_TPM

In reply to Philippe Mathieu-Daudé

a stub is now provided.

---
 vl.c | 2 --
 1 file changed, 2 deletions(-)
vl.c +0 -2
index 0723835bbf..ec299099ff 100644
@@ -4624,11 +4624,9 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
-#ifdef CONFIG_TPM
     if (tpm_init() < 0) {
         exit(1);
     }
-#endif
 
     /* init the bluetooth world */
     if (foreach_device_config(DEV_BT, bt_parse))
Signature · 1 line
2.15.0.rc1
Reviewed-by on v2 4/4
#11 lore raw

Re: [Qemu-devel] [PATCH v2 4/4] vl: remove unnecessary #ifdef CONFIG_TPM

In reply to Philippe Mathieu-Daudé
Quoted 4 lines · Philippe Mathieu-Daudé

a stub is now provided.

Quoted 20 lines

---
 vl.c | 2 --

 1 file changed, 2 deletions(-)

Reviewed-by:

vl.c +0 -0
index 0723835bbf..ec299099ff 100644
@@ -4624,11 +4624,9 @@ int main(int argc, char **argv, char **envp)
          exit(1);
      }


-#ifdef CONFIG_TPM
     if (tpm_init() < 0) {
         exit(1);
     }
-#endif

     /* init the bluetooth world */
     if (foreach_device_config(DEV_BT, bt_parse))

#12 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 8 lines · Philippe Mathieu-Daudé

This fixes building with --disable-tpm as reported by Zoltan:
http://lists.nongnu.org/archive/html/qemu-devel/2017-10/msg05369.html

Cc'ing Peter in case this enters as a build fix instead of via trivial.

v2:
- added Richard W.M. Jones Tested-by tag
- remove #ifdef CONFIG_TPM in tpm.c (Stefan Berger)

Can confirm v2 works as well.

Rich.

Signature · 5 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
#13 lore raw
Quoted 5 lines
Quoted 3 lines

v2:
- added Richard W.M. Jones Tested-by tag
- remove #ifdef CONFIG_TPM in tpm.c (Stefan Berger)

Can confirm v2 works as well.

Thanks for testing!

#14 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 22 lines · Philippe Mathieu-Daudé

This fixes building with --disable-tpm as reported by Zoltan:
http://lists.nongnu.org/archive/html/qemu-devel/2017-10/msg05369.html

Cc'ing Peter in case this enters as a build fix instead of via trivial.

v2:
- added Richard W.M. Jones Tested-by tag
- remove #ifdef CONFIG_TPM in tpm.c (Stefan Berger)

Regards,

Phil.

PD: I missed Amarnath Valluri in my first series, you might want to add yourself
a R: tag in MAINTAINTERS.

Philippe Mathieu-Daudé (4):
tpm: add missing include
tpm: add stubs
tpm: remove unnecessary #ifdef CONFIG_TPM
vl: remove unnecessary #ifdef CONFIG_TPM

Quoted 10 lines
 Makefile.objs        |  2 +-
 include/sysemu/tpm.h |  1 +
 stubs/tpm.c          | 33 +++++++++++++++++++++++++++++++++
 tpm.c                |  4 ----
 vl.c                 |  2 --
 MAINTAINERS          |  1 +
 stubs/Makefile.objs  |  1 +
 7 files changed, 37 insertions(+), 7 deletions(-)
 create mode 100644 stubs/tpm.c

+1, Nice cleanup in my opinion, now it looks much cleaner.

- Amarnath

#15 lore raw

Hi Amarnath,

Quoted 3 lines · Amarnath Valluri
Quoted 2 lines · Philippe Mathieu-Daudé

This fixes building with --disable-tpm as reported by Zoltan:
http://lists.nongnu.org/archive/html/qemu-devel/2017-10/msg05369.html

[...]

Quoted 1 line

+1, Nice cleanup in my opinion, now it looks much cleaner.

Thanks, however I'm not sure what a +1 means, is it equivalent to an Acked-by or a Reviewed-by tag? If so it would be better to write them explicitly.

Regards,

Phil.