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

{

    int nr_iov, c;

    int pattern = 0xcd;

    struct aio_ctx *ctx = g_new0(struct aio_ctx, 1);



    ctx->blk = blk;

    while ((c = getopt(argc, argv, "CqP:z")) != -1) {

        switch (c) {

        case 'C':

            ctx->Cflag = 1;

            break;

        case 'q':

            ctx->qflag = 1;

            break;

        case 'P':

            pattern = parse_pattern(optarg);

            if (pattern < 0) {


                return 0;

            }

            break;

        case 'z':

            ctx->zflag = 1;

            break;

        default:


            return qemuio_command_usage(&aio_write_cmd);

        }

    }



    if (optind > argc - 2) {


        return qemuio_command_usage(&aio_write_cmd);

    }



    if (ctx->zflag && optind != argc - 2) {

        printf("-z supports only a single length parameter\n");


        return 0;

    }



    if (ctx->zflag && ctx->Pflag) {

        printf("-z and -P cannot be specified at the same time\n");


        return 0;

    }



    ctx->offset = cvtnum(argv[optind]);

    if (ctx->offset < 0) {

        print_cvtnum_err(ctx->offset, argv[optind]);


        return 0;

    }

    optind++;



    if (ctx->offset & 0x1ff) {

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

               ctx->offset);

        block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_WRITE);


        return 0;

    }



    if (ctx->zflag) {

        int64_t count = cvtnum(argv[optind]);

        if (count < 0) {

            print_cvtnum_err(count, argv[optind]);


            return 0;

        }



        ctx->qiov.size = count;

        blk_aio_write_zeroes(blk, ctx->offset >> 9, count >> 9, 0,

                             aio_write_done, ctx);

    } else {

        nr_iov = argc - optind;

        ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov,

                                pattern);

        if (ctx->buf == NULL) {

            block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_WRITE);


            return 0;

        }



        gettimeofday(&ctx->t1, NULL);

        block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size,

                         BLOCK_ACCT_WRITE);



        blk_aio_writev(blk, ctx->offset >> 9, &ctx->qiov,

                       ctx->qiov.size >> 9, aio_write_done, ctx);

    }

    return 0;

}
static int aio_write_f(BlockBackend *blk, int argc, char **argv)

{

    int nr_iov, c;

    int pattern = 0xcd;

    struct aio_ctx *ctx = g_new0(struct aio_ctx, 1);



    ctx->blk = blk;

    while ((c = getopt(argc, argv, "CqP:z")) != -1) {

        switch (c) {

        case 'C':

            ctx->Cflag = 1;

            break;

        case 'q':

            ctx->qflag = 1;

            break;

        case 'P':

            pattern = parse_pattern(optarg);

            if (pattern < 0) {


                return 0;

            }

            break;

        case 'z':

            ctx->zflag = 1;

            break;

        default:


            return qemuio_command_usage(&aio_write_cmd);

        }

    }



    if (optind > argc - 2) {


        return qemuio_command_usage(&aio_write_cmd);

    }



    if (ctx->zflag && optind != argc - 2) {

        printf("-z supports only a single length parameter\n");


        return 0;

    }



    if (ctx->zflag && ctx->Pflag) {

        printf("-z and -P cannot be specified at the same time\n");


        return 0;

    }



    ctx->offset = cvtnum(argv[optind]);

    if (ctx->offset < 0) {

        print_cvtnum_err(ctx->offset, argv[optind]);


        return 0;

    }

    optind++;



    if (ctx->offset & 0x1ff) {

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

               ctx->offset);

        block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_WRITE);


        return 0;

    }



    if (ctx->zflag) {

        int64_t count = cvtnum(argv[optind]);

        if (count < 0) {

            print_cvtnum_err(count, argv[optind]);


            return 0;

        }



        ctx->qiov.size = count;

        blk_aio_write_zeroes(blk, ctx->offset >> 9, count >> 9, 0,

                             aio_write_done, ctx);

    } else {

        nr_iov = argc - optind;

        ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov,

                                pattern);

        if (ctx->buf == NULL) {

            block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_WRITE);


            return 0;

        }



        gettimeofday(&ctx->t1, NULL);

        block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size,

                         BLOCK_ACCT_WRITE);



        blk_aio_writev(blk, ctx->offset >> 9, &ctx->qiov,

                       ctx->qiov.size >> 9, aio_write_done, ctx);

    }

    return 0;

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

