static int writev_f(BlockBackend *blk, int argc, char **argv)

{

    struct timeval t1, t2;

    int Cflag = 0, qflag = 0;

    int c, cnt;

    char *buf;

    int64_t offset;

    /* Some compilers get confused and warn if this is not initialized.  */

    int total = 0;

    int nr_iov;

    int pattern = 0xcd;

    QEMUIOVector qiov;



    while ((c = getopt(argc, argv, "CqP:")) != EOF) {

        switch (c) {

        case 'C':

            Cflag = 1;

            break;

        case 'q':

            qflag = 1;

            break;

        case 'P':

            pattern = parse_pattern(optarg);

            if (pattern < 0) {

                return 0;

            }

            break;

        default:

            return qemuio_command_usage(&writev_cmd);

        }

    }



    if (optind > argc - 2) {

        return qemuio_command_usage(&writev_cmd);

    }



    offset = cvtnum(argv[optind]);

    if (offset < 0) {

        printf("non-numeric length argument -- %s\n", argv[optind]);

        return 0;

    }

    optind++;



    if (offset & 0x1ff) {

        printf("offset %" PRId64 " is not sector aligned\n",

               offset);

        return 0;

    }



    nr_iov = argc - optind;

    buf = create_iovec(blk, &qiov, &argv[optind], nr_iov, pattern);

    if (buf == NULL) {

        return 0;

    }



    gettimeofday(&t1, NULL);

    cnt = do_aio_writev(blk, &qiov, offset, &total);

    gettimeofday(&t2, NULL);



    if (cnt < 0) {

        printf("writev failed: %s\n", strerror(-cnt));

        goto out;

    }



    if (qflag) {

        goto out;

    }



    /* Finally, report back -- -C gives a parsable format */

    t2 = tsub(t2, t1);

    print_report("wrote", &t2, offset, qiov.size, total, cnt, Cflag);

out:

    qemu_iovec_destroy(&qiov);

    qemu_io_free(buf);

    return 0;

}

static int writev_f(BlockBackend *blk, int argc, char **argv)

{

    struct timeval t1, t2;

    int Cflag = 0, qflag = 0;

    int c, cnt;

    char *buf;

    int64_t offset;

    

    int total = 0;

    int nr_iov;

    int pattern = 0xcd;

    QEMUIOVector qiov;



    while ((c = getopt(argc, argv, "CqP:")) != EOF) {

        switch (c) {

        case 'C':

            Cflag = 1;

            break;

        case 'q':

            qflag = 1;

            break;

        case 'P':

            pattern = parse_pattern(optarg);

            if (pattern < 0) {

                return 0;

            }

            break;

        default:

            return qemuio_command_usage(&writev_cmd);

        }

    }



    if (optind > argc - 2) {

        return qemuio_command_usage(&writev_cmd);

    }



    offset = cvtnum(argv[optind]);

    if (offset < 0) {

        printf("non-numeric length argument -- %s\n", argv[optind]);

        return 0;

    }

    optind++;



    if (offset & 0x1ff) {

        printf("offset %" PRId64 " is not sector aligned\n",

               offset);

        return 0;

    }



    nr_iov = argc - optind;

    buf = create_iovec(blk, &qiov, &argv[optind], nr_iov, pattern);

    if (buf == NULL) {

        return 0;

    }



    gettimeofday(&t1, NULL);

    cnt = do_aio_writev(blk, &qiov, offset, &total);

    gettimeofday(&t2, NULL);



    if (cnt < 0) {

        printf("writev failed: %s\n", strerror(-cnt));

        goto out;

    }



    if (qflag) {

        goto out;

    }



    

    t2 = tsub(t2, t1);

    print_report("wrote", &t2, offset, qiov.size, total, cnt, Cflag);

out:

    qemu_iovec_destroy(&qiov);

    qemu_io_free(buf);

    return 0;

}

static int FUNC_0(BlockBackend *VAR_0, int VAR_1, char **VAR_2)

