qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Steve Sistare <steven.sistare@oracle.com>
To: qemu-devel@nongnu.org
Cc: Fabiano Rosas <farosas@suse.de>, Peter Xu <peterx@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Eric Blake <eblake@redhat.com>,
	"Dr. David Alan Gilbert" <dave@treblig.org>,
	Cedric Le Goater <clg@redhat.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Steve Sistare <steven.sistare@oracle.com>
Subject: [PATCH V5 17/19] migration-test: migrate_args
Date: Wed,  1 Oct 2025 08:34:09 -0700	[thread overview]
Message-ID: <1759332851-370353-18-git-send-email-steven.sistare@oracle.com> (raw)
In-Reply-To: <1759332851-370353-1-git-send-email-steven.sistare@oracle.com>

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>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
---
 tests/qtest/migration/framework.h |  2 ++
 tests/qtest/migration/framework.c | 65 ++++++++++++++++++++++++---------------
 2 files changed, 43 insertions(+), 24 deletions(-)

diff --git a/tests/qtest/migration/framework.h b/tests/qtest/migration/framework.h
index ba7145a..02f9681 100644
--- a/tests/qtest/migration/framework.h
+++ b/tests/qtest/migration/framework.h
@@ -223,6 +223,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);
+
+int 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 ca13477..c0b299f 100644
--- a/tests/qtest/migration/framework.c
+++ b/tests/qtest/migration/framework.c
@@ -260,13 +260,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)
+int 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;
@@ -275,23 +274,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";
 
@@ -388,12 +374,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
@@ -417,6 +397,42 @@ 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;
+    return 0;
+}
+
+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;
+
+    if (migrate_args(&cmd_source, &cmd_target, uri, args)) {
+        return -1;
+    }
+
+    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);
@@ -430,6 +446,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);
     }
 
-- 
1.8.3.1



  parent reply	other threads:[~2025-10-01 15:37 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-01 15:33 [PATCH V5 00/19] Live update: cpr-exec Steve Sistare
2025-10-01 15:33 ` [PATCH V5 01/19] migration: multi-mode notifier Steve Sistare
2025-10-01 15:33 ` [PATCH V5 02/19] migration: add cpr_walk_fd Steve Sistare
2025-10-01 15:33 ` [PATCH V5 03/19] oslib: qemu_clear_cloexec Steve Sistare
2025-10-01 15:33 ` [PATCH V5 04/19] migration: cpr-exec-command parameter Steve Sistare
2025-10-01 15:33 ` [PATCH V5 05/19] migration: cpr-exec save and load Steve Sistare
2025-10-01 16:36   ` Peter Xu
2025-10-01 15:33 ` [PATCH V5 06/19] migration: cpr-exec mode Steve Sistare
2025-10-01 15:33 ` [PATCH V5 07/19] migration: cpr-exec docs Steve Sistare
2025-10-01 15:34 ` [PATCH V5 08/19] vfio: cpr-exec mode Steve Sistare
2025-10-01 15:34 ` [PATCH V5 09/19] tests/qtest: export qtest_qemu_binary Steve Sistare
2025-10-01 15:34 ` [PATCH V5 10/19] tests/qtest: qtest_qemu_args Steve Sistare
2025-10-01 15:34 ` [PATCH V5 11/19] tests/qtest: qtest_create_test_state Steve Sistare
2025-10-01 15:34 ` [PATCH V5 12/19] tests/qtest: qtest_qemu_spawn_func Steve Sistare
2025-10-01 15:34 ` [PATCH V5 13/19] tests/qtest: qtest_init_after_exec Steve Sistare
2025-10-01 15:34 ` [PATCH V5 14/19] migration-test: only_source option Steve Sistare
2025-10-01 15:34 ` [PATCH V5 15/19] migration-test: shm path accessor Steve Sistare
2025-10-01 15:34 ` [PATCH V5 16/19] migration-test: misc exports Steve Sistare
2025-10-01 15:34 ` Steve Sistare [this message]
2025-10-01 15:34 ` [PATCH V5 18/19] migration-test: strv parameter Steve Sistare
2025-10-01 15:34 ` [PATCH V5 19/19] migration-test: test cpr-exec Steve Sistare
2025-10-01 18:56 ` [PATCH V5 00/19] Live update: cpr-exec Peter Xu
2025-10-01 19:07   ` Steven Sistare
2025-10-01 19:24     ` Steven Sistare
2025-10-01 20:05       ` Peter Xu
2025-10-02 12:44         ` Steven Sistare
2025-10-02  8:48       ` Cédric Le Goater
2025-10-01 20:03     ` Peter Xu
2025-10-02  8:50       ` Cédric Le Goater
2025-10-02 13:45         ` Steven Sistare
2025-10-02 13:44       ` Steven Sistare
2025-10-03 11:36         ` Steven Sistare
2025-10-03 13:11           ` Peter Xu
2025-10-03 13:36             ` Steven Sistare

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=1759332851-370353-18-git-send-email-steven.sistare@oracle.com \
    --to=steven.sistare@oracle.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=clg@redhat.com \
    --cc=dave@treblig.org \
    --cc=eblake@redhat.com \
    --cc=farosas@suse.de \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).