{

    int VAR_3, VAR_4;

    int VAR_5 = 0xcd;

    struct aio_ctx *VAR_6 = g_new0(struct aio_ctx, 1);



    VAR_6->VAR_0 = VAR_0;

    while ((VAR_4 = getopt(VAR_1, VAR_2, "CqP:z")) != -1) {

        switch (VAR_4) {

        case 'C':

            VAR_6->Cflag = 1;

            break;

        case 'q':

            VAR_6->qflag = 1;

            break;

        case 'P':

            VAR_5 = parse_pattern(optarg);

            if (VAR_5 < 0) {


                return 0;

            }

            break;

        case 'z':

            VAR_6->zflag = 1;

            break;

        default:


            return qemuio_command_usage(&aio_write_cmd);

        }

    }



    if (optind > VAR_1 - 2) {


        return qemuio_command_usage(&aio_write_cmd);

    }



    if (VAR_6->zflag && optind != VAR_1 - 2) {

        printf("-z supports only a single length parameter\n");


        return 0;

    }



    if (VAR_6->zflag && VAR_6->Pflag) {

        printf("-z and -P cannot be specified at the same time\n");


        return 0;

    }



    VAR_6->offset = cvtnum(VAR_2[optind]);

    if (VAR_6->offset < 0) {

        print_cvtnum_err(VAR_6->offset, VAR_2[optind]);


        return 0;

    }

    optind++;



    if (VAR_6->offset & 0x1ff) {

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

               VAR_6->offset);

        block_acct_invalid(blk_get_stats(VAR_0), BLOCK_ACCT_WRITE);


        return 0;

    }



    if (VAR_6->zflag) {

        int64_t count = cvtnum(VAR_2[optind]);

        if (count < 0) {

            print_cvtnum_err(count, VAR_2[optind]);


            return 0;

        }



        VAR_6->qiov.size = count;

        blk_aio_write_zeroes(VAR_0, VAR_6->offset >> 9, count >> 9, 0,

                             aio_write_done, VAR_6);

    } else {

        VAR_3 = VAR_1 - optind;

        VAR_6->buf = create_iovec(VAR_0, &VAR_6->qiov, &VAR_2[optind], VAR_3,

                                VAR_5);

        if (VAR_6->buf == NULL) {

            block_acct_invalid(blk_get_stats(VAR_0), BLOCK_ACCT_WRITE);


            return 0;

        }



        gettimeofday(&VAR_6->t1, NULL);

        block_acct_start(blk_get_stats(VAR_0), &VAR_6->acct, VAR_6->qiov.size,

                         BLOCK_ACCT_WRITE);



        blk_aio_writev(VAR_0, VAR_6->offset >> 9, &VAR_6->qiov,

                       VAR_6->qiov.size >> 9, aio_write_done, VAR_6);

    }

    return 0;

}
static int FUNC_0(BlockBackend *VAR_0, int VAR_1, char **VAR_2)
{ int VAR_3, VAR_4; int VAR_5 = 0xcd; struct aio_ctx *VAR_6 = g_new0(struct aio_ctx, 1); VAR_6->VAR_0 = VAR_0; while ((VAR_4 = getopt(VAR_1, VAR_2, "CqP:z")) != -1) { switch (VAR_4) { case 'C':
VAR_6->Cflag = 1; break; case 'q':
VAR_6->qflag = 1; break; case 'P':
VAR_5 = parse_pattern(optarg); if (VAR_5 < 0) { return 0; } break; case 'z':
VAR_6->zflag = 1; break; default:
return qemuio_command_usage(&aio_write_cmd); } } if (optind > VAR_1 - 2) { return qemuio_command_usage(&aio_write_cmd); } if (VAR_6->zflag && optind != VAR_1 - 2) { printf("-z supports only a single length parameter\n"); return 0; } if (VAR_6->zflag && VAR_6->Pflag) { printf("-z and -P cannot be specified at the same time\n"); return 0; } VAR_6->offset = cvtnum(VAR_2[optind]); if (VAR_6->offset < 0) { print_cvtnum_err(VAR_6->offset, VAR_2[optind]); return 0; } optind++; if (VAR_6->offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned\n",
VAR_6->offset); block_acct_invalid(blk_get_stats(VAR_0), BLOCK_ACCT_WRITE); return 0; } if (VAR_6->zflag) { int64_t count = cvtnum(VAR_2[optind]); if (count < 0) { print_cvtnum_err(count, VAR_2[optind]); return 0; } VAR_6->qiov.size = count; blk_aio_write_zeroes(VAR_0, VAR_6->offset >> 9, count >> 9, 0,
aio_write_done, VAR_6); } else { VAR_3 = VAR_1 - optind; VAR_6->buf = create_iovec(VAR_0, &VAR_6->qiov, &VAR_2[optind], VAR_3,
VAR_5); if (VAR_6->buf == NULL) { block_acct_invalid(blk_get_stats(VAR_0), BLOCK_ACCT_WRITE); return 0; } gettimeofday(&VAR_6->t1, NULL); block_acct_start(blk_get_stats(VAR_0), &VAR_6->acct, VAR_6->qiov.size,
BLOCK_ACCT_WRITE); blk_aio_writev(VAR_0, VAR_6->offset >> 9, &VAR_6->qiov,
VAR_6->qiov.size >> 9, aio_write_done, VAR_6); } return 0; }