Daniel P. Berrangé <berra...@redhat.com> writes: > On Mon, Oct 23, 2023 at 05:35:59PM -0300, Fabiano Rosas wrote: >> On the receiving side we don't need to differentiate between main >> channel and threads, so whichever channel is defined first gets to be >> the main one. And since there are no packets, use the atomic channel >> count to index into the params array. >> >> Signed-off-by: Fabiano Rosas <faro...@suse.de> >> --- >> migration/file.c | 39 +++++++++++++++++++++++++++++---------- >> migration/migration.c | 2 ++ >> migration/multifd.c | 7 ++++++- >> migration/multifd.h | 1 + >> 4 files changed, 38 insertions(+), 11 deletions(-) >> >> diff --git a/migration/file.c b/migration/file.c >> index 93b9b7bf5d..ad75225f43 100644 >> --- a/migration/file.c >> +++ b/migration/file.c >> @@ -6,13 +6,15 @@ >> */ >> >> #include "qemu/osdep.h" >> -#include "qemu/cutils.h" >> #include "qapi/error.h" >> +#include "qemu/cutils.h" >> +#include "qemu/error-report.h" >> #include "channel.h" >> #include "file.h" >> #include "migration.h" >> #include "io/channel-file.h" >> #include "io/channel-util.h" >> +#include "options.h" >> #include "trace.h" >> >> #define OFFSET_OPTION ",offset=" >> @@ -136,7 +138,8 @@ void file_start_incoming_migration(const char *filespec, >> Error **errp) >> g_autofree char *filename = g_strdup(filespec); >> QIOChannelFile *fioc = NULL; >> uint64_t offset = 0; >> - QIOChannel *ioc; >> + int channels = 1; >> + int i = 0, fd; >> >> trace_migration_file_incoming(filename); >> >> @@ -146,16 +149,32 @@ void file_start_incoming_migration(const char >> *filespec, Error **errp) >> >> fioc = qio_channel_file_new_path(filename, O_RDONLY, 0, errp); >> if (!fioc) { >> - return; >> + goto out; >> + } >> + >> + if (migrate_multifd()) { >> + channels += migrate_multifd_channels(); >> } >> >> - ioc = QIO_CHANNEL(fioc); >> - if (offset && qio_channel_io_seek(ioc, offset, SEEK_SET, errp) < 0) { >> + fd = fioc->fd; >> + >> + do { >> + QIOChannel *ioc = QIO_CHANNEL(fioc); >> + >> + if (offset && qio_channel_io_seek(ioc, offset, SEEK_SET, errp) < 0) >> { >> + return; >> + } >> + >> + qio_channel_set_name(ioc, "migration-file-incoming"); >> + qio_channel_add_watch_full(ioc, G_IO_IN, >> + file_accept_incoming_migration, >> + NULL, NULL, >> + g_main_context_get_thread_default()); >> + } while (++i < channels && (fioc = qio_channel_file_new_fd(fd))); > > IIUC, this loop is failing to call qio_channel_io_seek to set > the offset on the last 'fioc' that is created. >
Ah, this is actually bogus. We don't need to offset the secondary channels. That does nothing since we carry pointers to everything in the fixed-ram header. This should be out of the loop.