qemu-devel
[Top][All Lists]
Advanced

[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: Daniel P . Berrangé
Subject: Re: [PULL 25/27] migration/multifd: Add mapped-ram support to fd: URI
Date: Mon, 11 Mar 2024 12:03:41 +0000
User-agent: Mutt/2.2.12 (2023-09-09)

On Mon, Mar 04, 2024 at 09:26:32AM +0800, 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>
> ---
>  migration/fd.h        |  2 ++
>  migration/fd.c        | 44 +++++++++++++++++++++++++++++++++++++++++++
>  migration/file.c      | 18 ++++++++++++------
>  migration/migration.c |  4 ++++
>  migration/multifd.c   |  2 ++
>  5 files changed, 64 insertions(+), 6 deletions(-)
> 

> @@ -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)));
> +
> +            if (QIO_CHANNEL_FILE(ioc)->fd == -1) {
> +                error_setg(errp, "Failed to duplicate fd %d", fd);
> +                return;
> +            }

I'd suggest that Peter's comment about failure checks be fixed
by introducing a new constructor that handles the dup + error
reporting.

   QIOChannel *qio_channel_file_new_dupfd(int fd, Error **errp;)

so we're not repeating the error reporting multiple places.

> +
> +            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());
> +        }
> +    }
>  }

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




reply via email to

[Prev in Thread] Current Thread [Next in Thread]