From: Fabiano Rosas <farosas@suse.de>
To: Steve Sistare <steven.sistare@oracle.com>, qemu-devel@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>,
Steve Sistare <steven.sistare@oracle.com>
Subject: Re: [PATCH V1 09/11] migration-test: migrate_args
Date: Tue, 30 Sep 2025 16:51:11 -0300 [thread overview]
Message-ID: <87a52bvhw0.fsf@suse.de> (raw)
In-Reply-To: <1758291153-349744-10-git-send-email-steven.sistare@oracle.com>
Steve Sistare <steven.sistare@oracle.com> writes:
> Define the subroutine migrate_args to return the arguments that are
> used to exec the source or target qemu process.
>
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> ---
> tests/qtest/migration/framework.h | 2 ++
> tests/qtest/migration/framework.c | 64 ++++++++++++++++++++++++---------------
> 2 files changed, 41 insertions(+), 25 deletions(-)
>
> diff --git a/tests/qtest/migration/framework.h b/tests/qtest/migration/framework.h
> index 7ff3187..51a8a7e 100644
> --- a/tests/qtest/migration/framework.h
> +++ b/tests/qtest/migration/framework.h
> @@ -226,6 +226,8 @@ typedef struct {
> void wait_for_serial(const char *side);
> void migrate_prepare_for_dirty_mem(QTestState *from);
> void migrate_wait_for_dirty_mem(QTestState *from, QTestState *to);
> +
> +void migrate_args(char **from, char **to, const char *uri, MigrateStart *args);
> int migrate_start(QTestState **from, QTestState **to, const char *uri,
> MigrateStart *args);
> void migrate_end(QTestState *from, QTestState *to, bool test_dest);
> diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/framework.c
> index 8f9e359..2dfb1ee 100644
> --- a/tests/qtest/migration/framework.c
> +++ b/tests/qtest/migration/framework.c
> @@ -258,13 +258,12 @@ static char *test_shmem_path(void)
> return g_strdup_printf("/dev/shm/qemu-%d", getpid());
> }
>
> -int migrate_start(QTestState **from, QTestState **to, const char *uri,
> - MigrateStart *args)
> +void migrate_args(char **from, char **to, const char *uri, MigrateStart *args)
> {
> /* options for source and target */
> g_autofree gchar *arch_opts = NULL;
> - g_autofree gchar *cmd_source = NULL;
> - g_autofree gchar *cmd_target = NULL;
> + gchar *cmd_source = NULL;
> + gchar *cmd_target = NULL;
> const gchar *ignore_stderr;
> g_autofree char *shmem_opts = NULL;
> g_autofree char *shmem_path = NULL;
> @@ -273,23 +272,10 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri,
> const char *memory_size;
> const char *machine_alias, *machine_opts = "";
> g_autofree char *machine = NULL;
> - const char *bootpath;
> - g_autoptr(QList) capabilities = migrate_start_get_qmp_capabilities(args);
> + const char *bootpath = bootfile_get();
> g_autofree char *memory_backend = NULL;
> const char *events;
>
> - if (args->use_shmem) {
> - if (!g_file_test("/dev/shm", G_FILE_TEST_IS_DIR)) {
> - g_test_skip("/dev/shm is not supported");
> - return -1;
> - }
> - }
> -
> - dst_state = (QTestMigrationState) { };
> - src_state = (QTestMigrationState) { };
> - bootpath = bootfile_create(arch, tmpfs, args->suspend_me);
> - src_state.suspend_me = args->suspend_me;
> -
> if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
> memory_size = "150M";
>
> @@ -365,7 +351,7 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri,
> if (!qtest_has_machine(machine_alias)) {
> g_autofree char *msg = g_strdup_printf("machine %s not supported", machine_alias);
> g_test_skip(msg);
> - return -1;
> + return;
A common pitfall is that g_test_skip() doesn't actually ends the
test. The -1 needs to be propagated up, otherwise the test will proceed
with the unsupported machine.
> }
>
> machine = resolve_machine_version(machine_alias, QEMU_ENV_SRC,
> @@ -386,12 +372,6 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri,
> shmem_opts ? shmem_opts : "",
> args->opts_source ? args->opts_source : "",
> ignore_stderr);
> - if (!args->only_target) {
> - *from = qtest_init_ext(QEMU_ENV_SRC, cmd_source, capabilities, true);
> - qtest_qmp_set_event_callback(*from,
> - migrate_watch_for_events,
> - &src_state);
> - }
>
> /*
> * If the monitor connection is deferred, enable events on the command line
> @@ -415,6 +395,39 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri,
> shmem_opts ? shmem_opts : "",
> args->opts_target ? args->opts_target : "",
> ignore_stderr);
> +
> + *from = cmd_source;
> + *to = cmd_target;
> +}
> +
> +int migrate_start(QTestState **from, QTestState **to, const char *uri,
> + MigrateStart *args)
> +{
> + g_autofree gchar *cmd_source = NULL;
> + g_autofree gchar *cmd_target = NULL;
> + g_autoptr(QList) capabilities = migrate_start_get_qmp_capabilities(args);
> +
> + if (args->use_shmem) {
> + if (!g_file_test("/dev/shm", G_FILE_TEST_IS_DIR)) {
> + g_test_skip("/dev/shm is not supported");
> + return -1;
> + }
> + }
> +
> + dst_state = (QTestMigrationState) { };
> + src_state = (QTestMigrationState) { };
> + bootfile_create(qtest_get_arch(), tmpfs, args->suspend_me);
> + src_state.suspend_me = args->suspend_me;
> +
> + migrate_args(&cmd_source, &cmd_target, uri, args);
> +
> + if (!args->only_target) {
> + *from = qtest_init_ext(QEMU_ENV_SRC, cmd_source, capabilities, true);
> + qtest_qmp_set_event_callback(*from,
> + migrate_watch_for_events,
> + &src_state);
> + }
> +
> if (!args->only_source) {
> *to = qtest_init_ext(QEMU_ENV_DST, cmd_target, capabilities,
> !args->defer_target_connect);
> @@ -428,6 +441,7 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri,
> * It's valid because QEMU has already opened this file
> */
> if (args->use_shmem) {
> + g_autofree char *shmem_path = test_shmem_path();
> unlink(shmem_path);
> }
next prev parent reply other threads:[~2025-09-30 19:53 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-19 14:12 [PATCH V1 00/11] cpr-exec test Steve Sistare
2025-09-19 14:12 ` [PATCH V1 01/11] tests/qtest: export qtest_qemu_binary Steve Sistare
2025-09-29 14:47 ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 02/11] tests/qtest: qtest_qemu_args Steve Sistare
2025-09-29 14:51 ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 03/11] tests/qtest: qtest_create_test_state Steve Sistare
2025-09-29 14:52 ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 04/11] tests/qtest: qtest_qemu_spawn_func Steve Sistare
2025-09-29 14:57 ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 05/11] tests/qtest: qtest_init_after_exec Steve Sistare
2025-09-29 14:59 ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 06/11] migration-test: only_source option Steve Sistare
2025-09-29 20:27 ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 07/11] migration-test: shm path accessor Steve Sistare
2025-09-29 20:28 ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 08/11] migration-test: misc exports Steve Sistare
2025-09-19 14:12 ` [PATCH V1 09/11] migration-test: migrate_args Steve Sistare
2025-09-29 20:32 ` Fabiano Rosas
2025-09-30 14:35 ` Steven Sistare
2025-09-30 19:51 ` Fabiano Rosas [this message]
2025-09-30 19:59 ` Steven Sistare
2025-09-30 21:14 ` Steven Sistare
2025-10-01 12:16 ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 10/11] migration-test: strv parameter Steve Sistare
2025-09-19 14:12 ` [PATCH V1 11/11] migration-test: test cpr-exec Steve Sistare
2025-09-30 17:08 ` Peter Xu
2025-09-30 18:23 ` Steven Sistare
2025-09-30 19:02 ` Peter Xu
2025-09-30 19:07 ` Steven Sistare
2025-09-30 14:35 ` [PATCH V1 00/11] cpr-exec test Fabiano Rosas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a52bvhw0.fsf@suse.de \
--to=farosas@suse.de \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=steven.sistare@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.