static int qemu_gluster_parse_uri(BlockdevOptionsGluster *gconf,

                                  const char *filename)

{

    SocketAddress *gsconf;

    URI *uri;

    QueryParams *qp = NULL;

    bool is_unix = false;

    int ret = 0;



    uri = uri_parse(filename);

    if (!uri) {

        return -EINVAL;

    }



    gconf->server = g_new0(SocketAddressList, 1);

    gconf->server->value = gsconf = g_new0(SocketAddress, 1);



    /* transport */

    if (!uri->scheme || !strcmp(uri->scheme, "gluster")) {

        gsconf->type = SOCKET_ADDRESS_TYPE_INET;

    } else if (!strcmp(uri->scheme, "gluster+tcp")) {

        gsconf->type = SOCKET_ADDRESS_TYPE_INET;

    } else if (!strcmp(uri->scheme, "gluster+unix")) {

        gsconf->type = SOCKET_ADDRESS_TYPE_UNIX;

        is_unix = true;

    } else if (!strcmp(uri->scheme, "gluster+rdma")) {

        gsconf->type = SOCKET_ADDRESS_TYPE_INET;

        error_report("Warning: rdma feature is not supported, falling "

                     "back to tcp");

    } else {

        ret = -EINVAL;

        goto out;

    }



    ret = parse_volume_options(gconf, uri->path);

    if (ret < 0) {

        goto out;

    }



    qp = query_params_parse(uri->query);

    if (qp->n > 1 || (is_unix && !qp->n) || (!is_unix && qp->n)) {

        ret = -EINVAL;

        goto out;

    }



    if (is_unix) {

        if (uri->server || uri->port) {

            ret = -EINVAL;

            goto out;

        }

        if (strcmp(qp->p[0].name, "socket")) {

            ret = -EINVAL;

            goto out;

        }

        gsconf->u.q_unix.path = g_strdup(qp->p[0].value);

    } else {

        gsconf->u.inet.host = g_strdup(uri->server ? uri->server : "localhost");

        if (uri->port) {

            gsconf->u.inet.port = g_strdup_printf("%d", uri->port);

        } else {

            gsconf->u.inet.port = g_strdup_printf("%d", GLUSTER_DEFAULT_PORT);

        }

    }



out:

    if (qp) {

        query_params_free(qp);

    }

    uri_free(uri);

    return ret;

}

static int qemu_gluster_parse_uri(BlockdevOptionsGluster *gconf,

                                  const char *filename)

{

    SocketAddress *gsconf;

    URI *uri;

    QueryParams *qp = NULL;

    bool is_unix = false;

    int ret = 0;



    uri = uri_parse(filename);

    if (!uri) {

        return -EINVAL;

    }



    gconf->server = g_new0(SocketAddressList, 1);

    gconf->server->value = gsconf = g_new0(SocketAddress, 1);



    

    if (!uri->scheme || !strcmp(uri->scheme, "gluster")) {

        gsconf->type = SOCKET_ADDRESS_TYPE_INET;

    } else if (!strcmp(uri->scheme, "gluster+tcp")) {

        gsconf->type = SOCKET_ADDRESS_TYPE_INET;

    } else if (!strcmp(uri->scheme, "gluster+unix")) {

        gsconf->type = SOCKET_ADDRESS_TYPE_UNIX;

        is_unix = true;

    } else if (!strcmp(uri->scheme, "gluster+rdma")) {

        gsconf->type = SOCKET_ADDRESS_TYPE_INET;

        error_report("Warning: rdma feature is not supported, falling "

                     "back to tcp");

    } else {

        ret = -EINVAL;

        goto out;

    }



    ret = parse_volume_options(gconf, uri->path);

    if (ret < 0) {

        goto out;

    }



    qp = query_params_parse(uri->query);

    if (qp->n > 1 || (is_unix && !qp->n) || (!is_unix && qp->n)) {

        ret = -EINVAL;

        goto out;

    }



    if (is_unix) {

        if (uri->server || uri->port) {

            ret = -EINVAL;

            goto out;

        }

        if (strcmp(qp->p[0].name, "socket")) {

            ret = -EINVAL;

            goto out;

        }

        gsconf->u.q_unix.path = g_strdup(qp->p[0].value);

    } else {

        gsconf->u.inet.host = g_strdup(uri->server ? uri->server : "localhost");

        if (uri->port) {

            gsconf->u.inet.port = g_strdup_printf("%d", uri->port);

        } else {

            gsconf->u.inet.port = g_strdup_printf("%d", GLUSTER_DEFAULT_PORT);

        }

    }



out:

    if (qp) {

        query_params_free(qp);

    }

    uri_free(uri);

    return ret;

}

