int fd_start_outgoing_migration(MigrationState *s, const char *fdname)

{

    s->fd = monitor_get_fd(s->mon, fdname);

    if (s->fd == -1) {

        DPRINTF("fd_migration: invalid file descriptor identifier\n");

        goto err_after_get_fd;

    }



    if (fcntl(s->fd, F_SETFL, O_NONBLOCK) == -1) {

        DPRINTF("Unable to set nonblocking mode on file descriptor\n");

        goto err_after_open;

    }



    s->get_error = fd_errno;

    s->write = fd_write;

    s->close = fd_close;



    migrate_fd_connect(s);

    return 0;



err_after_open:

    close(s->fd);

err_after_get_fd:

    return -1;

}

int fd_start_outgoing_migration(MigrationState *s, const char *fdname)

{

    s->fd = monitor_get_fd(s->mon, fdname);

    if (s->fd == -1) {

        DPRINTF("fd_migration: invalid file descriptor identifier\n");

        goto err_after_get_fd;

    }



    if (fcntl(s->fd, F_SETFL, O_NONBLOCK) == -1) {

        DPRINTF("Unable to set nonblocking mode on file descriptor\n");

        goto err_after_open;

    }



    s->get_error = fd_errno;

    s->write = fd_write;

    s->close = fd_close;



    migrate_fd_connect(s);

    return 0;



err_after_open:

    close(s->fd);

err_after_get_fd:

    return -1;

}

int FUNC_0(MigrationState *VAR_0, const char *VAR_1)

{

    VAR_0->fd = monitor_get_fd(VAR_0->mon, VAR_1);

    if (VAR_0->fd == -1) {

        DPRINTF("fd_migration: invalid file descriptor identifier\n");

        goto err_after_get_fd;

    }



    if (fcntl(VAR_0->fd, F_SETFL, O_NONBLOCK) == -1) {

        DPRINTF("Unable to set nonblocking mode on file descriptor\n");

        goto err_after_open;

    }



    VAR_0->get_error = fd_errno;

    VAR_0->write = fd_write;

    VAR_0->close = fd_close;



    migrate_fd_connect(VAR_0);

    return 0;



err_after_open:

    close(VAR_0->fd);

err_after_get_fd:

    return -1;

}

int FUNC_0(MigrationState *VAR_0, const char *VAR_1)
{ VAR_0->fd = monitor_get_fd(VAR_0->mon, VAR_1); if (VAR_0->fd == -1) { DPRINTF("fd_migration: invalid file descriptor identifier\n"); goto err_after_get_fd; } if (fcntl(VAR_0->fd, F_SETFL, O_NONBLOCK) == -1) { DPRINTF("Unable to set nonblocking mode on file descriptor\n"); goto err_after_open; } VAR_0->get_error = fd_errno; VAR_0->write = fd_write; VAR_0->close = fd_close; migrate_fd_connect(VAR_0); return 0; err_after_open:
close(VAR_0->fd); err_after_get_fd:
return -1; }