aboutsummaryrefslogtreecommitdiffstats
path: root/tests/qtest/tpm-emu.h
diff options
context:
space:
mode:
authorTimos Ampelikiotis <t.ampelikiotis@virtualopensystems.com>2023-10-10 11:40:56 +0000
committerTimos Ampelikiotis <t.ampelikiotis@virtualopensystems.com>2023-10-10 11:40:56 +0000
commite02cda008591317b1625707ff8e115a4841aa889 (patch)
treeaee302e3cf8b59ec2d32ec481be3d1afddfc8968 /tests/qtest/tpm-emu.h
parentcc668e6b7e0ffd8c9d130513d12053cf5eda1d3b (diff)
Introduce Virtio-loopback epsilon release:
Epsilon release introduces a new compatibility layer which make virtio-loopback design to work with QEMU and rust-vmm vhost-user backend without require any changes. Signed-off-by: Timos Ampelikiotis <t.ampelikiotis@virtualopensystems.com> Change-Id: I52e57563e08a7d0bdc002f8e928ee61ba0c53dd9
Diffstat (limited to 'tests/qtest/tpm-emu.h')
-rw-r--r--tests/qtest/tpm-emu.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/qtest/tpm-emu.h b/tests/qtest/tpm-emu.h
new file mode 100644
index 000000000..c33d99af3
--- /dev/null
+++ b/tests/qtest/tpm-emu.h
@@ -0,0 +1,56 @@
+/*
+ * Minimal TPM emulator for TPM test cases
+ *
+ * Copyright (c) 2018 Red Hat, Inc.
+ *
+ * Authors:
+ * Marc-André Lureau <marcandre.lureau@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef TESTS_TPM_EMU_H
+#define TESTS_TPM_EMU_H
+
+#define TPM_RC_FAILURE 0x101
+#define TPM2_ST_NO_SESSIONS 0x8001
+
+#define TPM_FAIL 9
+#define TPM_TAG_RSP_COMMAND 0xc4
+
+#include "qemu/sockets.h"
+#include "io/channel.h"
+#include "sysemu/tpm.h"
+#include "libqos/libqtest.h"
+
+struct tpm_hdr {
+ uint16_t tag;
+ uint32_t len;
+ uint32_t code; /*ordinal/error */
+ char buffer[];
+} QEMU_PACKED;
+
+#ifndef CONFIG_TPM
+enum TPMVersion {
+ TPM_VERSION_1_2 = 1,
+ TPM_VERSION_2_0 = 2,
+};
+#endif
+
+typedef struct TPMTestState {
+ GMutex data_mutex;
+ GCond data_cond;
+ bool data_cond_signal;
+ SocketAddress *addr;
+ QIOChannel *tpm_ioc;
+ GThread *emu_tpm_thread;
+ struct tpm_hdr *tpm_msg;
+ enum TPMVersion tpm_version;
+} TPMTestState;
+
+void tpm_emu_test_wait_cond(TPMTestState *s);
+void *tpm_emu_ctrl_thread(void *data);
+bool tpm_model_is_available(const char *args, const char *tpm_if);
+
+#endif /* TESTS_TPM_EMU_H */