Skip to content

Commit

Permalink
migration: Fix fd protocol for incoming defer
Browse files Browse the repository at this point in the history
Currently, incoming migration through fd supports only command-line case:
E.g.
    fork();
    fd = open();
    exec("qemu ... -incoming fd:%d", fd);

It's possible to use add-fd commands to pass fd for migration, but it's
invalid case. add-fd works with fdset but not with particular fds.

To work with getfd in incoming defer it's enough to use monitor_fd_param
instead of strtol. monitor_fd_param supports both cases:
* fd:123
* fd:fd_name (added by getfd).

And also the use of monitor_fd_param improves error messages.

Signed-off-by: Yury Kotov <yury-kotov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
  • Loading branch information
Yury Kotov authored and Juan Quintela committed Jun 5, 2019
1 parent f38d7fb commit 61053d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions migration/fd.c
Expand Up @@ -52,12 +52,14 @@ static gboolean fd_accept_incoming_migration(QIOChannel *ioc,
return G_SOURCE_REMOVE;
}

void fd_start_incoming_migration(const char *infd, Error **errp)
void fd_start_incoming_migration(const char *fdname, Error **errp)
{
QIOChannel *ioc;
int fd;
int fd = monitor_fd_param(cur_mon, fdname, errp);
if (fd == -1) {
return;
}

fd = strtol(infd, NULL, 0);
trace_migration_fd_incoming(fd);

ioc = qio_channel_new_fd(fd, errp);
Expand Down
2 changes: 1 addition & 1 deletion migration/fd.h
Expand Up @@ -16,7 +16,7 @@

#ifndef QEMU_MIGRATION_FD_H
#define QEMU_MIGRATION_FD_H
void fd_start_incoming_migration(const char *path, Error **errp);
void fd_start_incoming_migration(const char *fdname, Error **errp);

void fd_start_outgoing_migration(MigrationState *s, const char *fdname,
Error **errp);
Expand Down

0 comments on commit 61053d4

Please sign in to comment.