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

{

    struct timeval t1, t2;

    int Cflag = 0, qflag = 0, vflag = 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;

    QEMUIOVector qiov;

    int pattern = 0;

    int Pflag = 0;



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

        switch (c) {

        case 'C':

            Cflag = 1;

            break;

        case 'P':

            Pflag = 1;

            pattern = parse_pattern(optarg);

            if (pattern < 0) {

                return 0;

            }

            break;

        case 'q':

            qflag = 1;

            break;

        case 'v':

            vflag = 1;

            break;

        default:

            return qemuio_command_usage(&readv_cmd);

        }

    }



    if (optind > argc - 2) {

        return qemuio_command_usage(&readv_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, 0xab);

    if (buf == NULL) {

        return 0;

    }



    gettimeofday(&t1, NULL);

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

    gettimeofday(&t2, NULL);



    if (cnt < 0) {

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

        goto out;

    }



    if (Pflag) {

        void *cmp_buf = g_malloc(qiov.size);

        memset(cmp_buf, pattern, qiov.size);

        if (memcmp(buf, cmp_buf, qiov.size)) {

            printf("Pattern verification failed at offset %"

                   PRId64 ", %zd bytes\n", offset, qiov.size);

        }

        g_free(cmp_buf);

    }



    if (qflag) {

        goto out;

    }



    if (vflag) {

        dump_buffer(buf, offset, qiov.size);

    }



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

    t2 = tsub(t2, t1);

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



out:

    qemu_iovec_destroy(&qiov);

    qemu_io_free(buf);

    return 0;

}

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

{

    struct timeval t1, t2;

    int Cflag = 0, qflag = 0, vflag = 0;

    int c, cnt;

    char *buf;

    int64_t offset;

    

    int total = 0;

    int nr_iov;

    QEMUIOVector qiov;

    int pattern = 0;

    int Pflag = 0;



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

        switch (c) {

        case 'C':

            Cflag = 1;

            break;

        case 'P':

            Pflag = 1;

            pattern = parse_pattern(optarg);

            if (pattern < 0) {

                return 0;

            }

            break;

        case 'q':

            qflag = 1;

            break;

        case 'v':

            vflag = 1;

            break;

        default:

            return qemuio_command_usage(&readv_cmd);

        }

    }



    if (optind > argc - 2) {

        return qemuio_command_usage(&readv_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, 0xab);

    if (buf == NULL) {

        return 0;

    }



    gettimeofday(&t1, NULL);

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

    gettimeofday(&t2, NULL);



    if (cnt < 0) {

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

        goto out;

    }



    if (Pflag) {

        void *cmp_buf = g_malloc(qiov.size);

        memset(cmp_buf, pattern, qiov.size);

        if (memcmp(buf, cmp_buf, qiov.size)) {

            printf("Pattern verification failed at offset %"

                   PRId64 ", %zd bytes\n", offset, qiov.size);

        }

        g_free(cmp_buf);

    }



    if (qflag) {

        goto out;

    }



    if (vflag) {

        dump_buffer(buf, offset, qiov.size);

    }



    

    t2 = tsub(t2, t1);

    print_report("read", &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, VAR_7 = 0;

    int VAR_8, VAR_9;

    char *VAR_10;

    int64_t offset;

    

    int VAR_11 = 0;

    int VAR_12;

    QEMUIOVector qiov;

    int VAR_13 = 0;

    int VAR_14 = 0;



    while ((VAR_8 = getopt(VAR_1, VAR_2, "CP:qv")) != EOF) {

        switch (VAR_8) {

        case 'C':

            VAR_5 = 1;

            break;

        case 'P':

            VAR_14 = 1;

            VAR_13 = parse_pattern(optarg);

            if (VAR_13 < 0) {

                return 0;

            }

            break;

        case 'q':

            VAR_6 = 1;

            break;

        case 'v':

            VAR_7 = 1;

            break;

        default:

            return qemuio_command_usage(&readv_cmd);

        }

    }



    if (optind > VAR_1 - 2) {

        return qemuio_command_usage(&readv_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_12 = VAR_1 - optind;

    VAR_10 = create_iovec(VAR_0, &qiov, &VAR_2[optind], VAR_12, 0xab);

    if (VAR_10 == NULL) {

        return 0;

    }



    gettimeofday(&VAR_3, NULL);

    VAR_9 = do_aio_readv(VAR_0, &qiov, offset, &VAR_11);

    gettimeofday(&VAR_4, NULL);



    if (VAR_9 < 0) {

        printf("readv failed: %s\n", strerror(-VAR_9));

        goto out;

    }



    if (VAR_14) {

        void *VAR_15 = g_malloc(qiov.size);

        memset(VAR_15, VAR_13, qiov.size);

        if (memcmp(VAR_10, VAR_15, qiov.size)) {

            printf("Pattern verification failed at offset %"

                   PRId64 ", %zd bytes\n", offset, qiov.size);

        }

        g_free(VAR_15);

    }



    if (VAR_6) {

        goto out;

    }



    if (VAR_7) {

        dump_buffer(VAR_10, offset, qiov.size);

    }



    

    VAR_4 = tsub(VAR_4, VAR_3);

    print_report("read", &VAR_4, offset, qiov.size, VAR_11, VAR_9, VAR_5);



out:

    qemu_iovec_destroy(&qiov);

    qemu_io_free(VAR_10);

    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, VAR_7 = 0; int VAR_8, VAR_9; char *VAR_10; int64_t offset; int VAR_11 = 0; int VAR_12; QEMUIOVector qiov; int VAR_13 = 0; int VAR_14 = 0; while ((VAR_8 = getopt(VAR_1, VAR_2, "CP:qv")) != EOF) { switch (VAR_8) { case 'C':
VAR_5 = 1; break; case 'P':
VAR_14 = 1; VAR_13 = parse_pattern(optarg); if (VAR_13 < 0) { return 0; } break; case 'q':
VAR_6 = 1; break; case 'v':
VAR_7 = 1; break; default:
return qemuio_command_usage(&readv_cmd); } } if (optind > VAR_1 - 2) { return qemuio_command_usage(&readv_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_12 = VAR_1 - optind; VAR_10 = create_iovec(VAR_0, &qiov, &VAR_2[optind], VAR_12, 0xab); if (VAR_10 == NULL) { return 0; } gettimeofday(&VAR_3, NULL); VAR_9 = do_aio_readv(VAR_0, &qiov, offset, &VAR_11); gettimeofday(&VAR_4, NULL); if (VAR_9 < 0) { printf("readv failed: %s\n", strerror(-VAR_9)); goto out; } if (VAR_14) { void *VAR_15 = g_malloc(qiov.size); memset(VAR_15, VAR_13, qiov.size); if (memcmp(VAR_10, VAR_15, qiov.size)) { printf("Pattern verification failed at offset %"
PRId64 ", %zd bytes\n", offset, qiov.size); } g_free(VAR_15); } if (VAR_6) { goto out; } if (VAR_7) { dump_buffer(VAR_10, offset, qiov.size); } VAR_4 = tsub(VAR_4, VAR_3); print_report("read", &VAR_4, offset, qiov.size, VAR_11, VAR_9, VAR_5); out:
qemu_iovec_destroy(&qiov); qemu_io_free(VAR_10); return 0; }