All of lore.kernel.org
 help / color / mirror / Atom feed
From: peterx@redhat.com
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: "David Hildenbrand" <david@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Cédric Le Goater" <clg@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Peter Xu" <peterx@redhat.com>
Subject: [PULL 03/25] tests/qtest/migration: Add a fd + file test
Date: Wed, 28 Feb 2024 13:12:53 +0800	[thread overview]
Message-ID: <20240228051315.400759-4-peterx@redhat.com> (raw)
In-Reply-To: <20240228051315.400759-1-peterx@redhat.com>

From: Fabiano Rosas <farosas@suse.de>

The fd URI supports an fd that is backed by a file. The code should
select between QIOChannelFile and QIOChannelSocket, depending on the
type of the fd. Add a test for that.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/20240220224138.24759-4-farosas@suse.de
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 tests/qtest/migration-test.c | 41 ++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index b729ce4d22..83512bce85 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -2433,6 +2433,45 @@ static void test_migrate_precopy_fd_socket(void)
     };
     test_precopy_common(&args);
 }
+
+static void *migrate_precopy_fd_file_start(QTestState *from, QTestState *to)
+{
+    g_autofree char *file = g_strdup_printf("%s/%s", tmpfs, FILE_TEST_FILENAME);
+    int src_flags = O_CREAT | O_RDWR;
+    int dst_flags = O_CREAT | O_RDWR;
+    int fds[2];
+
+    fds[0] = open(file, src_flags, 0660);
+    assert(fds[0] != -1);
+
+    fds[1] = open(file, dst_flags, 0660);
+    assert(fds[1] != -1);
+
+
+    qtest_qmp_fds_assert_success(to, &fds[0], 1,
+                                 "{ 'execute': 'getfd',"
+                                 "  'arguments': { 'fdname': 'fd-mig' }}");
+
+    qtest_qmp_fds_assert_success(from, &fds[1], 1,
+                                 "{ 'execute': 'getfd',"
+                                 "  'arguments': { 'fdname': 'fd-mig' }}");
+
+    close(fds[0]);
+    close(fds[1]);
+
+    return NULL;
+}
+
+static void test_migrate_precopy_fd_file(void)
+{
+    MigrateCommon args = {
+        .listen_uri = "defer",
+        .connect_uri = "fd:fd-mig",
+        .start_hook = migrate_precopy_fd_file_start,
+        .finish_hook = test_migrate_fd_finish_hook
+    };
+    test_file_common(&args, true);
+}
 #endif /* _WIN32 */
 
 static void do_test_validate_uuid(MigrateStart *args, bool should_fail)
@@ -3529,6 +3568,8 @@ int main(int argc, char **argv)
 #ifndef _WIN32
     migration_test_add("/migration/precopy/fd/tcp",
                        test_migrate_precopy_fd_socket);
+    migration_test_add("/migration/precopy/fd/file",
+                       test_migrate_precopy_fd_file);
 #endif
     migration_test_add("/migration/validate_uuid", test_validate_uuid);
     migration_test_add("/migration/validate_uuid_error",
-- 
2.43.0



  parent reply	other threads:[~2024-02-28  5:14 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28  5:12 [PULL 00/25] Migration next patches peterx
2024-02-28  5:12 ` [PULL 01/25] docs/devel/migration.rst: Document the file transport peterx
2024-02-28  5:12 ` [PULL 02/25] tests/qtest/migration: Rename fd_proto test peterx
2024-02-28  5:12 ` peterx [this message]
2024-02-28  5:12 ` [PULL 04/25] migration/multifd: Remove p->quit from recv side peterx
2024-02-28  5:12 ` [PULL 05/25] migration/multifd: Release recv sem_sync earlier peterx
2024-02-28  5:12 ` [PULL 06/25] migration/multifd: Cleanup TLS iochannel referencing peterx
2024-02-28  5:12 ` [PULL 07/25] migration/multifd: Drop registered_yank peterx
2024-02-28  5:12 ` [PULL 08/25] migration/multifd: Make multifd_channel_connect() return void peterx
2024-02-28  5:12 ` [PULL 09/25] migration/multifd: Cleanup outgoing_args in state destroy peterx
2024-02-28  5:13 ` [PULL 10/25] migration/multifd: Drop unnecessary helper to destroy IOC peterx
2024-02-28  5:13 ` [PULL 11/25] notify: pass error to notifier with return peterx
2024-02-28  5:13 ` [PULL 12/25] migration: remove error from notifier data peterx
2024-02-28  5:13 ` [PULL 13/25] migration: convert to NotifierWithReturn peterx
2024-02-28  5:13 ` [PULL 14/25] migration: MigrationEvent for notifiers peterx
2024-02-28  5:13 ` [PULL 15/25] migration: remove postcopy_after_devices peterx
2024-02-28  5:13 ` [PULL 16/25] migration: MigrationNotifyFunc peterx
2024-02-28  5:13 ` [PULL 17/25] migration: per-mode notifiers peterx
2024-02-28  5:13 ` [PULL 18/25] migration: refactor migrate_fd_connect failures peterx
2024-02-28  5:13 ` [PULL 19/25] migration: notifier error checking peterx
2024-02-28  5:13 ` [PULL 20/25] migration: stop vm for cpr peterx
2024-02-28  5:13 ` [PULL 21/25] migration: update cpr-reboot description peterx
2024-02-28  5:13 ` [PULL 22/25] migration: options incompatible with cpr peterx
2024-02-28  5:13 ` [PULL 23/25] migration: Fix qmp_query_migrate mbps value peterx
2024-02-28  5:13 ` [PULL 24/25] migration: Join the return path thread before releasing to_dst_file peterx
2024-02-28  5:13 ` [PULL 25/25] migration: Use migrate_has_error() in close_return_path_on_source() peterx
2024-02-29 15:24 ` [PULL 00/25] Migration next patches Peter Maydell

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=20240228051315.400759-4-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=clg@redhat.com \
    --cc=david@redhat.com \
    --cc=eblake@redhat.com \
    --cc=farosas@suse.de \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.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.