[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/31] libqtest: add qtest_kill_qemu()
From: |
Kevin Wolf |
Subject: |
[PULL 14/31] libqtest: add qtest_kill_qemu() |
Date: |
Fri, 5 Mar 2021 17:54:37 +0100 |
From: Stefan Hajnoczi <stefanha@redhat.com>
Tests that manage multiple processes may wish to kill QEMU before
destroying the QTestState. Expose a function to do that.
The vhost-user-blk-test testcase will need this.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Message-Id: <20210223144653.811468-4-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/qtest/libqos/libqtest.h | 11 +++++++++++
tests/qtest/libqtest.c | 7 ++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h
index e5f1ec590c..51287b9276 100644
--- a/tests/qtest/libqos/libqtest.h
+++ b/tests/qtest/libqos/libqtest.h
@@ -74,6 +74,17 @@ QTestState *qtest_init_without_qmp_handshake(const char
*extra_args);
*/
QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd);
+/**
+ * qtest_kill_qemu:
+ * @s: #QTestState instance to operate on.
+ *
+ * Kill the QEMU process and wait for it to terminate. It is safe to call this
+ * function multiple times. Normally qtest_quit() is used instead because it
+ * also frees QTestState. Use qtest_kill_qemu() when you just want to kill QEMU
+ * and qtest_quit() will be called later.
+ */
+void qtest_kill_qemu(QTestState *s);
+
/**
* qtest_quit:
* @s: #QTestState instance to operate on.
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index b19d2ebda0..2a98de2907 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -133,7 +133,7 @@ void qtest_set_expected_status(QTestState *s, int status)
s->expected_status = status;
}
-static void kill_qemu(QTestState *s)
+void qtest_kill_qemu(QTestState *s)
{
pid_t pid = s->qemu_pid;
int wstatus;
@@ -143,6 +143,7 @@ static void kill_qemu(QTestState *s)
kill(pid, SIGTERM);
TFR(pid = waitpid(s->qemu_pid, &s->wstatus, 0));
assert(pid == s->qemu_pid);
+ s->qemu_pid = -1;
}
/*
@@ -169,7 +170,7 @@ static void kill_qemu(QTestState *s)
static void kill_qemu_hook_func(void *s)
{
- kill_qemu(s);
+ qtest_kill_qemu(s);
}
static void sigabrt_handler(int signo)
@@ -373,7 +374,7 @@ void qtest_quit(QTestState *s)
/* Uninstall SIGABRT handler on last instance */
cleanup_sigabrt_handler();
- kill_qemu(s);
+ qtest_kill_qemu(s);
close(s->fd);
close(s->qmp_fd);
g_string_free(s->rx, true);
--
2.29.2
- [PULL 04/31] iotests/283: Check that finalize drops backup-top, (continued)
- [PULL 04/31] iotests/283: Check that finalize drops backup-top, Kevin Wolf, 2021/03/05
- [PULL 19/31] block/export: use VIRTIO_BLK_SECTOR_BITS, Kevin Wolf, 2021/03/05
- [PULL 03/31] backup-top: Refuse I/O in inactive state, Kevin Wolf, 2021/03/05
- [PULL 22/31] vhost-user-blk-test: test discard/write zeroes invalid inputs, Kevin Wolf, 2021/03/05
- [PULL 28/31] iotests.py: add unarchive_sample_image() helper, Kevin Wolf, 2021/03/05
- [PULL 18/31] block/export: fix blk_size double byteswap, Kevin Wolf, 2021/03/05
- [PULL 17/31] tests/qtest: add multi-queue test case to vhost-user-blk-test, Kevin Wolf, 2021/03/05
- [PULL 12/31] vhost-user-blk: fix blkcfg->num_queues endianness, Kevin Wolf, 2021/03/05
- [PULL 29/31] iotests: add parallels-read-bitmap test, Kevin Wolf, 2021/03/05
- [PULL 26/31] block/parallels: BDRVParallelsState: add cluster_size field, Kevin Wolf, 2021/03/05
- [PULL 14/31] libqtest: add qtest_kill_qemu(),
Kevin Wolf <=
- [PULL 11/31] docs: replace insecure /tmp examples in qsd docs, Kevin Wolf, 2021/03/05
- [PULL 27/31] parallels: support bitmap extension for read-only mode, Kevin Wolf, 2021/03/05
- [PULL 30/31] MAINTAINERS: update parallels block driver, Kevin Wolf, 2021/03/05
- [PULL 16/31] test: new qTest case to test the vhost-user-blk-server, Kevin Wolf, 2021/03/05
- Re: [PULL 00/31] Block layer patches, Peter Maydell, 2021/03/06