Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/libvirt_private.syms | 1 +
src/util/viruri.c | 16 ++++++++++++++++
src/util/viruri.h | 2 ++
3 files changed, 19 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b97906b852..5ed6729e6c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3335,6 +3335,7 @@ virTypedParamsValidate;
virURIFormat;
virURIFormatParams;
virURIFree;
+virURIGetParam;
virURIParse;
virURIResolveAlias;
diff --git a/src/util/viruri.c b/src/util/viruri.c
index 1b848bd336..f16ea16ac1 100644
--- a/src/util/viruri.c
+++ b/src/util/viruri.c
@@ -376,3 +376,19 @@ virURIResolveAlias(virConfPtr conf, const char *alias, char **uri)
return ret;
}
+
+
+const char *
+virURIGetParam(virURIPtr uri, const char *name)
+{
+ size_t i;
+
+ for (i = 0; i < uri->paramsCount; i++) {
+ if (STREQ(uri->params[i].name, name))
+ return uri->params[i].value;
+ }
+
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("Missing URI parameter '%s'"), name);
+ return NULL;
+}
diff --git a/src/util/viruri.h b/src/util/viruri.h
index b7f845f41f..1735620a2f 100644
--- a/src/util/viruri.h
+++ b/src/util/viruri.h
@@ -62,4 +62,6 @@ void virURIFree(virURIPtr uri);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virURI, virURIFree);
int virURIResolveAlias(virConfPtr conf, const char *alias, char **uri);
+const char *virURIGetParam(virURIPtr uri, const char *name);
+
#define VIR_URI_SERVER(uri) ((uri) && (uri)->server ? (uri)->server :
"localhost")
--
2.23.0