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

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

 



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))
+        goto error;
+
+    if (!(conn->uri = virURIParse(alias ? alias : (uri ? uri : default_uri))))
         goto error;
 
     if (!(sock_path = getSocketPath(conn->uri)))
@@ -230,6 +236,7 @@ virAdmConnectOpen(const char *uri, unsigned int flags)
 
  cleanup:
     VIR_FREE(sock_path);
+    VIR_FREE(alias);
     virConfFree(conf);
     return conn;
 
-- 
2.4.3

--
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]