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

[libvirt] [PATCH libvirt-glib 3/5] Ensure internal copy of URI is not NULL



From: "Daniel P. Berrange" <berrange redhat com>

It is permissible to pass in NULL for a URI to libvirt, which
causes it to probe for a supported driver. In such a case we
should populate priv->uri with the resulting probed URI after
opening the connection

* libvirt-gobject/libvirt-gobject-connection.c: Populate URI
  after opening connection, if NULL
---
 libvirt-gobject/libvirt-gobject-connection.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
index 59b828d..a1a6f5d 100644
--- a/libvirt-gobject/libvirt-gobject-connection.c
+++ b/libvirt-gobject/libvirt-gobject-connection.c
@@ -415,6 +415,18 @@ gboolean gvir_connection_open(GVirConnection *conn,
         return FALSE;
     }
 
+    if (!priv->uri &&
+        !(priv->uri = virConnectGetURI(priv->conn))) {
+        if (err)
+            *err = gvir_error_new(GVIR_CONNECTION_ERROR,
+                                  0,
+                                  "%s", "Unable to get connection URI");
+        virConnectClose(priv->conn);
+        priv->conn = NULL;
+        g_mutex_unlock(priv->lock);
+        return FALSE;
+    }
+
     if (virConnectDomainEventRegister(priv->conn, domain_event_cb, conn, NULL) != -1)
         priv->domain_event = TRUE;
     else
-- 
1.7.6.4


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