mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
remote_driver: Move URI re-generation into a function
There's a piece of code in doRemoteOpen() that is going to be called twice. Instead of duplicating the code, move it into a function that will be called twice, later on. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
77b4a67cf6
commit
c71c159248
@ -693,6 +693,24 @@ remoteConnectSupportsFeatureUnlocked(virConnectPtr conn,
|
|||||||
return rc != -1 && ret.supported;
|
return rc != -1 && ret.supported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *
|
||||||
|
remoteConnectFormatURI(virURI *uri,
|
||||||
|
const char *driver_str)
|
||||||
|
{
|
||||||
|
g_autofree char *query = NULL;
|
||||||
|
virURI tmpuri = {
|
||||||
|
.scheme = (char *)driver_str,
|
||||||
|
.path = uri->path,
|
||||||
|
.fragment = uri->fragment,
|
||||||
|
};
|
||||||
|
|
||||||
|
query = tmpuri.query = virURIFormatParams(uri);
|
||||||
|
|
||||||
|
return virURIFormat(&tmpuri);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* helper macro to ease extraction of arguments from the URI */
|
/* helper macro to ease extraction of arguments from the URI */
|
||||||
#define EXTRACT_URI_ARG_STR(ARG_NAME, ARG_VAR) \
|
#define EXTRACT_URI_ARG_STR(ARG_NAME, ARG_VAR) \
|
||||||
if (STRCASEEQ(var->name, ARG_NAME)) { \
|
if (STRCASEEQ(var->name, ARG_NAME)) { \
|
||||||
@ -833,16 +851,8 @@ doRemoteOpen(virConnectPtr conn,
|
|||||||
/* Allow remote serve to probe */
|
/* Allow remote serve to probe */
|
||||||
name = g_strdup("");
|
name = g_strdup("");
|
||||||
} else {
|
} else {
|
||||||
virURI tmpuri = {
|
name = remoteConnectFormatURI(conn->uri, driver_str);
|
||||||
.scheme = (char *)driver_str,
|
|
||||||
.query = virURIFormatParams(conn->uri),
|
|
||||||
.path = conn->uri->path,
|
|
||||||
.fragment = conn->uri->fragment,
|
|
||||||
};
|
|
||||||
|
|
||||||
name = virURIFormat(&tmpuri);
|
|
||||||
|
|
||||||
VIR_FREE(tmpuri.query);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user