[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL 25/27] migration/multifd: Add mapped-ram support to fd: URI
From: |
Peter Maydell |
Subject: |
Re: [PULL 25/27] migration/multifd: Add mapped-ram support to fd: URI |
Date: |
Mon, 11 Mar 2024 11:50:47 +0000 |
On Mon, 4 Mar 2024 at 01:28, <peterx@redhat.com> wrote:
>
> From: Fabiano Rosas <farosas@suse.de>
>
> If we receive a file descriptor that points to a regular file, there's
> nothing stopping us from doing multifd migration with mapped-ram to
> that file.
>
> Enable the fd: URI to work with multifd + mapped-ram.
>
> Note that the fds passed into multifd are duplicated because we want
> to avoid cross-thread effects when doing cleanup (i.e. close(fd)). The
> original fd doesn't need to be duplicated because monitor_get_fd()
> transfers ownership to the caller.
>
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> Reviewed-by: Peter Xu <peterx@redhat.com>
> Link: https://lore.kernel.org/r/20240229153017.2221-23-farosas@suse.de
> Signed-off-by: Peter Xu <peterx@redhat.com>
Hi; Coverity points out some issues with this commit (CID 1539961, 1539965):
> @@ -73,4 +98,23 @@ void fd_start_incoming_migration(const char *fdname, Error
> **errp)
> fd_accept_incoming_migration,
> NULL, NULL,
> g_main_context_get_thread_default());
> +
> + if (migrate_multifd()) {
> + int channels = migrate_multifd_channels();
> +
> + while (channels--) {
> + ioc = QIO_CHANNEL(qio_channel_file_new_fd(dup(fd)));
dup() can fail and return -1, but we don't check for failure
and pass the return value directly to qio_channel_file_new_fd(),
which will call lseek() on it, which isn't valid.
> +
> + if (QIO_CHANNEL_FILE(ioc)->fd == -1) {
> + error_setg(errp, "Failed to duplicate fd %d", fd);
> + return;
> + }
> +
> + qio_channel_set_name(ioc, "migration-fd-incoming");
> + qio_channel_add_watch_full(ioc, G_IO_IN,
> + fd_accept_incoming_migration,
> + NULL, NULL,
> + g_main_context_get_thread_default());
> + }
> + }
> @@ -53,15 +54,20 @@ bool file_send_channel_create(gpointer opaque, Error
> **errp)
> {
> QIOChannelFile *ioc;
> int flags = O_WRONLY;
> - bool ret = true;
> -
> - ioc = qio_channel_file_new_path(outgoing_args.fname, flags, 0, errp);
> - if (!ioc) {
> - ret = false;
> - goto out;
> + bool ret = false;
> + int fd = fd_args_get_fd();
> +
> + if (fd && fd != -1) {
> + ioc = qio_channel_file_new_fd(dup(fd));
Similarly here.
> + } else {
> + ioc = qio_channel_file_new_path(outgoing_args.fname, flags, 0, errp);
> + if (!ioc) {
> + goto out;
> + }
> }
>
> multifd_channel_connect(opaque, QIO_CHANNEL(ioc));
> + ret = true;
>
> out:
> /*
thanks
-- PMM
- [PULL 15/27] migration/multifd: Rename MultiFDSend|RecvParams::data to compress_data, (continued)
- [PULL 15/27] migration/multifd: Rename MultiFDSend|RecvParams::data to compress_data, peterx, 2024/03/03
- [PULL 21/27] migration/multifd: Add incoming QIOChannelFile support, peterx, 2024/03/03
- [PULL 18/27] migration/multifd: Allow receiving pages without packets, peterx, 2024/03/03
- [PULL 24/27] migration/multifd: Support incoming mapped-ram stream format, peterx, 2024/03/03
- [PULL 17/27] migration/multifd: Allow multifd without packets, peterx, 2024/03/03
- [PULL 19/27] migration/multifd: Add a wrapper for channels_created, peterx, 2024/03/03
- [PULL 20/27] migration/multifd: Add outgoing QIOChannelFile support, peterx, 2024/03/03
- [PULL 23/27] migration/multifd: Support outgoing mapped-ram stream format, peterx, 2024/03/03
- [PULL 26/27] tests/qtest/migration: Add a multifd + mapped-ram migration test, peterx, 2024/03/03
- [PULL 25/27] migration/multifd: Add mapped-ram support to fd: URI, peterx, 2024/03/03
- [PULL 22/27] migration/multifd: Prepare multifd sync for mapped-ram migration, peterx, 2024/03/03
- [PULL 27/27] migration/multifd: Document two places for mapped-ram, peterx, 2024/03/03
- Re: [PULL 00/27] Migration next patches, Peter Maydell, 2024/03/05