static int parse_add_fd(QemuOpts *opts, void *opaque)

{

    int fd, dupfd, flags;

    int64_t fdset_id;

    const char *fd_opaque = NULL;



    fd = qemu_opt_get_number(opts, "fd", -1);

    fdset_id = qemu_opt_get_number(opts, "set", -1);

    fd_opaque = qemu_opt_get(opts, "opaque");



    if (fd < 0) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "fd option is required and must be non-negative");

        return -1;

    }



    if (fd <= STDERR_FILENO) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "fd cannot be a standard I/O stream");

        return -1;

    }



    /*

     * All fds inherited across exec() necessarily have FD_CLOEXEC

     * clear, while qemu sets FD_CLOEXEC on all other fds used internally.

     */

    flags = fcntl(fd, F_GETFD);

    if (flags == -1 || (flags & FD_CLOEXEC)) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "fd is not valid or already in use");

        return -1;

    }



    if (fdset_id < 0) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "set option is required and must be non-negative");

        return -1;

    }



#ifdef F_DUPFD_CLOEXEC

    dupfd = fcntl(fd, F_DUPFD_CLOEXEC, 0);

#else

    dupfd = dup(fd);

    if (dupfd != -1) {

        qemu_set_cloexec(dupfd);

    }

#endif

    if (dupfd == -1) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "Error duplicating fd: %s", strerror(errno));

        return -1;

    }



    /* add the duplicate fd, and optionally the opaque string, to the fd set */

    monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,

                         fd_opaque, NULL);



    return 0;

}

static int parse_add_fd(QemuOpts *opts, void *opaque)

{

    int fd, dupfd, flags;

    int64_t fdset_id;

    const char *fd_opaque = NULL;



    fd = qemu_opt_get_number(opts, "fd", -1);

    fdset_id = qemu_opt_get_number(opts, "set", -1);

    fd_opaque = qemu_opt_get(opts, "opaque");



    if (fd < 0) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "fd option is required and must be non-negative");

        return -1;

    }



    if (fd <= STDERR_FILENO) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "fd cannot be a standard I/O stream");

        return -1;

    }



    







    flags = fcntl(fd, F_GETFD);

    if (flags == -1 || (flags & FD_CLOEXEC)) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "fd is not valid or already in use");

        return -1;

    }



    if (fdset_id < 0) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "set option is required and must be non-negative");

        return -1;

    }



#ifdef F_DUPFD_CLOEXEC

    dupfd = fcntl(fd, F_DUPFD_CLOEXEC, 0);

#else

    dupfd = dup(fd);

    if (dupfd != -1) {

        qemu_set_cloexec(dupfd);

    }

#endif

    if (dupfd == -1) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "Error duplicating fd: %s", strerror(errno));

        return -1;

    }



    

    monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,

                         fd_opaque, NULL);



    return 0;

}

    monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,                          fd_opaque, NULL);
static int FUNC_0(QemuOpts *VAR_0, void *VAR_1)

{

    int VAR_2, VAR_3, VAR_4;

    int64_t fdset_id;

    const char *VAR_5 = NULL;



    VAR_2 = qemu_opt_get_number(VAR_0, "VAR_2", -1);

    fdset_id = qemu_opt_get_number(VAR_0, "set", -1);

    VAR_5 = qemu_opt_get(VAR_0, "VAR_1");



    if (VAR_2 < 0) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "VAR_2 option is required and must be non-negative");

        return -1;

    }



    if (VAR_2 <= STDERR_FILENO) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "VAR_2 cannot be a standard I/O stream");

        return -1;

    }



    







    VAR_4 = fcntl(VAR_2, F_GETFD);

    if (VAR_4 == -1 || (VAR_4 & FD_CLOEXEC)) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "VAR_2 is not valid or already in use");

        return -1;

    }



    if (fdset_id < 0) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "set option is required and must be non-negative");

        return -1;

    }



#ifdef F_DUPFD_CLOEXEC

    VAR_3 = fcntl(VAR_2, F_DUPFD_CLOEXEC, 0);

#else

    VAR_3 = dup(VAR_2);

    if (VAR_3 != -1) {

        qemu_set_cloexec(VAR_3);

    }

#endif

    if (VAR_3 == -1) {

        qerror_report(ERROR_CLASS_GENERIC_ERROR,

                      "Error duplicating VAR_2: %s", strerror(errno));

        return -1;

    }



    

    monitor_fdset_add_fd(VAR_3, true, fdset_id, VAR_5 ? true : false,

                         VAR_5, NULL);



    return 0;

}

static int FUNC_0(QemuOpts *VAR_0, void *VAR_1)
{ int VAR_2, VAR_3, VAR_4; int64_t fdset_id; const char *VAR_5 = NULL; VAR_2 = qemu_opt_get_number(VAR_0, "VAR_2", -1); fdset_id = qemu_opt_get_number(VAR_0, "set", -1); VAR_5 = qemu_opt_get(VAR_0, "VAR_1"); if (VAR_2 < 0) { qerror_report(ERROR_CLASS_GENERIC_ERROR,
"VAR_2 option is required and must be non-negative"); return -1; } if (VAR_2 <= STDERR_FILENO) { qerror_report(ERROR_CLASS_GENERIC_ERROR,
"VAR_2 cannot be a standard I/O stream"); return -1; } VAR_4 = fcntl(VAR_2, F_GETFD); if (VAR_4 == -1 || (VAR_4 & FD_CLOEXEC)) { qerror_report(ERROR_CLASS_GENERIC_ERROR,
"VAR_2 is not valid or already in use"); return -1; } if (fdset_id < 0) { qerror_report(ERROR_CLASS_GENERIC_ERROR,
"set option is required and must be non-negative"); return -1; } #ifdef F_DUPFD_CLOEXEC
VAR_3 = fcntl(VAR_2, F_DUPFD_CLOEXEC, 0); #else
VAR_3 = dup(VAR_2); if (VAR_3 != -1) { qemu_set_cloexec(VAR_3); } #endif
if (VAR_3 == -1) { qerror_report(ERROR_CLASS_GENERIC_ERROR,
"Error duplicating VAR_2: %s", strerror(errno)); return -1; } monitor_fdset_add_fd(VAR_3, true, fdset_id, VAR_5 ? true : false,
VAR_5, NULL); return 0; }