virDomainPtr
virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
virDomainPtr ret = NULL;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
if ((!VIR_IS_CONNECT(conn)) || (name == NULL) || (uuid == NULL)) {
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
}
virMutexLock(&conn->lock);
- /* TODO search by UUID first as they are better differentiators */
+ virUUIDFormat(uuid, uuidstr);
- ret = (virDomainPtr) virHashLookup(conn->domains, name);
- /* TODO check the UUID */
+ ret = (virDomainPtr) virHashLookup(conn->domains, uuidstr);
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
virMutexUnlock(&conn->lock);
memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
ret->snapshots = virHashCreate(20);
- if (virHashAddEntry(conn->domains, name, ret) < 0) {
+ if (virHashAddEntry(conn->domains, uuidstr, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to add domain to connection hash table"));
static void
virReleaseDomain(virDomainPtr domain) {
virConnectPtr conn = domain->conn;
- DEBUG("release domain %p %s", domain, domain->name);
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
- /* TODO search by UUID first as they are better differentiators */
- if (virHashRemoveEntry(conn->domains, domain->name, NULL) < 0) {
+ virUUIDFormat(domain->uuid, uuidstr);
+ DEBUG("release domain %p %s %s", domain, domain->name, uuidstr);
+
+ if (virHashRemoveEntry(conn->domains, uuidstr, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain missing from connection hash table"));
virNetworkPtr
virGetNetwork(virConnectPtr conn, const char *name, const unsigned char *uuid) {
virNetworkPtr ret = NULL;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
if ((!VIR_IS_CONNECT(conn)) || (name == NULL) || (uuid == NULL)) {
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
}
virMutexLock(&conn->lock);
- /* TODO search by UUID first as they are better differentiators */
+ virUUIDFormat(uuid, uuidstr);
- ret = (virNetworkPtr) virHashLookup(conn->networks, name);
- /* TODO check the UUID */
+ ret = (virNetworkPtr) virHashLookup(conn->networks, uuidstr);
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
virMutexUnlock(&conn->lock);
if (uuid != NULL)
memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
- if (virHashAddEntry(conn->networks, name, ret) < 0) {
+ if (virHashAddEntry(conn->networks, uuidstr, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to add network to connection hash table"));
static void
virReleaseNetwork(virNetworkPtr network) {
virConnectPtr conn = network->conn;
- DEBUG("release network %p %s", network, network->name);
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
- /* TODO search by UUID first as they are better differentiators */
- if (virHashRemoveEntry(conn->networks, network->name, NULL) < 0) {
+ virUUIDFormat(network->uuid, uuidstr);
+ DEBUG("release network %p %s %s", network, network->name, uuidstr);
+
+ if (virHashRemoveEntry(conn->networks, uuidstr, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("network missing from connection hash table"));
virStoragePoolPtr
virGetStoragePool(virConnectPtr conn, const char *name, const unsigned char *uuid) {
virStoragePoolPtr ret = NULL;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
if ((!VIR_IS_CONNECT(conn)) || (name == NULL) || (uuid == NULL)) {
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
}
virMutexLock(&conn->lock);
- /* TODO search by UUID first as they are better differentiators */
+ virUUIDFormat(uuid, uuidstr);
- ret = (virStoragePoolPtr) virHashLookup(conn->storagePools, name);
- /* TODO check the UUID */
+ ret = (virStoragePoolPtr) virHashLookup(conn->storagePools, uuidstr);
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
virMutexUnlock(&conn->lock);
if (uuid != NULL)
memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
- if (virHashAddEntry(conn->storagePools, name, ret) < 0) {
+ if (virHashAddEntry(conn->storagePools, uuidstr, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to add storage pool to connection hash table"));
static void
virReleaseStoragePool(virStoragePoolPtr pool) {
virConnectPtr conn = pool->conn;
- DEBUG("release pool %p %s", pool, pool->name);
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
- /* TODO search by UUID first as they are better differentiators */
- if (virHashRemoveEntry(conn->storagePools, pool->name, NULL) < 0) {
+ virUUIDFormat(pool->uuid, uuidstr);
+ DEBUG("release pool %p %s %s", pool, pool->name, uuidstr);
+
+ if (virHashRemoveEntry(conn->storagePools, uuidstr, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pool missing from connection hash table"));
virNWFilterPtr
virGetNWFilter(virConnectPtr conn, const char *name, const unsigned char *uuid) {
virNWFilterPtr ret = NULL;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
if ((!VIR_IS_CONNECT(conn)) || (name == NULL) || (uuid == NULL)) {
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
}
virMutexLock(&conn->lock);
- /* TODO search by UUID first as they are better differentiators */
+ virUUIDFormat(uuid, uuidstr);
- ret = (virNWFilterPtr) virHashLookup(conn->nwfilterPools, name);
- /* TODO check the UUID */
+ ret = (virNWFilterPtr) virHashLookup(conn->nwfilterPools, uuidstr);
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
virMutexUnlock(&conn->lock);
if (uuid != NULL)
memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
- if (virHashAddEntry(conn->nwfilterPools, name, ret) < 0) {
+ if (virHashAddEntry(conn->nwfilterPools, uuidstr, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to add network filter pool to connection hash table"));
static void
virReleaseNWFilterPool(virNWFilterPtr pool) {
virConnectPtr conn = pool->conn;
- DEBUG("release pool %p %s", pool, pool->name);
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
- /* TODO search by UUID first as they are better differentiators */
- if (virHashRemoveEntry(conn->nwfilterPools, pool->name, NULL) < 0) {
+ virUUIDFormat(pool->uuid, uuidstr);
+ DEBUG("release pool %p %s %s", pool, pool->name, uuidstr);
+
+ if (virHashRemoveEntry(conn->nwfilterPools, uuidstr, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pool missing from connection hash table"));