static CharDriverState *qemu_chr_open_pty(const char *id,

                                          ChardevBackend *backend,

                                          ChardevReturn *ret,

                                          Error **errp)

{

    CharDriverState *chr;

    PtyCharDriver *s;

    int master_fd, slave_fd;

    char pty_name[PATH_MAX];



    master_fd = qemu_openpty_raw(&slave_fd, pty_name);

    if (master_fd < 0) {

        error_setg_errno(errp, errno, "Failed to create PTY");

        return NULL;

    }



    close(slave_fd);

    qemu_set_nonblock(master_fd);



    chr = qemu_chr_alloc();



    chr->filename = g_strdup_printf("pty:%s", pty_name);

    ret->pty = g_strdup(pty_name);

    ret->has_pty = true;



    fprintf(stderr, "char device redirected to %s (label %s)\n",

            pty_name, id);



    s = g_new0(PtyCharDriver, 1);

    chr->opaque = s;

    chr->chr_write = pty_chr_write;

    chr->chr_update_read_handler = pty_chr_update_read_handler;

    chr->chr_close = pty_chr_close;

    chr->chr_add_watch = pty_chr_add_watch;

    chr->explicit_be_open = true;



    s->fd = io_channel_from_fd(master_fd);

    s->timer_tag = 0;



    return chr;

}

static CharDriverState *qemu_chr_open_pty(const char *id,

                                          ChardevBackend *backend,

                                          ChardevReturn *ret,

                                          Error **errp)

{

    CharDriverState *chr;

    PtyCharDriver *s;

    int master_fd, slave_fd;

    char pty_name[PATH_MAX];



    master_fd = qemu_openpty_raw(&slave_fd, pty_name);

    if (master_fd < 0) {

        error_setg_errno(errp, errno, "Failed to create PTY");

        return NULL;

    }



    close(slave_fd);

    qemu_set_nonblock(master_fd);



    chr = qemu_chr_alloc();



    chr->filename = g_strdup_printf("pty:%s", pty_name);

    ret->pty = g_strdup(pty_name);

    ret->has_pty = true;



    fprintf(stderr, "char device redirected to %s (label %s)\n",

            pty_name, id);



    s = g_new0(PtyCharDriver, 1);

    chr->opaque = s;

    chr->chr_write = pty_chr_write;

    chr->chr_update_read_handler = pty_chr_update_read_handler;

    chr->chr_close = pty_chr_close;

    chr->chr_add_watch = pty_chr_add_watch;

    chr->explicit_be_open = true;



    s->fd = io_channel_from_fd(master_fd);

    s->timer_tag = 0;



    return chr;

}

static CharDriverState *FUNC_0(const char *id,

                                          ChardevBackend *backend,

                                          ChardevReturn *ret,

                                          Error **errp)

{

    CharDriverState *chr;

    PtyCharDriver *s;

    int VAR_0, VAR_1;

    char VAR_2[PATH_MAX];



    VAR_0 = qemu_openpty_raw(&VAR_1, VAR_2);

    if (VAR_0 < 0) {

        error_setg_errno(errp, errno, "Failed to create PTY");

        return NULL;

    }



    close(VAR_1);

    qemu_set_nonblock(VAR_0);



    chr = qemu_chr_alloc();



    chr->filename = g_strdup_printf("pty:%s", VAR_2);

    ret->pty = g_strdup(VAR_2);

    ret->has_pty = true;



    fprintf(stderr, "char device redirected to %s (label %s)\n",

            VAR_2, id);



    s = g_new0(PtyCharDriver, 1);

    chr->opaque = s;

    chr->chr_write = pty_chr_write;

    chr->chr_update_read_handler = pty_chr_update_read_handler;

    chr->chr_close = pty_chr_close;

    chr->chr_add_watch = pty_chr_add_watch;

    chr->explicit_be_open = true;



    s->fd = io_channel_from_fd(VAR_0);

    s->timer_tag = 0;



    return chr;

}

static CharDriverState *FUNC_0(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{ CharDriverState *chr; PtyCharDriver *s; int VAR_0, VAR_1; char VAR_2[PATH_MAX]; VAR_0 = qemu_openpty_raw(&VAR_1, VAR_2); if (VAR_0 < 0) { error_setg_errno(errp, errno, "Failed to create PTY"); return NULL; } close(VAR_1); qemu_set_nonblock(VAR_0); chr = qemu_chr_alloc(); chr->filename = g_strdup_printf("pty:%s", VAR_2); ret->pty = g_strdup(VAR_2); ret->has_pty = true; fprintf(stderr, "char device redirected to %s (label %s)\n",
VAR_2, id); s = g_new0(PtyCharDriver, 1); chr->opaque = s; chr->chr_write = pty_chr_write; chr->chr_update_read_handler = pty_chr_update_read_handler; chr->chr_close = pty_chr_close; chr->chr_add_watch = pty_chr_add_watch; chr->explicit_be_open = true; s->fd = io_channel_from_fd(VAR_0); s->timer_tag = 0; return chr; }