mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
migration/multifd: Add outgoing QIOChannelFile support
Allow multifd to open file-backed channels. This will be used when enabling the mapped-ram migration stream format which expects a seekable transport. The QIOChannel read and write methods will use the preadv/pwritev versions which don't update the file offset at each call so we can reuse the fd without re-opening for every channel. Contrary to the socket migration, the file migration doesn't need an asynchronous channel creation process, so expose multifd_channel_connect() and call it directly. Note that this is just setup code and multifd cannot yet make use of the file channels. Signed-off-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/r/20240229153017.2221-18-farosas@suse.de Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
parent
a8a3e7102c
commit
b7b03eb614
4 changed files with 57 additions and 3 deletions
|
@ -12,12 +12,17 @@
|
|||
#include "channel.h"
|
||||
#include "file.h"
|
||||
#include "migration.h"
|
||||
#include "multifd.h"
|
||||
#include "io/channel-file.h"
|
||||
#include "io/channel-util.h"
|
||||
#include "trace.h"
|
||||
|
||||
#define OFFSET_OPTION ",offset="
|
||||
|
||||
static struct FileOutgoingArgs {
|
||||
char *fname;
|
||||
} outgoing_args;
|
||||
|
||||
/* Remove the offset option from @filespec and return it in @offsetp. */
|
||||
|
||||
int file_parse_offset(char *filespec, uint64_t *offsetp, Error **errp)
|
||||
|
@ -37,6 +42,36 @@ int file_parse_offset(char *filespec, uint64_t *offsetp, Error **errp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void file_cleanup_outgoing_migration(void)
|
||||
{
|
||||
g_free(outgoing_args.fname);
|
||||
outgoing_args.fname = NULL;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
multifd_channel_connect(opaque, QIO_CHANNEL(ioc));
|
||||
|
||||
out:
|
||||
/*
|
||||
* File channel creation is synchronous. However posting this
|
||||
* semaphore here is simpler than adding a special case.
|
||||
*/
|
||||
multifd_send_channel_created();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void file_start_outgoing_migration(MigrationState *s,
|
||||
FileMigrationArgs *file_args, Error **errp)
|
||||
{
|
||||
|
@ -53,6 +88,8 @@ void file_start_outgoing_migration(MigrationState *s,
|
|||
return;
|
||||
}
|
||||
|
||||
outgoing_args.fname = g_strdup(filename);
|
||||
|
||||
ioc = QIO_CHANNEL(fioc);
|
||||
if (offset && qio_channel_io_seek(ioc, offset, SEEK_SET, errp) < 0) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue