diff options
| author | Steve Sistare <steven.sistare@oracle.com> | 2025-10-01 08:34:05 -0700 |
|---|---|---|
| committer | Fabiano Rosas <farosas@suse.de> | 2025-10-01 17:09:22 -0300 |
| commit | 5419f36e9eb3ec155cd3762a691c92fcfca48958 (patch) | |
| tree | c4578a9352b2d86db2892d5a2f834549757c0fbc | |
| parent | e9fbd9e6b15a054f2b7eee757f6c9b11d4132044 (diff) | |
| download | focaccia-qemu-5419f36e9eb3ec155cd3762a691c92fcfca48958.tar.gz focaccia-qemu-5419f36e9eb3ec155cd3762a691c92fcfca48958.zip | |
tests/qtest: qtest_init_after_exec
Define a function to create a QTestState object representing the state of QEMU after old QEMU exec's new QEMU. This is needed for testing the cpr-exec migration mode. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> Reviewed-by: Fabiano Rosas <farosas@suse.de> Link: https://lore.kernel.org/qemu-devel/1759332851-370353-14-git-send-email-steven.sistare@oracle.com Signed-off-by: Fabiano Rosas <farosas@suse.de>
| -rw-r--r-- | tests/qtest/libqtest.c | 19 | ||||
| -rw-r--r-- | tests/qtest/libqtest.h | 8 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index d97144e1d5..933d085869 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -615,6 +615,25 @@ QTestState *qtest_init_ext(const char *var, const char *extra_args, return s; } +static QTestState *qtest_attach_qemu(const char *qemu_bin, + const char *extra_args, + void *opaque) +{ + int pid = *(int *)opaque; + return qtest_create_test_state(pid); +} + +QTestState *qtest_init_after_exec(QTestState *qts) +{ + void *opaque = (void *)&qts->qemu_pid; + QTestState *s; + + s = qtest_init_internal(NULL, NULL, true, qtest_attach_qemu, opaque); + qts->qemu_pid = -1; + qtest_qmp_handshake(s, NULL); + return s; +} + QTestState *qtest_init(const char *extra_args) { return qtest_init_ext(NULL, extra_args, NULL, true); diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index 7f8dd0a912..9c118c89ca 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -57,6 +57,14 @@ QTestState *qtest_vinitf(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0); const char *qtest_qemu_binary(const char *var); /** + * qtest_init_after_exec: + * @qts: the previous QEMU state + * + * Return a test state representing new QEMU after @qts exec's it. + */ +QTestState *qtest_init_after_exec(QTestState *qts); + +/** * qtest_qemu_args: * @extra_args: Other arguments to pass to QEMU. * |