On Wed, Nov 30, 2011 at 04:52:05PM +0000, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange(a)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))) {
priv->uri will be freed with g_free(), virConnectGetURI must be freed with
free(), I'm afraid we'll have to g_strdup + free() here.
+ 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
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list