QOSState must be released with qtest_shutdown().
Fixes: 0b70c6ce7b31 ("Add functional and unit tests for the vm-launch-update
device")
Signed-off-by: Marc-André Lureau <[email protected]>
---
tests/qtest/launchupdate-test.c | 14 +++++---------
tests/qtest/libqos/libqos.h | 2 ++
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/tests/qtest/launchupdate-test.c b/tests/qtest/launchupdate-test.c
index ed007cdce29f..12a09079ae91 100644
--- a/tests/qtest/launchupdate-test.c
+++ b/tests/qtest/launchupdate-test.c
@@ -51,7 +51,7 @@ static void test_vm_launch_update_capability(void)
static void test_vm_launch_update_disable(void)
{
QFWCFG *fw_cfg;
- QOSState *qs;
+ g_autoptr(QOSState) qs = NULL;
VMLaunchUpdate launch_update;
uint64_t control;
size_t filesize;
@@ -95,13 +95,12 @@ static void test_vm_launch_update_disable(void)
g_assert_cmpint(VM_LAUNCHUPDATE_CTL_DISABLE & control, ==, 1);
pc_fw_cfg_uninit(fw_cfg);
- qtest_shutdown(qs);
}
static void check_error(void)
{
QFWCFG *fw_cfg;
- QOSState *qs;
+ g_autoptr(QOSState) qs = NULL;
VMLaunchUpdate launch_update;
uint16_t status;
size_t filesize;
@@ -149,6 +148,7 @@ static void check_error(void)
status = le64_to_cpu(launch_update.status);
/* should fail with LOAD_FAIL since it was not IGVM format */
g_assert_cmpint(status, ==, VM_LAUNCHUPDATE_LOAD_FAIL);
+
}
static int64_t get_image_size(const char *filename)
@@ -326,7 +326,7 @@ static void test_load_igvm(void)
size_t igvm_sz;
size_t filesize;
QFWCFG *fw_cfg;
- QOSState *qs;
+ g_autoptr(QOSState) qs = NULL;
VMLaunchUpdate launch_update;
if (!trace) {
@@ -456,8 +456,6 @@ static void test_load_igvm(void)
close(ser_fd);
guest_free(&qs->alloc, gaddr);
pc_fw_cfg_uninit(fw_cfg);
- /* qtest_quit() kils QEMU, first by sending SIGTERM, then SIGKILL */
- qtest_quit(qs->qts);
}
static void test_set_ctrl_once_and_reset_to_host_igvm(void)
@@ -475,7 +473,7 @@ static void test_set_ctrl_once_and_reset_to_host_igvm(void)
size_t igvm_sz;
size_t filesize;
QFWCFG *fw_cfg;
- QOSState *qs;
+ g_autoptr(QOSState) qs = NULL;
VMLaunchUpdate launch_update;
if (!qtest_has_machine("q35")) {
@@ -585,8 +583,6 @@ static void test_set_ctrl_once_and_reset_to_host_igvm(void)
close(ser_fd);
guest_free(&qs->alloc, gaddr);
pc_fw_cfg_uninit(fw_cfg);
- /* qtest_quit() kils QEMU, first by sending SIGTERM, then SIGKILL */
- qtest_quit(qs->qts);
}
int main(int argc, char **argv)
diff --git a/tests/qtest/libqos/libqos.h b/tests/qtest/libqos/libqos.h
index c04950e2b19d..b2d02825a9af 100644
--- a/tests/qtest/libqos/libqos.h
+++ b/tests/qtest/libqos/libqos.h
@@ -42,4 +42,6 @@ static inline void qfree(QOSState *q, uint64_t addr)
guest_free(&q->alloc, addr);
}
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QOSState, qtest_shutdown)
+
#endif
--
2.55.0.543.g5ebe2ebe4ea8