static int FUNC_0(BlockdevOptionsGluster *VAR_0,

                                  const char *VAR_1)

{

    SocketAddress *gsconf;

    URI *uri;

    QueryParams *qp = NULL;

    bool is_unix = false;

    int VAR_2 = 0;



    uri = uri_parse(VAR_1);

    if (!uri) {

        return -EINVAL;

    }



    VAR_0->server = g_new0(SocketAddressList, 1);

    VAR_0->server->value = gsconf = g_new0(SocketAddress, 1);



    

    if (!uri->scheme || !strcmp(uri->scheme, "gluster")) {

        gsconf->type = SOCKET_ADDRESS_TYPE_INET;

    } else if (!strcmp(uri->scheme, "gluster+tcp")) {

        gsconf->type = SOCKET_ADDRESS_TYPE_INET;

    } else if (!strcmp(uri->scheme, "gluster+unix")) {

        gsconf->type = SOCKET_ADDRESS_TYPE_UNIX;

        is_unix = true;

    } else if (!strcmp(uri->scheme, "gluster+rdma")) {

        gsconf->type = SOCKET_ADDRESS_TYPE_INET;

        error_report("Warning: rdma feature is not supported, falling "

                     "back to tcp");

    } else {

        VAR_2 = -EINVAL;

        goto out;

    }



    VAR_2 = parse_volume_options(VAR_0, uri->path);

    if (VAR_2 < 0) {

        goto out;

    }



    qp = query_params_parse(uri->query);

    if (qp->n > 1 || (is_unix && !qp->n) || (!is_unix && qp->n)) {

        VAR_2 = -EINVAL;

        goto out;

    }



    if (is_unix) {

        if (uri->server || uri->port) {

            VAR_2 = -EINVAL;

            goto out;

        }

        if (strcmp(qp->p[0].name, "socket")) {

            VAR_2 = -EINVAL;

            goto out;

        }

        gsconf->u.q_unix.path = g_strdup(qp->p[0].value);

    } else {

        gsconf->u.inet.host = g_strdup(uri->server ? uri->server : "localhost");

        if (uri->port) {

            gsconf->u.inet.port = g_strdup_printf("%d", uri->port);

        } else {

            gsconf->u.inet.port = g_strdup_printf("%d", GLUSTER_DEFAULT_PORT);

        }

    }



out:

    if (qp) {

        query_params_free(qp);

    }

    uri_free(uri);

    return VAR_2;

}

static int FUNC_0(BlockdevOptionsGluster *VAR_0,
const char *VAR_1)
{ SocketAddress *gsconf; URI *uri; QueryParams *qp = NULL; bool is_unix = false; int VAR_2 = 0; uri = uri_parse(VAR_1); if (!uri) { return -EINVAL; } VAR_0->server = g_new0(SocketAddressList, 1); VAR_0->server->value = gsconf = g_new0(SocketAddress, 1); if (!uri->scheme || !strcmp(uri->scheme, "gluster")) { gsconf->type = SOCKET_ADDRESS_TYPE_INET; } else if (!strcmp(uri->scheme, "gluster+tcp")) { gsconf->type = SOCKET_ADDRESS_TYPE_INET; } else if (!strcmp(uri->scheme, "gluster+unix")) { gsconf->type = SOCKET_ADDRESS_TYPE_UNIX; is_unix = true; } else if (!strcmp(uri->scheme, "gluster+rdma")) { gsconf->type = SOCKET_ADDRESS_TYPE_INET; error_report("Warning: rdma feature is not supported, falling "
"back to tcp"); } else { VAR_2 = -EINVAL; goto out; } VAR_2 = parse_volume_options(VAR_0, uri->path); if (VAR_2 < 0) { goto out; } qp = query_params_parse(uri->query); if (qp->n > 1 || (is_unix && !qp->n) || (!is_unix && qp->n)) { VAR_2 = -EINVAL; goto out; } if (is_unix) { if (uri->server || uri->port) { VAR_2 = -EINVAL; goto out; } if (strcmp(qp->p[0].name, "socket")) { VAR_2 = -EINVAL; goto out; } gsconf->u.q_unix.path = g_strdup(qp->p[0].value); } else { gsconf->u.inet.host = g_strdup(uri->server ? uri->server : "localhost"); if (uri->port) { gsconf->u.inet.port = g_strdup_printf("%d", uri->port); } else { gsconf->u.inet.port = g_strdup_printf("%d", GLUSTER_DEFAULT_PORT); } } out:
if (qp) { query_params_free(qp); } uri_free(uri); return VAR_2; }