static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,

                                           Error **errp)

{

    struct glfs *glfs;

    int ret;

    int old_errno;

    GlusterServerList *server;



    glfs = glfs_new(gconf->volume);

    if (!glfs) {

        goto out;

    }



    for (server = gconf->server; server; server = server->next) {

        if (server->value->type  == GLUSTER_TRANSPORT_UNIX) {

            ret = glfs_set_volfile_server(glfs,

                                   GlusterTransport_lookup[server->value->type],

                                   server->value->u.q_unix.path, 0);

        } else {

            ret = glfs_set_volfile_server(glfs,

                                   GlusterTransport_lookup[server->value->type],

                                   server->value->u.tcp.host,

                                   atoi(server->value->u.tcp.port));

        }



        if (ret < 0) {

            goto out;

        }

    }



    ret = glfs_set_logging(glfs, "-", gconf->debug_level);

    if (ret < 0) {

        goto out;

    }



    ret = glfs_init(glfs);

    if (ret) {

        error_setg(errp, "Gluster connection for volume %s, path %s failed"

                         " to connect", gconf->volume, gconf->path);

        for (server = gconf->server; server; server = server->next) {

            if (server->value->type  == GLUSTER_TRANSPORT_UNIX) {

                error_append_hint(errp, "hint: failed on socket %s ",

                                  server->value->u.q_unix.path);

            } else {

                error_append_hint(errp, "hint: failed on host %s and port %s ",

                                  server->value->u.tcp.host,

                                  server->value->u.tcp.port);

            }

        }



        error_append_hint(errp, "Please refer to gluster logs for more info\n");



        /* glfs_init sometimes doesn't set errno although docs suggest that */

        if (errno == 0) {

            errno = EINVAL;

        }



        goto out;

    }

    return glfs;



out:

    if (glfs) {

        old_errno = errno;

        glfs_fini(glfs);

        errno = old_errno;

    }

    return NULL;

}

static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,

                                           Error **errp)

{

    struct glfs *glfs;

    int ret;

    int old_errno;

    GlusterServerList *server;



    glfs = glfs_new(gconf->volume);

    if (!glfs) {

        goto out;

    }



    for (server = gconf->server; server; server = server->next) {

        if (server->value->type  == GLUSTER_TRANSPORT_UNIX) {

            ret = glfs_set_volfile_server(glfs,

                                   GlusterTransport_lookup[server->value->type],

                                   server->value->u.q_unix.path, 0);

        } else {

            ret = glfs_set_volfile_server(glfs,

                                   GlusterTransport_lookup[server->value->type],

                                   server->value->u.tcp.host,

                                   atoi(server->value->u.tcp.port));

        }



        if (ret < 0) {

            goto out;

        }

    }



    ret = glfs_set_logging(glfs, "-", gconf->debug_level);

    if (ret < 0) {

        goto out;

    }



    ret = glfs_init(glfs);

    if (ret) {

        error_setg(errp, "Gluster connection for volume %s, path %s failed"

                         " to connect", gconf->volume, gconf->path);

        for (server = gconf->server; server; server = server->next) {

            if (server->value->type  == GLUSTER_TRANSPORT_UNIX) {

                error_append_hint(errp, "hint: failed on socket %s ",

                                  server->value->u.q_unix.path);

            } else {

                error_append_hint(errp, "hint: failed on host %s and port %s ",

                                  server->value->u.tcp.host,

                                  server->value->u.tcp.port);

            }

        }



        error_append_hint(errp, "Please refer to gluster logs for more info\n");



        

        if (errno == 0) {

            errno = EINVAL;

        }



        goto out;

    }

    return glfs;



out:

    if (glfs) {

        old_errno = errno;

        glfs_fini(glfs);

        errno = old_errno;

    }

    return NULL;

}

    ret = glfs_set_logging(glfs, "-", gconf->debug_level);
static struct VAR_2 *FUNC_0(BlockdevOptionsGluster *VAR_0,

                                           Error **VAR_1)

