qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

test: tpm: pass optional machine options to swtpm test functions

We plan to use swtpm test functions on ARM for testing the
sysbus TPM-TIS device. However on ARM there is no default machine
type. So we need to explictly pass some machine options on startup.
Let's allow this by adding a new parameter to both swtpm test
functions and update all call sites.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-id: 20200305165149.618-9-eric.auger@redhat.com
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>

authored by

Eric Auger and committed by
Stefan Berger
551cabdf fcaa2041

+23 -13
+3 -2
tests/qtest/tpm-crb-swtpm-test.c
··· 29 29 { 30 30 const TestState *ts = data; 31 31 32 - tpm_test_swtpm_test(ts->src_tpm_path, tpm_util_crb_transfer, "tpm-crb"); 32 + tpm_test_swtpm_test(ts->src_tpm_path, tpm_util_crb_transfer, 33 + "tpm-crb", NULL); 33 34 } 34 35 35 36 static void tpm_crb_swtpm_migration_test(const void *data) ··· 37 38 const TestState *ts = data; 38 39 39 40 tpm_test_swtpm_migration_test(ts->src_tpm_path, ts->dst_tpm_path, ts->uri, 40 - tpm_util_crb_transfer, "tpm-crb"); 41 + tpm_util_crb_transfer, "tpm-crb", NULL); 41 42 } 42 43 43 44 int main(int argc, char **argv)
+6 -4
tests/qtest/tpm-tests.c
··· 30 30 } 31 31 32 32 void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx, 33 - const char *ifmodel) 33 + const char *ifmodel, const char *machine_options) 34 34 { 35 35 char *args = NULL; 36 36 QTestState *s; ··· 47 47 g_assert_true(succ); 48 48 49 49 args = g_strdup_printf( 50 + "%s " 50 51 "-chardev socket,id=chr,path=%s " 51 52 "-tpmdev emulator,id=dev,chardev=chr " 52 53 "-device %s,tpmdev=dev", 53 - addr->u.q_unix.path, ifmodel); 54 + machine_options ? : "", addr->u.q_unix.path, ifmodel); 54 55 55 56 s = qtest_start(args); 56 57 g_free(args); ··· 78 79 void tpm_test_swtpm_migration_test(const char *src_tpm_path, 79 80 const char *dst_tpm_path, 80 81 const char *uri, tx_func *tx, 81 - const char *ifmodel) 82 + const char *ifmodel, 83 + const char *machine_options) 82 84 { 83 85 gboolean succ; 84 86 GPid src_tpm_pid, dst_tpm_pid; ··· 100 102 101 103 tpm_util_migration_start_qemu(&src_qemu, &dst_qemu, 102 104 src_tpm_addr, dst_tpm_addr, uri, 103 - ifmodel); 105 + ifmodel, machine_options); 104 106 105 107 tpm_util_startup(src_qemu, tx); 106 108 tpm_util_pcrextend(src_qemu, tx);
+3 -2
tests/qtest/tpm-tests.h
··· 16 16 #include "tpm-util.h" 17 17 18 18 void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx, 19 - const char *ifmodel); 19 + const char *ifmodel, const char *machine_options); 20 20 21 21 void tpm_test_swtpm_migration_test(const char *src_tpm_path, 22 22 const char *dst_tpm_path, 23 23 const char *uri, tx_func *tx, 24 - const char *ifmodel); 24 + const char *ifmodel, 25 + const char *machine_options); 25 26 26 27 #endif /* TESTS_TPM_TESTS_H */
+3 -2
tests/qtest/tpm-tis-swtpm-test.c
··· 29 29 { 30 30 const TestState *ts = data; 31 31 32 - tpm_test_swtpm_test(ts->src_tpm_path, tpm_util_tis_transfer, "tpm-tis"); 32 + tpm_test_swtpm_test(ts->src_tpm_path, tpm_util_tis_transfer, 33 + "tpm-tis", NULL); 33 34 } 34 35 35 36 static void tpm_tis_swtpm_migration_test(const void *data) ··· 37 38 const TestState *ts = data; 38 39 39 40 tpm_test_swtpm_migration_test(ts->src_tpm_path, ts->dst_tpm_path, ts->uri, 40 - tpm_util_tis_transfer, "tpm-tis"); 41 + tpm_util_tis_transfer, "tpm-tis", NULL); 41 42 } 42 43 43 44 int main(int argc, char **argv)
+6 -2
tests/qtest/tpm-util.c
··· 258 258 SocketAddress *src_tpm_addr, 259 259 SocketAddress *dst_tpm_addr, 260 260 const char *miguri, 261 - const char *ifmodel) 261 + const char *ifmodel, 262 + const char *machine_options) 262 263 { 263 264 char *src_qemu_args, *dst_qemu_args; 264 265 265 266 src_qemu_args = g_strdup_printf( 267 + "%s " 266 268 "-chardev socket,id=chr,path=%s " 267 269 "-tpmdev emulator,id=dev,chardev=chr " 268 270 "-device %s,tpmdev=dev ", 269 - src_tpm_addr->u.q_unix.path, ifmodel); 271 + machine_options ? : "", src_tpm_addr->u.q_unix.path, ifmodel); 270 272 271 273 *src_qemu = qtest_init(src_qemu_args); 272 274 273 275 dst_qemu_args = g_strdup_printf( 276 + "%s " 274 277 "-chardev socket,id=chr,path=%s " 275 278 "-tpmdev emulator,id=dev,chardev=chr " 276 279 "-device %s,tpmdev=dev " 277 280 "-incoming %s", 281 + machine_options ? : "", 278 282 dst_tpm_addr->u.q_unix.path, 279 283 ifmodel, miguri); 280 284
+2 -1
tests/qtest/tpm-util.h
··· 44 44 SocketAddress *src_tpm_addr, 45 45 SocketAddress *dst_tpm_addr, 46 46 const char *miguri, 47 - const char *ifmodel); 47 + const char *ifmodel, 48 + const char *machine_options); 48 49 49 50 void tpm_util_wait_for_migration_complete(QTestState *who); 50 51