static int qemu_gluster_create(const char *filename,

        QEMUOptionParameter *options, Error **errp)

{

    struct glfs *glfs;

    struct glfs_fd *fd;

    int ret = 0;

    int prealloc = 0;

    int64_t total_size = 0;

    GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));



    glfs = qemu_gluster_init(gconf, filename, errp);

    if (!glfs) {

        ret = -EINVAL;

        goto out;

    }



    while (options && options->name) {

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

            total_size = options->value.n / BDRV_SECTOR_SIZE;

        } 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, "full") &&

                    gluster_supports_zerofill()) {

                prealloc = 1;

            } else {

                error_setg(errp, "Invalid preallocation mode: '%s'"

                    " or GlusterFS doesn't support zerofill API",

                           options->value.s);

                ret = -EINVAL;

                goto out;

            }

        }

        options++;

    }



    fd = glfs_creat(glfs, gconf->image,

        O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);

    if (!fd) {

        ret = -errno;

    } else {

        if (!glfs_ftruncate(fd, total_size * BDRV_SECTOR_SIZE)) {

            if (prealloc && qemu_gluster_zerofill(fd, 0,

                    total_size * BDRV_SECTOR_SIZE)) {

                ret = -errno;

            }

        } else {

            ret = -errno;

        }



        if (glfs_close(fd) != 0) {

            ret = -errno;

        }

    }

out:

    qemu_gluster_gconf_free(gconf);

    if (glfs) {

        glfs_fini(glfs);

    }

    return ret;

}

static int qemu_gluster_create(const char *filename,

        QEMUOptionParameter *options, Error **errp)

{

    struct glfs *glfs;

    struct glfs_fd *fd;

    int ret = 0;

    int prealloc = 0;

    int64_t total_size = 0;

    GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));



    glfs = qemu_gluster_init(gconf, filename, errp);

    if (!glfs) {

        ret = -EINVAL;

        goto out;

    }



    while (options && options->name) {

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

            total_size = options->value.n / BDRV_SECTOR_SIZE;

        } 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, "full") &&

                    gluster_supports_zerofill()) {

                prealloc = 1;

            } else {

                error_setg(errp, "Invalid preallocation mode: '%s'"

                    " or GlusterFS doesn't support zerofill API",

                           options->value.s);

                ret = -EINVAL;

                goto out;

            }

        }

        options++;

    }



    fd = glfs_creat(glfs, gconf->image,

        O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);

    if (!fd) {

        ret = -errno;

    } else {

        if (!glfs_ftruncate(fd, total_size * BDRV_SECTOR_SIZE)) {

            if (prealloc && qemu_gluster_zerofill(fd, 0,

                    total_size * BDRV_SECTOR_SIZE)) {

                ret = -errno;

            }

        } else {

            ret = -errno;

        }



        if (glfs_close(fd) != 0) {

            ret = -errno;

        }

    }

out:

    qemu_gluster_gconf_free(gconf);

    if (glfs) {

        glfs_fini(glfs);

    }

    return ret;

}

        ret = -EINVAL;
static int FUNC_0(const char *VAR_0,

        QEMUOptionParameter *VAR_1, Error **VAR_2)

{

    struct VAR_3 *VAR_3;

    struct glfs_fd *VAR_4;

    int VAR_5 = 0;

    int VAR_6 = 0;

    int64_t total_size = 0;

    GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));



    VAR_3 = qemu_gluster_init(gconf, VAR_0, VAR_2);

    if (!VAR_3) {

        VAR_5 = -EINVAL;

        goto out;

    }



    while (VAR_1 && VAR_1->name) {

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

            total_size = VAR_1->value.n / BDRV_SECTOR_SIZE;

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

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

                VAR_6 = 0;

            } else if (!strcmp(VAR_1->value.s, "full") &&

                    gluster_supports_zerofill()) {

                VAR_6 = 1;

            } else {

                error_setg(VAR_2, "Invalid preallocation mode: '%s'"

                    " or GlusterFS doesn't support zerofill API",

                           VAR_1->value.s);

                VAR_5 = -EINVAL;

                goto out;

            }

        }

        VAR_1++;

    }



    VAR_4 = glfs_creat(VAR_3, gconf->image,

        O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);

    if (!VAR_4) {

        VAR_5 = -errno;

    } else {

        if (!glfs_ftruncate(VAR_4, total_size * BDRV_SECTOR_SIZE)) {

            if (VAR_6 && qemu_gluster_zerofill(VAR_4, 0,

                    total_size * BDRV_SECTOR_SIZE)) {

                VAR_5 = -errno;

            }

        } else {

            VAR_5 = -errno;

        }



        if (glfs_close(VAR_4) != 0) {

            VAR_5 = -errno;

        }

    }

out:

    qemu_gluster_gconf_free(gconf);

    if (VAR_3) {

        glfs_fini(VAR_3);

    }

    return VAR_5;

}

static int FUNC_0(const char *VAR_0,
QEMUOptionParameter *VAR_1, Error **VAR_2)
{ struct VAR_3 *VAR_3; struct glfs_fd *VAR_4; int VAR_5 = 0; int VAR_6 = 0; int64_t total_size = 0; GlusterConf *gconf = g_malloc0(sizeof(GlusterConf)); VAR_3 = qemu_gluster_init(gconf, VAR_0, VAR_2); if (!VAR_3) { VAR_5 = -EINVAL; goto out; } while (VAR_1 && VAR_1->name) { if (!strcmp(VAR_1->name, BLOCK_OPT_SIZE)) { total_size = VAR_1->value.n / BDRV_SECTOR_SIZE; } else if (!strcmp(VAR_1->name, BLOCK_OPT_PREALLOC)) { if (!VAR_1->value.s || !strcmp(VAR_1->value.s, "off")) { VAR_6 = 0; } else if (!strcmp(VAR_1->value.s, "full") && gluster_supports_zerofill()) { VAR_6 = 1; } else { error_setg(VAR_2, "Invalid preallocation mode: '%s'"
" or GlusterFS doesn't support zerofill API",
VAR_1->value.s); VAR_5 = -EINVAL; goto out; } } VAR_1++; } VAR_4 = glfs_creat(VAR_3, gconf->image,
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR); if (!VAR_4) { VAR_5 = -errno; } else { if (!glfs_ftruncate(VAR_4, total_size * BDRV_SECTOR_SIZE)) { if (VAR_6 && qemu_gluster_zerofill(VAR_4, 0,
total_size * BDRV_SECTOR_SIZE)) { VAR_5 = -errno; } } else { VAR_5 = -errno; } if (glfs_close(VAR_4) != 0) { VAR_5 = -errno; } } out:
qemu_gluster_gconf_free(gconf); if (VAR_3) { glfs_fini(VAR_3); } return VAR_5; }