+Wed Aug 21 11:09:09 BST 2008 Daniel P. Berrange <berrange@redhat.com>
+
+ * src/libvirt.c: Propagate error from virConnect to global
+ error object for virConnectOpen() failures
+
Wed Aug 21 10:28:09 BST 2008 Daniel P. Berrange <berrange@redhat.com>
* libvirt.spec.in: Add libvirt_lxc to spec file and conditionals
name = "xen:///";
ret = virGetConnect();
- if (ret == NULL) {
- virLibConnError(NULL, VIR_ERR_NO_MEMORY, _("allocating connection"));
+ if (ret == NULL)
return NULL;
- }
uri = xmlParseURI (name);
if (!uri) {
failed:
if (ret->driver) ret->driver->close (ret);
if (uri) xmlFreeURI(uri);
- virUnrefConnect(ret);
+
+ /* If not global error was set, copy any error set
+ in the connection object we're about to dispose of */
+ if (__lastErr.code == VIR_ERR_OK) {
+ memcpy(&__lastErr, &ret->err, sizeof(ret->err));
+ memset(&ret->err, 0, sizeof(ret->err));
+ }
+
+ /* Still no error set, then raise a generic error */
+ if (__lastErr.code == VIR_ERR_OK)
+ virLibConnError (NULL, VIR_ERR_INTERNAL_ERROR,
+ _("unable to open connection"));
+
+ virUnrefConnect(ret);
+
return NULL;
}