{

    struct timeval VAR_3, VAR_4;

    int VAR_5 = 0, VAR_6 = 0;

    int VAR_7, VAR_8;

    char *VAR_9;

    int64_t offset;

    

    int VAR_10 = 0;

    int VAR_11;

    int VAR_12 = 0xcd;

    QEMUIOVector qiov;



    while ((VAR_7 = getopt(VAR_1, VAR_2, "CqP:")) != EOF) {

        switch (VAR_7) {

        case 'C':

            VAR_5 = 1;

            break;

        case 'q':

            VAR_6 = 1;

            break;

        case 'P':

            VAR_12 = parse_pattern(optarg);

            if (VAR_12 < 0) {

                return 0;

            }

            break;

        default:

            return qemuio_command_usage(&writev_cmd);

        }

    }



    if (optind > VAR_1 - 2) {

        return qemuio_command_usage(&writev_cmd);

    }



    offset = cvtnum(VAR_2[optind]);

    if (offset < 0) {

        printf("non-numeric length argument -- %s\n", VAR_2[optind]);

        return 0;

    }

    optind++;



    if (offset & 0x1ff) {

        printf("offset %" PRId64 " is not sector aligned\n",

               offset);

        return 0;

    }



    VAR_11 = VAR_1 - optind;

    VAR_9 = create_iovec(VAR_0, &qiov, &VAR_2[optind], VAR_11, VAR_12);

    if (VAR_9 == NULL) {

        return 0;

    }



    gettimeofday(&VAR_3, NULL);

    VAR_8 = do_aio_writev(VAR_0, &qiov, offset, &VAR_10);

    gettimeofday(&VAR_4, NULL);



    if (VAR_8 < 0) {

        printf("writev failed: %s\n", strerror(-VAR_8));

        goto out;

    }



    if (VAR_6) {

        goto out;

    }



    

    VAR_4 = tsub(VAR_4, VAR_3);

    print_report("wrote", &VAR_4, offset, qiov.size, VAR_10, VAR_8, VAR_5);

out:

    qemu_iovec_destroy(&qiov);

    qemu_io_free(VAR_9);

    return 0;

}

static int FUNC_0(BlockBackend *VAR_0, int VAR_1, char **VAR_2)
{ struct timeval VAR_3, VAR_4; int VAR_5 = 0, VAR_6 = 0; int VAR_7, VAR_8; char *VAR_9; int64_t offset; int VAR_10 = 0; int VAR_11; int VAR_12 = 0xcd; QEMUIOVector qiov; while ((VAR_7 = getopt(VAR_1, VAR_2, "CqP:")) != EOF) { switch (VAR_7) { case 'C':
VAR_5 = 1; break; case 'q':
VAR_6 = 1; break; case 'P':
VAR_12 = parse_pattern(optarg); if (VAR_12 < 0) { return 0; } break; default:
return qemuio_command_usage(&writev_cmd); } } if (optind > VAR_1 - 2) { return qemuio_command_usage(&writev_cmd); } offset = cvtnum(VAR_2[optind]); if (offset < 0) { printf("non-numeric length argument -- %s\n", VAR_2[optind]); return 0; } optind++; if (offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned\n",
offset); return 0; } VAR_11 = VAR_1 - optind; VAR_9 = create_iovec(VAR_0, &qiov, &VAR_2[optind], VAR_11, VAR_12); if (VAR_9 == NULL) { return 0; } gettimeofday(&VAR_3, NULL); VAR_8 = do_aio_writev(VAR_0, &qiov, offset, &VAR_10); gettimeofday(&VAR_4, NULL); if (VAR_8 < 0) { printf("writev failed: %s\n", strerror(-VAR_8)); goto out; } if (VAR_6) { goto out; } VAR_4 = tsub(VAR_4, VAR_3); print_report("wrote", &VAR_4, offset, qiov.size, VAR_10, VAR_8, VAR_5); out:
qemu_iovec_destroy(&qiov); qemu_io_free(VAR_9); return 0; }