mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
Remove deallocator parameter from hash functions
Since the deallocator is passed into the constructor of a hash table it is not desirable to pass it into each function again. Remove it from all functions, but provide a virHashSteal to allow a item to be removed from a hash table without deleteing it. * src/util/hash.c, src/util/hash.h: Remove deallocator param from all functions. Add virHashSteal * src/libvirt_private.syms: Add virHashSteal * src/conf/domain_conf.c, src/conf/nwfilter_params.c, src/nwfilter/nwfilter_learnipaddr.c, src/qemu/qemu_command.c, src/xen/xm_internal.c: Update for changed hash API
This commit is contained in:
parent
f0e9dfeca9
commit
6952708ca4
@ -392,7 +392,7 @@ VIR_ENUM_IMPL(virDomainTimerMode, VIR_DOMAIN_TIMER_MODE_LAST,
|
|||||||
#define VIR_DOMAIN_XML_READ_FLAGS VIR_DOMAIN_XML_INACTIVE
|
#define VIR_DOMAIN_XML_READ_FLAGS VIR_DOMAIN_XML_INACTIVE
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virDomainObjListDeallocator(void *payload, const char *name ATTRIBUTE_UNUSED)
|
virDomainObjListDataFree(void *payload, const char *name ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
virDomainObjPtr obj = payload;
|
virDomainObjPtr obj = payload;
|
||||||
virDomainObjLock(obj);
|
virDomainObjLock(obj);
|
||||||
@ -402,7 +402,7 @@ virDomainObjListDeallocator(void *payload, const char *name ATTRIBUTE_UNUSED)
|
|||||||
|
|
||||||
int virDomainObjListInit(virDomainObjListPtr doms)
|
int virDomainObjListInit(virDomainObjListPtr doms)
|
||||||
{
|
{
|
||||||
doms->objs = virHashCreate(50, virDomainObjListDeallocator);
|
doms->objs = virHashCreate(50, virDomainObjListDataFree);
|
||||||
if (!doms->objs)
|
if (!doms->objs)
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
@ -1143,7 +1143,7 @@ void virDomainRemoveInactive(virDomainObjListPtr doms,
|
|||||||
|
|
||||||
virDomainObjUnlock(dom);
|
virDomainObjUnlock(dom);
|
||||||
|
|
||||||
virHashRemoveEntry(doms->objs, uuidstr, virDomainObjListDeallocator);
|
virHashRemoveEntry(doms->objs, uuidstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -8753,7 +8753,7 @@ virDomainSnapshotObjPtr virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr s
|
|||||||
|
|
||||||
/* Snapshot Obj List functions */
|
/* Snapshot Obj List functions */
|
||||||
static void
|
static void
|
||||||
virDomainSnapshotObjListDeallocator(void *payload,
|
virDomainSnapshotObjListDataFree(void *payload,
|
||||||
const char *name ATTRIBUTE_UNUSED)
|
const char *name ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
virDomainSnapshotObjPtr obj = payload;
|
virDomainSnapshotObjPtr obj = payload;
|
||||||
@ -8763,7 +8763,7 @@ virDomainSnapshotObjListDeallocator(void *payload,
|
|||||||
|
|
||||||
int virDomainSnapshotObjListInit(virDomainSnapshotObjListPtr snapshots)
|
int virDomainSnapshotObjListInit(virDomainSnapshotObjListPtr snapshots)
|
||||||
{
|
{
|
||||||
snapshots->objs = virHashCreate(50, virDomainSnapshotObjListDeallocator);
|
snapshots->objs = virHashCreate(50, virDomainSnapshotObjListDataFree);
|
||||||
if (!snapshots->objs)
|
if (!snapshots->objs)
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
@ -8860,8 +8860,7 @@ virDomainSnapshotObjPtr virDomainSnapshotFindByName(const virDomainSnapshotObjLi
|
|||||||
void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots,
|
void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots,
|
||||||
virDomainSnapshotObjPtr snapshot)
|
virDomainSnapshotObjPtr snapshot)
|
||||||
{
|
{
|
||||||
virHashRemoveEntry(snapshots->objs, snapshot->def->name,
|
virHashRemoveEntry(snapshots->objs, snapshot->def->name);
|
||||||
virDomainSnapshotObjListDeallocator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct snapshot_has_children {
|
struct snapshot_has_children {
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
||||||
|
|
||||||
static void
|
static void
|
||||||
hashDealloc(void *payload, const char *name ATTRIBUTE_UNUSED)
|
hashDataFree(void *payload, const char *name ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
VIR_FREE(payload);
|
VIR_FREE(payload);
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ virNWFilterHashTablePut(virNWFilterHashTablePtr table,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (virHashUpdateEntry(table->hashTable, name, val, hashDealloc) != 0) {
|
if (virHashUpdateEntry(table->hashTable, name, val) != 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ virNWFilterHashTableCreate(int n) {
|
|||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ret->hashTable = virHashCreate(n, hashDealloc);
|
ret->hashTable = virHashCreate(n, hashDataFree);
|
||||||
if (!ret->hashTable) {
|
if (!ret->hashTable) {
|
||||||
VIR_FREE(ret);
|
VIR_FREE(ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -134,7 +134,7 @@ virNWFilterHashTableRemoveEntry(virNWFilterHashTablePtr ht,
|
|||||||
const char *entry)
|
const char *entry)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int rc = virHashRemoveEntry(ht->hashTable, entry, hashDealloc);
|
int rc = virHashRemoveEntry(ht->hashTable, entry);
|
||||||
|
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
for (i = 0; i < ht->nNames; i++) {
|
for (i = 0; i < ht->nNames; i++) {
|
||||||
|
@ -413,6 +413,7 @@ virHashRemoveEntry;
|
|||||||
virHashRemoveSet;
|
virHashRemoveSet;
|
||||||
virHashSearch;
|
virHashSearch;
|
||||||
virHashSize;
|
virHashSize;
|
||||||
|
virHashSteal;
|
||||||
|
|
||||||
|
|
||||||
# hooks.h
|
# hooks.h
|
||||||
|
@ -207,7 +207,7 @@ virNWFilterUnlockIface(const char *ifname) {
|
|||||||
|
|
||||||
ifaceLock->refctr--;
|
ifaceLock->refctr--;
|
||||||
if (ifaceLock->refctr == 0)
|
if (ifaceLock->refctr == 0)
|
||||||
virHashRemoveEntry(ifaceLockMap, ifname, freeIfaceLock);
|
virHashRemoveEntry(ifaceLockMap, ifname);
|
||||||
}
|
}
|
||||||
|
|
||||||
virMutexUnlock(&ifaceMapLock);
|
virMutexUnlock(&ifaceMapLock);
|
||||||
@ -301,10 +301,7 @@ virNWFilterDeregisterLearnReq(int ifindex) {
|
|||||||
|
|
||||||
virMutexLock(&pendingLearnReqLock);
|
virMutexLock(&pendingLearnReqLock);
|
||||||
|
|
||||||
res = virHashLookup(pendingLearnReq, ifindex_str);
|
res = virHashSteal(pendingLearnReq, ifindex_str);
|
||||||
|
|
||||||
if (res)
|
|
||||||
virHashRemoveEntry(pendingLearnReq, ifindex_str, NULL);
|
|
||||||
|
|
||||||
virMutexUnlock(&pendingLearnReqLock);
|
virMutexUnlock(&pendingLearnReqLock);
|
||||||
|
|
||||||
|
@ -842,7 +842,7 @@ int qemuDomainPCIAddressReleaseAddr(qemuDomainPCIAddressSetPtr addrs,
|
|||||||
if (!addr)
|
if (!addr)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ret = virHashRemoveEntry(addrs->used, addr, qemuDomainPCIAddressSetFreeEntry);
|
ret = virHashRemoveEntry(addrs->used, addr);
|
||||||
|
|
||||||
VIR_FREE(addr);
|
VIR_FREE(addr);
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ struct _virHashTable {
|
|||||||
struct _virHashEntry *table;
|
struct _virHashEntry *table;
|
||||||
int size;
|
int size;
|
||||||
int nbElems;
|
int nbElems;
|
||||||
virHashDeallocator f;
|
virHashDataFree dataFree;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -80,14 +80,14 @@ virHashComputeKey(virHashTablePtr table, const char *name)
|
|||||||
/**
|
/**
|
||||||
* virHashCreate:
|
* virHashCreate:
|
||||||
* @size: the size of the hash table
|
* @size: the size of the hash table
|
||||||
* @deallocator: function to call on each entry during virHashFree
|
* @dataFree: function to call on each entry during virHashFree
|
||||||
*
|
*
|
||||||
* Create a new virHashTablePtr.
|
* Create a new virHashTablePtr.
|
||||||
*
|
*
|
||||||
* Returns the newly created object, or NULL if an error occured.
|
* Returns the newly created object, or NULL if an error occured.
|
||||||
*/
|
*/
|
||||||
virHashTablePtr
|
virHashTablePtr
|
||||||
virHashCreate(int size, virHashDeallocator deallocator)
|
virHashCreate(int size, virHashDataFree dataFree)
|
||||||
{
|
{
|
||||||
virHashTablePtr table = NULL;
|
virHashTablePtr table = NULL;
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ virHashCreate(int size, virHashDeallocator deallocator)
|
|||||||
|
|
||||||
table->size = size;
|
table->size = size;
|
||||||
table->nbElems = 0;
|
table->nbElems = 0;
|
||||||
table->f = deallocator;
|
table->dataFree = dataFree;
|
||||||
if (VIR_ALLOC_N(table->table, size) < 0) {
|
if (VIR_ALLOC_N(table->table, size) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
VIR_FREE(table);
|
VIR_FREE(table);
|
||||||
@ -229,8 +229,8 @@ virHashFree(virHashTablePtr table)
|
|||||||
inside_table = 1;
|
inside_table = 1;
|
||||||
while (iter) {
|
while (iter) {
|
||||||
next = iter->next;
|
next = iter->next;
|
||||||
if ((table->f != NULL) && (iter->payload != NULL))
|
if ((table->dataFree != NULL) && (iter->payload != NULL))
|
||||||
table->f(iter->payload, iter->name);
|
table->dataFree(iter->payload, iter->name);
|
||||||
VIR_FREE(iter->name);
|
VIR_FREE(iter->name);
|
||||||
iter->payload = NULL;
|
iter->payload = NULL;
|
||||||
if (!inside_table)
|
if (!inside_table)
|
||||||
@ -246,8 +246,8 @@ virHashFree(virHashTablePtr table)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virHashAddOrUpdateEntry(virHashTablePtr table, const char *name,
|
virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
|
||||||
void *userdata, virHashDeallocator f,
|
void *userdata,
|
||||||
bool is_update)
|
bool is_update)
|
||||||
{
|
{
|
||||||
unsigned long key, len = 0;
|
unsigned long key, len = 0;
|
||||||
@ -281,8 +281,8 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const char *name,
|
|||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
if (is_update) {
|
if (is_update) {
|
||||||
if (f)
|
if (table->dataFree)
|
||||||
f(insert->payload, insert->name);
|
table->dataFree(insert->payload, insert->name);
|
||||||
insert->payload = userdata;
|
insert->payload = userdata;
|
||||||
return (0);
|
return (0);
|
||||||
} else {
|
} else {
|
||||||
@ -336,7 +336,7 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const char *name,
|
|||||||
int
|
int
|
||||||
virHashAddEntry(virHashTablePtr table, const char *name, void *userdata)
|
virHashAddEntry(virHashTablePtr table, const char *name, void *userdata)
|
||||||
{
|
{
|
||||||
return virHashAddOrUpdateEntry(table, name, userdata, NULL, false);
|
return virHashAddOrUpdateEntry(table, name, userdata, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -344,7 +344,6 @@ virHashAddEntry(virHashTablePtr table, const char *name, void *userdata)
|
|||||||
* @table: the hash table
|
* @table: the hash table
|
||||||
* @name: the name of the userdata
|
* @name: the name of the userdata
|
||||||
* @userdata: a pointer to the userdata
|
* @userdata: a pointer to the userdata
|
||||||
* @f: the deallocator function for replaced item (if any)
|
|
||||||
*
|
*
|
||||||
* Add the @userdata to the hash @table. This can later be retrieved
|
* Add the @userdata to the hash @table. This can later be retrieved
|
||||||
* by using @name. Existing entry for this tuple
|
* by using @name. Existing entry for this tuple
|
||||||
@ -354,9 +353,9 @@ virHashAddEntry(virHashTablePtr table, const char *name, void *userdata)
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virHashUpdateEntry(virHashTablePtr table, const char *name,
|
virHashUpdateEntry(virHashTablePtr table, const char *name,
|
||||||
void *userdata, virHashDeallocator f)
|
void *userdata)
|
||||||
{
|
{
|
||||||
return virHashAddOrUpdateEntry(table, name, userdata, f, true);
|
return virHashAddOrUpdateEntry(table, name, userdata, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -388,6 +387,30 @@ virHashLookup(virHashTablePtr table, const char *name)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virHashSteal:
|
||||||
|
* @table: the hash table
|
||||||
|
* @name: the name of the userdata
|
||||||
|
*
|
||||||
|
* Find the userdata specified by @name
|
||||||
|
* and remove it from the hash without freeing it.
|
||||||
|
*
|
||||||
|
* Returns the a pointer to the userdata
|
||||||
|
*/
|
||||||
|
void *virHashSteal(virHashTablePtr table, const char *name)
|
||||||
|
{
|
||||||
|
void *data = virHashLookup(table, name);
|
||||||
|
if (data) {
|
||||||
|
virHashDataFree dataFree = table->dataFree;
|
||||||
|
table->dataFree = NULL;
|
||||||
|
virHashRemoveEntry(table, name);
|
||||||
|
table->dataFree = dataFree;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virHashSize:
|
* virHashSize:
|
||||||
* @table: the hash table
|
* @table: the hash table
|
||||||
@ -409,7 +432,6 @@ virHashSize(virHashTablePtr table)
|
|||||||
* virHashRemoveEntry:
|
* virHashRemoveEntry:
|
||||||
* @table: the hash table
|
* @table: the hash table
|
||||||
* @name: the name of the userdata
|
* @name: the name of the userdata
|
||||||
* @f: the deallocator function for removed item (if any)
|
|
||||||
*
|
*
|
||||||
* Find the userdata specified by the @name and remove
|
* Find the userdata specified by the @name and remove
|
||||||
* it from the hash @table. Existing userdata for this tuple will be removed
|
* it from the hash @table. Existing userdata for this tuple will be removed
|
||||||
@ -418,8 +440,7 @@ virHashSize(virHashTablePtr table)
|
|||||||
* Returns 0 if the removal succeeded and -1 in case of error or not found.
|
* Returns 0 if the removal succeeded and -1 in case of error or not found.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virHashRemoveEntry(virHashTablePtr table, const char *name,
|
virHashRemoveEntry(virHashTablePtr table, const char *name)
|
||||||
virHashDeallocator f)
|
|
||||||
{
|
{
|
||||||
unsigned long key;
|
unsigned long key;
|
||||||
virHashEntryPtr entry;
|
virHashEntryPtr entry;
|
||||||
@ -435,8 +456,8 @@ virHashRemoveEntry(virHashTablePtr table, const char *name,
|
|||||||
for (entry = &(table->table[key]); entry != NULL;
|
for (entry = &(table->table[key]); entry != NULL;
|
||||||
entry = entry->next) {
|
entry = entry->next) {
|
||||||
if (STREQ(entry->name, name)) {
|
if (STREQ(entry->name, name)) {
|
||||||
if ((f != NULL) && (entry->payload != NULL))
|
if (table->dataFree && (entry->payload != NULL))
|
||||||
f(entry->payload, entry->name);
|
table->dataFree(entry->payload, entry->name);
|
||||||
entry->payload = NULL;
|
entry->payload = NULL;
|
||||||
VIR_FREE(entry->name);
|
VIR_FREE(entry->name);
|
||||||
if (prev) {
|
if (prev) {
|
||||||
@ -508,7 +529,7 @@ int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data) {
|
|||||||
*
|
*
|
||||||
* Returns number of items removed on success, -1 on failure
|
* Returns number of items removed on success, -1 on failure
|
||||||
*/
|
*/
|
||||||
int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, virHashDeallocator f, const void *data) {
|
int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *data) {
|
||||||
int i, count = 0;
|
int i, count = 0;
|
||||||
|
|
||||||
if (table == NULL || iter == NULL)
|
if (table == NULL || iter == NULL)
|
||||||
@ -521,7 +542,8 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, virHashDealloc
|
|||||||
while (entry && entry->valid) {
|
while (entry && entry->valid) {
|
||||||
if (iter(entry->payload, entry->name, data)) {
|
if (iter(entry->payload, entry->name, data)) {
|
||||||
count++;
|
count++;
|
||||||
f(entry->payload, entry->name);
|
if (table->dataFree)
|
||||||
|
table->dataFree(entry->payload, entry->name);
|
||||||
VIR_FREE(entry->name);
|
VIR_FREE(entry->name);
|
||||||
table->nbElems--;
|
table->nbElems--;
|
||||||
if (prev) {
|
if (prev) {
|
||||||
|
@ -23,13 +23,13 @@ typedef virHashTable *virHashTablePtr;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virHashDeallocator:
|
* virHashDataFree:
|
||||||
* @payload: the data in the hash
|
* @payload: the data in the hash
|
||||||
* @name: the name associated
|
* @name: the name associated
|
||||||
*
|
*
|
||||||
* Callback to free data from a hash.
|
* Callback to free data from a hash.
|
||||||
*/
|
*/
|
||||||
typedef void (*virHashDeallocator) (void *payload, const char *name);
|
typedef void (*virHashDataFree) (void *payload, const char *name);
|
||||||
/**
|
/**
|
||||||
* virHashIterator:
|
* virHashIterator:
|
||||||
* @payload: the data in the hash
|
* @payload: the data in the hash
|
||||||
@ -55,7 +55,7 @@ typedef int (*virHashSearcher) (const void *payload, const char *name,
|
|||||||
/*
|
/*
|
||||||
* Constructor and destructor.
|
* Constructor and destructor.
|
||||||
*/
|
*/
|
||||||
virHashTablePtr virHashCreate(int size, virHashDeallocator f);
|
virHashTablePtr virHashCreate(int size, virHashDataFree dataFree);
|
||||||
void virHashFree(virHashTablePtr table);
|
void virHashFree(virHashTablePtr table);
|
||||||
int virHashSize(virHashTablePtr table);
|
int virHashSize(virHashTablePtr table);
|
||||||
|
|
||||||
@ -66,25 +66,30 @@ int virHashAddEntry(virHashTablePtr table,
|
|||||||
const char *name, void *userdata);
|
const char *name, void *userdata);
|
||||||
int virHashUpdateEntry(virHashTablePtr table,
|
int virHashUpdateEntry(virHashTablePtr table,
|
||||||
const char *name,
|
const char *name,
|
||||||
void *userdata, virHashDeallocator f);
|
void *userdata);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove an entry from the hash table.
|
* Remove an entry from the hash table.
|
||||||
*/
|
*/
|
||||||
int virHashRemoveEntry(virHashTablePtr table,
|
int virHashRemoveEntry(virHashTablePtr table,
|
||||||
const char *name, virHashDeallocator f);
|
const char *name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Retrieve the userdata.
|
* Retrieve the userdata.
|
||||||
*/
|
*/
|
||||||
void *virHashLookup(virHashTablePtr table, const char *name);
|
void *virHashLookup(virHashTablePtr table, const char *name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve & remove the userdata.
|
||||||
|
*/
|
||||||
|
void *virHashSteal(virHashTablePtr table, const char *name);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Iterators
|
* Iterators
|
||||||
*/
|
*/
|
||||||
int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data);
|
int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data);
|
||||||
int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, virHashDeallocator f, const void *data);
|
int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *data);
|
||||||
void *virHashSearch(virHashTablePtr table, virHashSearcher iter, const void *data);
|
void *virHashSearch(virHashTablePtr table, virHashSearcher iter, const void *data);
|
||||||
|
|
||||||
#endif /* ! __VIR_HASH_H__ */
|
#endif /* ! __VIR_HASH_H__ */
|
||||||
|
@ -161,7 +161,7 @@ static int xenXMConfigReaper(const void *payload, const char *key ATTRIBUTE_UNUS
|
|||||||
const char *olddomname = entry->def->name;
|
const char *olddomname = entry->def->name;
|
||||||
char *nameowner = (char *)virHashLookup(args->priv->nameConfigMap, olddomname);
|
char *nameowner = (char *)virHashLookup(args->priv->nameConfigMap, olddomname);
|
||||||
if (nameowner && STREQ(nameowner, key)) {
|
if (nameowner && STREQ(nameowner, key)) {
|
||||||
virHashRemoveEntry(args->priv->nameConfigMap, olddomname, NULL);
|
virHashRemoveEntry(args->priv->nameConfigMap, olddomname);
|
||||||
}
|
}
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
@ -216,8 +216,8 @@ xenXMConfigCacheRemoveFile(virConnectPtr conn,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virHashRemoveEntry(priv->nameConfigMap, entry->def->name, NULL);
|
virHashRemoveEntry(priv->nameConfigMap, entry->def->name);
|
||||||
virHashRemoveEntry(priv->configCache, filename, xenXMConfigFree);
|
virHashRemoveEntry(priv->configCache, filename);
|
||||||
VIR_DEBUG("Removed %s %s", entry->def->name, filename);
|
VIR_DEBUG("Removed %s %s", entry->def->name, filename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ xenXMConfigCacheAddFile(virConnectPtr conn, const char *filename)
|
|||||||
re-acquire it later - just in case it was renamed */
|
re-acquire it later - just in case it was renamed */
|
||||||
nameowner = (char *)virHashLookup(priv->nameConfigMap, entry->def->name);
|
nameowner = (char *)virHashLookup(priv->nameConfigMap, entry->def->name);
|
||||||
if (nameowner && STREQ(nameowner, filename)) {
|
if (nameowner && STREQ(nameowner, filename)) {
|
||||||
virHashRemoveEntry(priv->nameConfigMap, entry->def->name, NULL);
|
virHashRemoveEntry(priv->nameConfigMap, entry->def->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear existing config entry which needs refresh */
|
/* Clear existing config entry which needs refresh */
|
||||||
@ -287,7 +287,7 @@ xenXMConfigCacheAddFile(virConnectPtr conn, const char *filename)
|
|||||||
if (!(entry->def = xenXMConfigReadFile(conn, entry->filename))) {
|
if (!(entry->def = xenXMConfigReadFile(conn, entry->filename))) {
|
||||||
VIR_DEBUG("Failed to read %s", entry->filename);
|
VIR_DEBUG("Failed to read %s", entry->filename);
|
||||||
if (!newborn)
|
if (!newborn)
|
||||||
virHashRemoveEntry(priv->configCache, filename, NULL);
|
virHashSteal(priv->configCache, filename);
|
||||||
VIR_FREE(entry);
|
VIR_FREE(entry);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -309,7 +309,7 @@ xenXMConfigCacheAddFile(virConnectPtr conn, const char *filename)
|
|||||||
*/
|
*/
|
||||||
if (!virHashLookup(priv->nameConfigMap, entry->def->name)) {
|
if (!virHashLookup(priv->nameConfigMap, entry->def->name)) {
|
||||||
if (virHashAddEntry(priv->nameConfigMap, entry->def->name, entry->filename) < 0) {
|
if (virHashAddEntry(priv->nameConfigMap, entry->def->name, entry->filename) < 0) {
|
||||||
virHashRemoveEntry(priv->configCache, filename, NULL);
|
virHashSteal(priv->configCache, filename);
|
||||||
virDomainDefFree(entry->def);
|
virDomainDefFree(entry->def);
|
||||||
VIR_FREE(entry);
|
VIR_FREE(entry);
|
||||||
}
|
}
|
||||||
@ -412,7 +412,7 @@ int xenXMConfigCacheRefresh (virConnectPtr conn) {
|
|||||||
then the config is no longer on disk */
|
then the config is no longer on disk */
|
||||||
args.now = now;
|
args.now = now;
|
||||||
args.priv = priv;
|
args.priv = priv;
|
||||||
virHashRemoveSet(priv->configCache, xenXMConfigReaper, xenXMConfigFree, &args);
|
virHashRemoveSet(priv->configCache, xenXMConfigReaper, &args);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
closedir(dh);
|
closedir(dh);
|
||||||
@ -1114,14 +1114,14 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Remove the name -> filename mapping */
|
/* Remove the name -> filename mapping */
|
||||||
if (virHashRemoveEntry(priv->nameConfigMap, def->name, NULL) < 0) {
|
if (virHashRemoveEntry(priv->nameConfigMap, def->name) < 0) {
|
||||||
xenXMError(VIR_ERR_INTERNAL_ERROR,
|
xenXMError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("failed to remove old domain from config map"));
|
"%s", _("failed to remove old domain from config map"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove the config record itself */
|
/* Remove the config record itself */
|
||||||
if (virHashRemoveEntry(priv->configCache, oldfilename, xenXMConfigFree) < 0) {
|
if (virHashRemoveEntry(priv->configCache, oldfilename) < 0) {
|
||||||
xenXMError(VIR_ERR_INTERNAL_ERROR,
|
xenXMError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("failed to remove old domain from config map"));
|
"%s", _("failed to remove old domain from config map"));
|
||||||
goto error;
|
goto error;
|
||||||
@ -1164,7 +1164,7 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virHashAddEntry(priv->nameConfigMap, def->name, entry->filename) < 0) {
|
if (virHashAddEntry(priv->nameConfigMap, def->name, entry->filename) < 0) {
|
||||||
virHashRemoveEntry(priv->configCache, filename, NULL);
|
virHashSteal(priv->configCache, filename);
|
||||||
xenXMError(VIR_ERR_INTERNAL_ERROR,
|
xenXMError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("unable to store config file handle"));
|
"%s", _("unable to store config file handle"));
|
||||||
goto error;
|
goto error;
|
||||||
@ -1213,11 +1213,11 @@ int xenXMDomainUndefine(virDomainPtr domain) {
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* Remove the name -> filename mapping */
|
/* Remove the name -> filename mapping */
|
||||||
if (virHashRemoveEntry(priv->nameConfigMap, domain->name, NULL) < 0)
|
if (virHashRemoveEntry(priv->nameConfigMap, domain->name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* Remove the config record itself */
|
/* Remove the config record itself */
|
||||||
if (virHashRemoveEntry(priv->configCache, entry->filename, xenXMConfigFree) < 0)
|
if (virHashRemoveEntry(priv->configCache, entry->filename) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user