[libvirt] [PATCH v3 07/11] livirt: Move URI alias matching to util
Martin Kletzander
mkletzan at redhat.com
Mon Nov 16 16:27:17 UTC 2015
On Fri, Nov 06, 2015 at 12:46:22PM +0100, Erik Skultety wrote:
>As we need to provide support for URI aliases in libvirt-admin as well, URI
>alias matching needs to be internally visible. Since
>virConnectOpenResolveURIAlias does have a compatible signature, it could be
>easily reused by libvirt-admin. This patch moves URI alias matching to util,
>renaming it accordingly.
>---
> src/libvirt.c | 78 +---------------------------------------
> src/libvirt_private.syms | 1 +
> src/util/viruri.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++
> src/util/viruri.h | 2 ++
> 4 files changed, 96 insertions(+), 77 deletions(-)
>
>diff --git a/src/util/viruri.c b/src/util/viruri.c
>index 6166c37..16d27db 100644
>--- a/src/util/viruri.c
>+++ b/src/util/viruri.c
>@@ -311,3 +315,91 @@ void virURIFree(virURIPtr uri)
>
> VIR_FREE(uri);
> }
>+
>+
>+#define URI_ALIAS_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"
>+
>+static int
>+virURIFindAliasMatch(virConfValuePtr value, const char *alias,
>+ char **uri)
>+{
>+ virConfValuePtr entry;
>+ size_t alias_len;
>+
>+ if (value->type != VIR_CONF_LIST) {
>+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>+ _("Expected a list for 'uri_aliases' config parameter"));
>+ return -1;
>+ }
>+
>+ entry = value->list;
>+ alias_len = strlen(alias);
>+ while (entry) {
>+ char *offset;
>+ size_t safe;
>+
>+ if (entry->type != VIR_CONF_STRING) {
>+ virReportError(VIR_ERR_CONF_SYNTAX, "%s",
>+ _("Expected a string for 'uri_aliases' config "
>+ "parameter list entry"));
>+ return -1;
>+ }
>+
>+ if (!(offset = strchr(entry->str, '='))) {
>+ virReportError(VIR_ERR_CONF_SYNTAX,
>+ _("Malformed 'uri_aliases' config entry '%s', "
>+ "expected 'alias=uri://host/path'"), entry->str);
>+ return -1;
>+ }
>+
>+ safe = strspn(entry->str, URI_ALIAS_CHARS);
Double whitespace after 'safe' ^^.
ACK with that fixed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20151116/5b1226db/attachment-0001.sig>
More information about the libvir-list
mailing list