Remove virConnectPtr from virLibConnError

This commit is contained in:
Matthias Bolte 2010-04-03 15:01:26 +02:00
parent b290e48cf7
commit 5a19c24611

View File

@ -31,8 +31,8 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define virLibConnError(conn, code, ...) \
virReportErrorHelper(conn, VIR_FROM_THIS, code, __FILE__, \
#define virLibConnError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/************************************************************************
@ -269,7 +269,7 @@ virUnrefConnect(virConnectPtr conn) {
int refs;
if ((!VIR_IS_CONNECT(conn))) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
}
virMutexLock(&conn->lock);
@ -325,7 +325,7 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
virDomainPtr ret = NULL;
if ((!VIR_IS_CONNECT(conn)) || (name == NULL) || (uuid == NULL)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(NULL);
}
virMutexLock(&conn->lock);
@ -355,8 +355,8 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
if (virHashAddEntry(conn->domains, name, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to add domain to connection hash table"));
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to add domain to connection hash table"));
goto error;
}
conn->refs++;
@ -396,8 +396,8 @@ virReleaseDomain(virDomainPtr domain) {
/* TODO search by UUID first as they are better differenciators */
if (virHashRemoveEntry(conn->domains, domain->name, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("domain missing from connection hash table"));
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain missing from connection hash table"));
conn = NULL;
}
@ -435,7 +435,7 @@ virUnrefDomain(virDomainPtr domain) {
int refs;
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
}
virMutexLock(&domain->conn->lock);
@ -470,7 +470,7 @@ virGetNetwork(virConnectPtr conn, const char *name, const unsigned char *uuid) {
virNetworkPtr ret = NULL;
if ((!VIR_IS_CONNECT(conn)) || (name == NULL) || (uuid == NULL)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(NULL);
}
virMutexLock(&conn->lock);
@ -498,8 +498,8 @@ virGetNetwork(virConnectPtr conn, const char *name, const unsigned char *uuid) {
if (virHashAddEntry(conn->networks, name, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to add network to connection hash table"));
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to add network to connection hash table"));
goto error;
}
conn->refs++;
@ -536,8 +536,8 @@ virReleaseNetwork(virNetworkPtr network) {
/* TODO search by UUID first as they are better differenciators */
if (virHashRemoveEntry(conn->networks, network->name, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("network missing from connection hash table"));
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("network missing from connection hash table"));
conn = NULL;
}
@ -572,7 +572,7 @@ virUnrefNetwork(virNetworkPtr network) {
int refs;
if (!VIR_IS_CONNECTED_NETWORK(network)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
}
virMutexLock(&network->conn->lock);
@ -609,7 +609,7 @@ virGetInterface(virConnectPtr conn, const char *name, const char *mac) {
virInterfacePtr ret = NULL;
if ((!VIR_IS_CONNECT(conn)) || (name == NULL)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(NULL);
}
@ -645,8 +645,9 @@ virGetInterface(virConnectPtr conn, const char *name, const char *mac) {
* interface, and that is unlikely to change.
*/
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
_("Failed to change interface mac address from %s to %s due to differing lengths."),
virLibConnError(VIR_ERR_INTERNAL_ERROR,
_("Failed to change interface mac address "
"from %s to %s due to differing lengths."),
ret->mac, mac);
ret = NULL;
goto error;
@ -676,8 +677,8 @@ _("Failed to change interface mac address from %s to %s due to differing lengths
if (virHashAddEntry(conn->interfaces, name, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to add interface to connection hash table"));
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to add interface to connection hash table"));
goto error;
}
conn->refs++;
@ -715,8 +716,8 @@ virReleaseInterface(virInterfacePtr iface) {
if (virHashRemoveEntry(conn->interfaces, iface->name, NULL) < 0) {
/* unlock before reporting error because error report grabs lock */
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("interface missing from connection hash table"));
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("interface missing from connection hash table"));
/* don't decr the conn refct if we weren't connected to it */
conn = NULL;
}
@ -753,7 +754,7 @@ virUnrefInterface(virInterfacePtr iface) {
int refs;
if (!VIR_IS_CONNECTED_INTERFACE(iface)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
}
virMutexLock(&iface->conn->lock);
@ -789,7 +790,7 @@ virGetStoragePool(virConnectPtr conn, const char *name, const unsigned char *uui
virStoragePoolPtr ret = NULL;
if ((!VIR_IS_CONNECT(conn)) || (name == NULL) || (uuid == NULL)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(NULL);
}
virMutexLock(&conn->lock);
@ -817,7 +818,7 @@ virGetStoragePool(virConnectPtr conn, const char *name, const unsigned char *uui
if (virHashAddEntry(conn->storagePools, name, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
virLibConnError(VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to add storage pool to connection hash table"));
goto error;
}
@ -856,8 +857,8 @@ virReleaseStoragePool(virStoragePoolPtr pool) {
/* TODO search by UUID first as they are better differenciators */
if (virHashRemoveEntry(conn->storagePools, pool->name, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("pool missing from connection hash table"));
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pool missing from connection hash table"));
conn = NULL;
}
@ -892,7 +893,7 @@ virUnrefStoragePool(virStoragePoolPtr pool) {
int refs;
if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
}
virMutexLock(&pool->conn->lock);
@ -929,7 +930,7 @@ virGetStorageVol(virConnectPtr conn, const char *pool, const char *name, const c
virStorageVolPtr ret = NULL;
if ((!VIR_IS_CONNECT(conn)) || (name == NULL) || (key == NULL)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(NULL);
}
virMutexLock(&conn->lock);
@ -955,7 +956,7 @@ virGetStorageVol(virConnectPtr conn, const char *pool, const char *name, const c
}
if (virStrcpyStatic(ret->key, key) == NULL) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
virLibConnError(VIR_ERR_INTERNAL_ERROR,
_("Volume key %s too large for destination"), key);
goto error;
}
@ -964,8 +965,8 @@ virGetStorageVol(virConnectPtr conn, const char *pool, const char *name, const c
if (virHashAddEntry(conn->storageVols, key, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to add storage vol to connection hash table"));
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to add storage vol to connection hash table"));
goto error;
}
conn->refs++;
@ -1004,8 +1005,8 @@ virReleaseStorageVol(virStorageVolPtr vol) {
/* TODO search by UUID first as they are better differenciators */
if (virHashRemoveEntry(conn->storageVols, vol->key, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("vol missing from connection hash table"));
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("vol missing from connection hash table"));
conn = NULL;
}
@ -1041,7 +1042,7 @@ virUnrefStorageVol(virStorageVolPtr vol) {
int refs;
if (!VIR_IS_CONNECTED_STORAGE_VOL(vol)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
}
virMutexLock(&vol->conn->lock);
@ -1077,7 +1078,7 @@ virGetNodeDevice(virConnectPtr conn, const char *name)
virNodeDevicePtr ret = NULL;
if ((!VIR_IS_CONNECT(conn)) || (name == NULL)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(NULL);
}
virMutexLock(&conn->lock);
@ -1100,7 +1101,7 @@ virGetNodeDevice(virConnectPtr conn, const char *name)
if (virHashAddEntry(conn->nodeDevices, name, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
virLibConnError(VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to add node dev to conn hash table"));
goto error;
}
@ -1138,7 +1139,7 @@ virReleaseNodeDevice(virNodeDevicePtr dev) {
if (virHashRemoveEntry(conn->nodeDevices, dev->name, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
virLibConnError(VIR_ERR_INTERNAL_ERROR,
"%s", _("dev missing from connection hash table"));
conn = NULL;
}
@ -1209,7 +1210,7 @@ virGetSecret(virConnectPtr conn, const unsigned char *uuid,
char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!VIR_IS_CONNECT(conn) || uuid == NULL || usageID == NULL) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return NULL;
}
virMutexLock(&conn->lock);
@ -1234,8 +1235,8 @@ virGetSecret(virConnectPtr conn, const unsigned char *uuid,
}
if (virHashAddEntry(conn->secrets, uuidstr, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to add secret to conn hash table"));
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to add secret to conn hash table"));
goto error;
}
conn->refs++;
@ -1273,8 +1274,8 @@ virReleaseSecret(virSecretPtr secret) {
virUUIDFormat(secret->uuid, uuidstr);
if (virHashRemoveEntry(conn->secrets, uuidstr, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("secret missing from connection hash table"));
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("secret missing from connection hash table"));
conn = NULL;
}
@ -1308,7 +1309,7 @@ virUnrefSecret(virSecretPtr secret) {
int refs;
if (!VIR_IS_CONNECTED_SECRET(secret)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return -1;
}
virMutexLock(&secret->conn->lock);
@ -1402,7 +1403,7 @@ virGetNWFilter(virConnectPtr conn, const char *name, const unsigned char *uuid)
virNWFilterPtr ret = NULL;
if ((!VIR_IS_CONNECT(conn)) || (name == NULL) || (uuid == NULL)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(NULL);
}
virMutexLock(&conn->lock);
@ -1430,8 +1431,8 @@ virGetNWFilter(virConnectPtr conn, const char *name, const unsigned char *uuid)
if (virHashAddEntry(conn->nwfilterPools, name, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to add network filter pool to connection hash table"));
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to add network filter pool to connection hash table"));
goto error;
}
conn->refs++;
@ -1469,8 +1470,8 @@ virReleaseNWFilterPool(virNWFilterPtr pool) {
/* TODO search by UUID first as they are better differenciators */
if (virHashRemoveEntry(conn->nwfilterPools, pool->name, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("pool missing from connection hash table"));
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pool missing from connection hash table"));
conn = NULL;
}
@ -1505,7 +1506,7 @@ virUnrefNWFilter(virNWFilterPtr pool) {
int refs;
if (!VIR_IS_CONNECTED_NWFILTER(pool)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return -1;
}
virMutexLock(&pool->conn->lock);
@ -1529,7 +1530,7 @@ virGetDomainSnapshot(virDomainPtr domain, const char *name)
virDomainSnapshotPtr ret = NULL;
if ((!VIR_IS_DOMAIN(domain)) || (name == NULL)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(NULL);
}
virMutexLock(&domain->conn->lock);
@ -1552,7 +1553,7 @@ virGetDomainSnapshot(virDomainPtr domain, const char *name)
if (virHashAddEntry(domain->snapshots, name, ret) < 0) {
virMutexUnlock(&domain->conn->lock);
virLibConnError(domain->conn, VIR_ERR_INTERNAL_ERROR,
virLibConnError(VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to add snapshot to domain hash table"));
goto error;
}
@ -1582,7 +1583,7 @@ virReleaseDomainSnapshot(virDomainSnapshotPtr snapshot)
if (virHashRemoveEntry(domain->snapshots, snapshot->name, NULL) < 0) {
virMutexUnlock(&domain->conn->lock);
virLibConnError(domain->conn, VIR_ERR_INTERNAL_ERROR,
virLibConnError(VIR_ERR_INTERNAL_ERROR,
"%s", _("snapshot missing from domain hash table"));
domain = NULL;
}
@ -1609,7 +1610,7 @@ virUnrefDomainSnapshot(virDomainSnapshotPtr snapshot)
int refs;
if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
}