{

    struct VAR_2 *VAR_2;

    int VAR_3;

    int VAR_4;

    GlusterServerList *server;



    VAR_2 = glfs_new(VAR_0->volume);

    if (!VAR_2) {

        goto out;

    }



    for (server = VAR_0->server; server; server = server->next) {

        if (server->value->type  == GLUSTER_TRANSPORT_UNIX) {

            VAR_3 = glfs_set_volfile_server(VAR_2,

                                   GlusterTransport_lookup[server->value->type],

                                   server->value->u.q_unix.path, 0);

        } else {

            VAR_3 = glfs_set_volfile_server(VAR_2,

                                   GlusterTransport_lookup[server->value->type],

                                   server->value->u.tcp.host,

                                   atoi(server->value->u.tcp.port));

        }



        if (VAR_3 < 0) {

            goto out;

        }

    }



    VAR_3 = glfs_set_logging(VAR_2, "-", VAR_0->debug_level);

    if (VAR_3 < 0) {

        goto out;

    }



    VAR_3 = glfs_init(VAR_2);

    if (VAR_3) {

        error_setg(VAR_1, "Gluster connection for volume %s, path %s failed"

                         " to connect", VAR_0->volume, VAR_0->path);

        for (server = VAR_0->server; server; server = server->next) {

            if (server->value->type  == GLUSTER_TRANSPORT_UNIX) {

                error_append_hint(VAR_1, "hint: failed on socket %s ",

                                  server->value->u.q_unix.path);

            } else {

                error_append_hint(VAR_1, "hint: failed on host %s and port %s ",

                                  server->value->u.tcp.host,

                                  server->value->u.tcp.port);

            }

        }



        error_append_hint(VAR_1, "Please refer to gluster logs for more info\n");



        

        if (errno == 0) {

            errno = EINVAL;

        }



        goto out;

    }

    return VAR_2;



out:

    if (VAR_2) {

        VAR_4 = errno;

        glfs_fini(VAR_2);

        errno = VAR_4;

    }

    return NULL;

}

static struct VAR_2 *FUNC_0(BlockdevOptionsGluster *VAR_0,
Error **VAR_1)
{ struct VAR_2 *VAR_2; int VAR_3; int VAR_4; GlusterServerList *server; VAR_2 = glfs_new(VAR_0->volume); if (!VAR_2) { goto out; } for (server = VAR_0->server; server; server = server->next) { if (server->value->type  == GLUSTER_TRANSPORT_UNIX) { VAR_3 = glfs_set_volfile_server(VAR_2,
GlusterTransport_lookup[server->value->type],
server->value->u.q_unix.path, 0); } else { VAR_3 = glfs_set_volfile_server(VAR_2,
GlusterTransport_lookup[server->value->type],
server->value->u.tcp.host,
atoi(server->value->u.tcp.port)); } if (VAR_3 < 0) { goto out; } } VAR_3 = glfs_set_logging(VAR_2, "-", VAR_0->debug_level); if (VAR_3 < 0) { goto out; } VAR_3 = glfs_init(VAR_2); if (VAR_3) { error_setg(VAR_1, "Gluster connection for volume %s, path %s failed"
" to connect", VAR_0->volume, VAR_0->path); for (server = VAR_0->server; server; server = server->next) { if (server->value->type  == GLUSTER_TRANSPORT_UNIX) { error_append_hint(VAR_1, "hint: failed on socket %s ",
server->value->u.q_unix.path); } else { error_append_hint(VAR_1, "hint: failed on host %s and port %s ",
server->value->u.tcp.host,
server->value->u.tcp.port); } } error_append_hint(VAR_1, "Please refer to gluster logs for more info\n"); if (errno == 0) { errno = EINVAL; } goto out; } return VAR_2; out:
if (VAR_2) { VAR_4 = errno; glfs_fini(VAR_2); errno = VAR_4; } return NULL; }