Re: [PATCH v3 07/11] livirt: Move URI alias matching to util

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]