[libvirt] [PATCH v3 08/11] admin: Add support for URI aliases

Martin Kletzander mkletzan at redhat.com
Mon Nov 16 16:31:16 UTC 2015


On Fri, Nov 06, 2015 at 12:46:23PM +0100, Erik Skultety wrote:
>Now that we introduced URI support in libvirt-admin, we should also support URI
>aliases during connection establishment phase. After applying this patch,
>virAdmConnectOpen will also support VIR_CONNECT_NO_ALIASES flag.
>---
> src/libvirt-admin.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
>diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
>index 599c30a..d9a20fc 100644
>--- a/src/libvirt-admin.c
>+++ b/src/libvirt-admin.c
>@@ -196,6 +196,7 @@ virAdmConnectOpen(const char *uri, unsigned int flags)
> {
>     char *sock_path = NULL;
>     const char *default_uri = NULL;
>+    char *alias = NULL;
>     virAdmConnectPtr conn = NULL;
>     virConfPtr conf = NULL;
>
>@@ -204,6 +205,7 @@ virAdmConnectOpen(const char *uri, unsigned int flags)
>
>     VIR_DEBUG("flags=%x", flags);
>     virResetLastError();
>+    virCheckFlags(VIR_CONNECT_NO_ALIASES, NULL);
>
>     if (!(conn = virAdmConnectNew()))
>         goto error;
>@@ -214,7 +216,11 @@ virAdmConnectOpen(const char *uri, unsigned int flags)
>     if (!uri && !(default_uri = virAdmGetDefaultURI(conf)))
>         goto error;
>
>-    if (!(conn->uri = virURIParse(uri ? uri : default_uri)))
>+    if ((!(flags & VIR_CONNECT_NO_ALIASES) &&
>+         virURIResolveAlias(conf, uri ? uri : default_uri, &alias) < 0))

this should also be fixed (with what I mentioned in previous review).

>+        goto error;
>+
>+    if (!(conn->uri = virURIParse(alias ? alias : (uri ? uri : default_uri))))

Also, if you modify virURIResolveAlias() to simply copy the string
over to @alias if the alias is not found, that would be pretty nice
syntax-sugar and spare our souls from this ugly thing =)

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/f4be5faf/attachment-0001.sig>


More information about the libvir-list mailing list