static int qcow_create(const char *filename, QEMUOptionParameter *options)

{

    const char *backing_file = NULL;

    const char *backing_fmt = NULL;

    uint64_t sectors = 0;

    int flags = 0;

    size_t cluster_size = 65536;

    int prealloc = 0;



    /* Read out options */

    while (options && options->name) {

        if (!strcmp(options->name, BLOCK_OPT_SIZE)) {

            sectors = options->value.n / 512;

        } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) {

            backing_file = options->value.s;

        } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FMT)) {

            backing_fmt = options->value.s;

        } else if (!strcmp(options->name, BLOCK_OPT_ENCRYPT)) {

            flags |= options->value.n ? BLOCK_FLAG_ENCRYPT : 0;

        } else if (!strcmp(options->name, BLOCK_OPT_CLUSTER_SIZE)) {

            if (options->value.n) {

                cluster_size = options->value.n;

            }

        } else if (!strcmp(options->name, BLOCK_OPT_PREALLOC)) {

            if (!options->value.s || !strcmp(options->value.s, "off")) {

                prealloc = 0;

            } else if (!strcmp(options->value.s, "metadata")) {

                prealloc = 1;

            } else {

                fprintf(stderr, "Invalid preallocation mode: '%s'\n",

                    options->value.s);

                return -EINVAL;

            }

        }

        options++;

    }



    if (backing_file && prealloc) {

        fprintf(stderr, "Backing file and preallocation cannot be used at "

            "the same time\n");

        return -EINVAL;

    }



    return qcow_create2(filename, sectors, backing_file, backing_fmt, flags,

        cluster_size, prealloc);

}

static int qcow_create(const char *filename, QEMUOptionParameter *options)

{

    const char *backing_file = NULL;

    const char *backing_fmt = NULL;

    uint64_t sectors = 0;

    int flags = 0;

    size_t cluster_size = 65536;

    int prealloc = 0;



    

    while (options && options->name) {

        if (!strcmp(options->name, BLOCK_OPT_SIZE)) {

            sectors = options->value.n / 512;

        } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) {

            backing_file = options->value.s;

        } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FMT)) {

            backing_fmt = options->value.s;

        } else if (!strcmp(options->name, BLOCK_OPT_ENCRYPT)) {

            flags |= options->value.n ? BLOCK_FLAG_ENCRYPT : 0;

        } else if (!strcmp(options->name, BLOCK_OPT_CLUSTER_SIZE)) {

            if (options->value.n) {

                cluster_size = options->value.n;

            }

        } else if (!strcmp(options->name, BLOCK_OPT_PREALLOC)) {

            if (!options->value.s || !strcmp(options->value.s, "off")) {

                prealloc = 0;

            } else if (!strcmp(options->value.s, "metadata")) {

                prealloc = 1;

            } else {

                fprintf(stderr, "Invalid preallocation mode: '%s'\n",

                    options->value.s);

                return -EINVAL;

            }

        }

        options++;

    }



    if (backing_file && prealloc) {

        fprintf(stderr, "Backing file and preallocation cannot be used at "

            "the same time\n");

        return -EINVAL;

    }



    return qcow_create2(filename, sectors, backing_file, backing_fmt, flags,

        cluster_size, prealloc);

}

static int FUNC_0(const char *VAR_0, QEMUOptionParameter *VAR_1)

{

    const char *VAR_2 = NULL;

    const char *VAR_3 = NULL;

    uint64_t sectors = 0;

    int VAR_4 = 0;

    size_t cluster_size = 65536;

    int VAR_5 = 0;



    

    while (VAR_1 && VAR_1->name) {

        if (!strcmp(VAR_1->name, BLOCK_OPT_SIZE)) {

            sectors = VAR_1->value.n / 512;

        } else if (!strcmp(VAR_1->name, BLOCK_OPT_BACKING_FILE)) {

            VAR_2 = VAR_1->value.s;

        } else if (!strcmp(VAR_1->name, BLOCK_OPT_BACKING_FMT)) {

            VAR_3 = VAR_1->value.s;

        } else if (!strcmp(VAR_1->name, BLOCK_OPT_ENCRYPT)) {

            VAR_4 |= VAR_1->value.n ? BLOCK_FLAG_ENCRYPT : 0;

        } else if (!strcmp(VAR_1->name, BLOCK_OPT_CLUSTER_SIZE)) {

            if (VAR_1->value.n) {

                cluster_size = VAR_1->value.n;

            }

        } else if (!strcmp(VAR_1->name, BLOCK_OPT_PREALLOC)) {

            if (!VAR_1->value.s || !strcmp(VAR_1->value.s, "off")) {

                VAR_5 = 0;

            } else if (!strcmp(VAR_1->value.s, "metadata")) {

                VAR_5 = 1;

            } else {

                fprintf(stderr, "Invalid preallocation mode: '%s'\n",

                    VAR_1->value.s);

                return -EINVAL;

            }

        }

        VAR_1++;

    }



    if (VAR_2 && VAR_5) {

        fprintf(stderr, "Backing file and preallocation cannot be used at "

            "the same time\n");

        return -EINVAL;

    }



    return qcow_create2(VAR_0, sectors, VAR_2, VAR_3, VAR_4,

        cluster_size, VAR_5);

}

static int FUNC_0(const char *VAR_0, QEMUOptionParameter *VAR_1)
{ const char *VAR_2 = NULL; const char *VAR_3 = NULL; uint64_t sectors = 0; int VAR_4 = 0; size_t cluster_size = 65536; int VAR_5 = 0; while (VAR_1 && VAR_1->name) { if (!strcmp(VAR_1->name, BLOCK_OPT_SIZE)) { sectors = VAR_1->value.n / 512; } else if (!strcmp(VAR_1->name, BLOCK_OPT_BACKING_FILE)) { VAR_2 = VAR_1->value.s; } else if (!strcmp(VAR_1->name, BLOCK_OPT_BACKING_FMT)) { VAR_3 = VAR_1->value.s; } else if (!strcmp(VAR_1->name, BLOCK_OPT_ENCRYPT)) { VAR_4 |= VAR_1->value.n ? BLOCK_FLAG_ENCRYPT : 0; } else if (!strcmp(VAR_1->name, BLOCK_OPT_CLUSTER_SIZE)) { if (VAR_1->value.n) { cluster_size = VAR_1->value.n; } } else if (!strcmp(VAR_1->name, BLOCK_OPT_PREALLOC)) { if (!VAR_1->value.s || !strcmp(VAR_1->value.s, "off")) { VAR_5 = 0; } else if (!strcmp(VAR_1->value.s, "metadata")) { VAR_5 = 1; } else { fprintf(stderr, "Invalid preallocation mode: '%s'\n",
VAR_1->value.s); return -EINVAL; } } VAR_1++; } if (VAR_2 && VAR_5) { fprintf(stderr, "Backing file and preallocation cannot be used at "
"the same time\n"); return -EINVAL; } return qcow_create2(VAR_0, sectors, VAR_2, VAR_3, VAR_4,
cluster_size, VAR_5); }