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>
This commit is contained in:
parent
fcaa204194
commit
551cabdfa9
@ -29,7 +29,8 @@ static void tpm_crb_swtpm_test(const void *data)
|
|||||||
{
|
{
|
||||||
const TestState *ts = data;
|
const TestState *ts = data;
|
||||||
|
|
||||||
tpm_test_swtpm_test(ts->src_tpm_path, tpm_util_crb_transfer, "tpm-crb");
|
tpm_test_swtpm_test(ts->src_tpm_path, tpm_util_crb_transfer,
|
||||||
|
"tpm-crb", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tpm_crb_swtpm_migration_test(const void *data)
|
static void tpm_crb_swtpm_migration_test(const void *data)
|
||||||
@ -37,7 +38,7 @@ static void tpm_crb_swtpm_migration_test(const void *data)
|
|||||||
const TestState *ts = data;
|
const TestState *ts = data;
|
||||||
|
|
||||||
tpm_test_swtpm_migration_test(ts->src_tpm_path, ts->dst_tpm_path, ts->uri,
|
tpm_test_swtpm_migration_test(ts->src_tpm_path, ts->dst_tpm_path, ts->uri,
|
||||||
tpm_util_crb_transfer, "tpm-crb");
|
tpm_util_crb_transfer, "tpm-crb", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
@ -30,7 +30,7 @@ tpm_test_swtpm_skip(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx,
|
void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx,
|
||||||
const char *ifmodel)
|
const char *ifmodel, const char *machine_options)
|
||||||
{
|
{
|
||||||
char *args = NULL;
|
char *args = NULL;
|
||||||
QTestState *s;
|
QTestState *s;
|
||||||
@ -47,10 +47,11 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx,
|
|||||||
g_assert_true(succ);
|
g_assert_true(succ);
|
||||||
|
|
||||||
args = g_strdup_printf(
|
args = g_strdup_printf(
|
||||||
|
"%s "
|
||||||
"-chardev socket,id=chr,path=%s "
|
"-chardev socket,id=chr,path=%s "
|
||||||
"-tpmdev emulator,id=dev,chardev=chr "
|
"-tpmdev emulator,id=dev,chardev=chr "
|
||||||
"-device %s,tpmdev=dev",
|
"-device %s,tpmdev=dev",
|
||||||
addr->u.q_unix.path, ifmodel);
|
machine_options ? : "", addr->u.q_unix.path, ifmodel);
|
||||||
|
|
||||||
s = qtest_start(args);
|
s = qtest_start(args);
|
||||||
g_free(args);
|
g_free(args);
|
||||||
@ -78,7 +79,8 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx,
|
|||||||
void tpm_test_swtpm_migration_test(const char *src_tpm_path,
|
void tpm_test_swtpm_migration_test(const char *src_tpm_path,
|
||||||
const char *dst_tpm_path,
|
const char *dst_tpm_path,
|
||||||
const char *uri, tx_func *tx,
|
const char *uri, tx_func *tx,
|
||||||
const char *ifmodel)
|
const char *ifmodel,
|
||||||
|
const char *machine_options)
|
||||||
{
|
{
|
||||||
gboolean succ;
|
gboolean succ;
|
||||||
GPid src_tpm_pid, dst_tpm_pid;
|
GPid src_tpm_pid, dst_tpm_pid;
|
||||||
@ -100,7 +102,7 @@ void tpm_test_swtpm_migration_test(const char *src_tpm_path,
|
|||||||
|
|
||||||
tpm_util_migration_start_qemu(&src_qemu, &dst_qemu,
|
tpm_util_migration_start_qemu(&src_qemu, &dst_qemu,
|
||||||
src_tpm_addr, dst_tpm_addr, uri,
|
src_tpm_addr, dst_tpm_addr, uri,
|
||||||
ifmodel);
|
ifmodel, machine_options);
|
||||||
|
|
||||||
tpm_util_startup(src_qemu, tx);
|
tpm_util_startup(src_qemu, tx);
|
||||||
tpm_util_pcrextend(src_qemu, tx);
|
tpm_util_pcrextend(src_qemu, tx);
|
||||||
|
@ -16,11 +16,12 @@
|
|||||||
#include "tpm-util.h"
|
#include "tpm-util.h"
|
||||||
|
|
||||||
void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx,
|
void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx,
|
||||||
const char *ifmodel);
|
const char *ifmodel, const char *machine_options);
|
||||||
|
|
||||||
void tpm_test_swtpm_migration_test(const char *src_tpm_path,
|
void tpm_test_swtpm_migration_test(const char *src_tpm_path,
|
||||||
const char *dst_tpm_path,
|
const char *dst_tpm_path,
|
||||||
const char *uri, tx_func *tx,
|
const char *uri, tx_func *tx,
|
||||||
const char *ifmodel);
|
const char *ifmodel,
|
||||||
|
const char *machine_options);
|
||||||
|
|
||||||
#endif /* TESTS_TPM_TESTS_H */
|
#endif /* TESTS_TPM_TESTS_H */
|
||||||
|
@ -29,7 +29,8 @@ static void tpm_tis_swtpm_test(const void *data)
|
|||||||
{
|
{
|
||||||
const TestState *ts = data;
|
const TestState *ts = data;
|
||||||
|
|
||||||
tpm_test_swtpm_test(ts->src_tpm_path, tpm_util_tis_transfer, "tpm-tis");
|
tpm_test_swtpm_test(ts->src_tpm_path, tpm_util_tis_transfer,
|
||||||
|
"tpm-tis", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tpm_tis_swtpm_migration_test(const void *data)
|
static void tpm_tis_swtpm_migration_test(const void *data)
|
||||||
@ -37,7 +38,7 @@ static void tpm_tis_swtpm_migration_test(const void *data)
|
|||||||
const TestState *ts = data;
|
const TestState *ts = data;
|
||||||
|
|
||||||
tpm_test_swtpm_migration_test(ts->src_tpm_path, ts->dst_tpm_path, ts->uri,
|
tpm_test_swtpm_migration_test(ts->src_tpm_path, ts->dst_tpm_path, ts->uri,
|
||||||
tpm_util_tis_transfer, "tpm-tis");
|
tpm_util_tis_transfer, "tpm-tis", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
@ -258,23 +258,27 @@ void tpm_util_migration_start_qemu(QTestState **src_qemu,
|
|||||||
SocketAddress *src_tpm_addr,
|
SocketAddress *src_tpm_addr,
|
||||||
SocketAddress *dst_tpm_addr,
|
SocketAddress *dst_tpm_addr,
|
||||||
const char *miguri,
|
const char *miguri,
|
||||||
const char *ifmodel)
|
const char *ifmodel,
|
||||||
|
const char *machine_options)
|
||||||
{
|
{
|
||||||
char *src_qemu_args, *dst_qemu_args;
|
char *src_qemu_args, *dst_qemu_args;
|
||||||
|
|
||||||
src_qemu_args = g_strdup_printf(
|
src_qemu_args = g_strdup_printf(
|
||||||
|
"%s "
|
||||||
"-chardev socket,id=chr,path=%s "
|
"-chardev socket,id=chr,path=%s "
|
||||||
"-tpmdev emulator,id=dev,chardev=chr "
|
"-tpmdev emulator,id=dev,chardev=chr "
|
||||||
"-device %s,tpmdev=dev ",
|
"-device %s,tpmdev=dev ",
|
||||||
src_tpm_addr->u.q_unix.path, ifmodel);
|
machine_options ? : "", src_tpm_addr->u.q_unix.path, ifmodel);
|
||||||
|
|
||||||
*src_qemu = qtest_init(src_qemu_args);
|
*src_qemu = qtest_init(src_qemu_args);
|
||||||
|
|
||||||
dst_qemu_args = g_strdup_printf(
|
dst_qemu_args = g_strdup_printf(
|
||||||
|
"%s "
|
||||||
"-chardev socket,id=chr,path=%s "
|
"-chardev socket,id=chr,path=%s "
|
||||||
"-tpmdev emulator,id=dev,chardev=chr "
|
"-tpmdev emulator,id=dev,chardev=chr "
|
||||||
"-device %s,tpmdev=dev "
|
"-device %s,tpmdev=dev "
|
||||||
"-incoming %s",
|
"-incoming %s",
|
||||||
|
machine_options ? : "",
|
||||||
dst_tpm_addr->u.q_unix.path,
|
dst_tpm_addr->u.q_unix.path,
|
||||||
ifmodel, miguri);
|
ifmodel, miguri);
|
||||||
|
|
||||||
|
@ -44,7 +44,8 @@ void tpm_util_migration_start_qemu(QTestState **src_qemu,
|
|||||||
SocketAddress *src_tpm_addr,
|
SocketAddress *src_tpm_addr,
|
||||||
SocketAddress *dst_tpm_addr,
|
SocketAddress *dst_tpm_addr,
|
||||||
const char *miguri,
|
const char *miguri,
|
||||||
const char *ifmodel);
|
const char *ifmodel,
|
||||||
|
const char *machine_options);
|
||||||
|
|
||||||
void tpm_util_wait_for_migration_complete(QTestState *who);
|
void tpm_util_wait_for_migration_complete(QTestState *who);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user