Propagate virConnectOpen errors to global error object

This commit is contained in:
Daniel P. Berrange 2008-08-21 10:12:32 +00:00
parent c2bbf99e48
commit 11a2e2972a
2 changed files with 21 additions and 4 deletions

View File

@ -1,3 +1,8 @@
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

View File

@ -744,10 +744,8 @@ do_open (const char *name,
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) {
@ -848,7 +846,21 @@ do_open (const char *name,
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;
}