Now that the virHash handling functions call virReportOOMError by
themselves when needed, users of the virHash API no longer need to
do it by themselves. Since users of the virHash API were not
consitently calling virReportOOMError after memory failures from
the virHash code, this has the added benefit of making OOM
reporting from this code more consistent and reliable.
---
src/conf/domain_conf.c | 18 ++++--------------
src/conf/nwfilter_conf.c | 4 +---
src/conf/nwfilter_params.c | 1 -
src/nwfilter/nwfilter_gentech_driver.c | 2 --
src/nwfilter/nwfilter_learnipaddr.c | 3 ---
src/openvz/openvz_conf.c | 2 +-
src/qemu/qemu_command.c | 2 +-
7 files changed, 7 insertions(+), 25 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 01a5b2c..351daf7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -394,10 +394,8 @@ VIR_ENUM_IMPL(virDomainTimerMode, VIR_DOMAIN_TIMER_MODE_LAST,
int virDomainObjListInit(virDomainObjListPtr doms)
{
doms->objs = virHashCreate(50);
- if (!doms->objs) {
- virReportOOMError();
+ if (!doms->objs)
return -1;
- }
return 0;
}
@@ -1061,7 +1059,6 @@ virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
virUUIDFormat(def->uuid, uuidstr);
if (virHashAddEntry(doms->objs, uuidstr, domain) < 0) {
VIR_FREE(domain);
- virReportOOMError();
return NULL;
}
@@ -8189,10 +8186,8 @@ static virDomainObjPtr virDomainLoadStatus(virCapsPtr caps,
goto error;
}
- if (virHashAddEntry(doms->objs, uuidstr, obj) < 0) {
- virReportOOMError();
+ if (virHashAddEntry(doms->objs, uuidstr, obj) < 0)
goto error;
- }
if (notify)
(*notify)(obj, 1, opaque);
@@ -8750,7 +8745,6 @@ virDomainSnapshotObjPtr
virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr s
if (virHashAddEntry(snapshots->objs, snap->def->name, snap) < 0) {
VIR_FREE(snap);
- virReportOOMError();
return NULL;
}
@@ -8761,10 +8755,8 @@ virDomainSnapshotObjPtr
virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr s
int virDomainSnapshotObjListInit(virDomainSnapshotObjListPtr snapshots)
{
snapshots->objs = virHashCreate(50);
- if (!snapshots->objs) {
- virReportOOMError();
+ if (!snapshots->objs)
return -1;
- }
return 0;
}
@@ -9053,10 +9045,8 @@ int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
_("could not close file %s"),
path);
- if (virHashAddEntry(paths, path, (void*)0x1) < 0) {
- virReportOOMError();
+ if (virHashAddEntry(paths, path, (void*)0x1) < 0)
goto cleanup;
- }
depth++;
nextpath = meta.backingStore;
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index a5703cb..c6a4d6f 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2300,10 +2300,8 @@ virNWFilterTriggerVMFilterRebuild(virConnectPtr conn)
.skipInterfaces = virHashCreate(0),
};
- if (!cb.skipInterfaces) {
- virReportOOMError();
+ if (!cb.skipInterfaces)
return 1;
- }
for (i = 0; i < nCallbackDriver; i++) {
callbackDrvArray[i]->vmFilterRebuild(conn,
diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index 7a59387..23423fa 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -121,7 +121,6 @@ virNWFilterHashTableCreate(int n) {
}
ret->hashTable = virHashCreate(n);
if (!ret->hashTable) {
- virReportOOMError();
VIR_FREE(ret);
return NULL;
}
diff --git a/src/nwfilter/nwfilter_gentech_driver.c
b/src/nwfilter/nwfilter_gentech_driver.c
index 9ef3692..d81aac8 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -1037,8 +1037,6 @@ virNWFilterDomainFWUpdateCB(void *payload,
cb->err = virHashAddEntry(cb->skipInterfaces,
net->ifname,
(void *)~0);
- if (cb->err)
- virReportOOMError();
}
break;
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index c593481..02af918 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -165,7 +165,6 @@ virNWFilterLockIface(const char *ifname) {
}
while (virHashAddEntry(ifaceLockMap, ifname, ifaceLock)) {
- virReportOOMError();
VIR_FREE(ifaceLock);
goto err_exit;
}
@@ -825,7 +824,6 @@ virNWFilterLearnInit(void) {
pendingLearnReq = virHashCreate(0);
if (!pendingLearnReq) {
- virReportOOMError();
return 1;
}
@@ -848,7 +846,6 @@ virNWFilterLearnInit(void) {
ifaceLockMap = virHashCreate(0);
if (!ifaceLockMap) {
- virReportOOMError();
virNWFilterLearnShutdown();
return 1;
}
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index dae66a5..0eb5ab3 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -526,7 +526,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
virUUIDFormat(dom->def->uuid, uuidstr);
if (virHashAddEntry(driver->domains.objs, uuidstr, dom) < 0)
- goto no_memory;
+ goto cleanup;
virDomainObjUnlock(dom);
dom = NULL;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 618d3a9..c9feb9b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -753,7 +753,7 @@ qemuDomainPCIAddressSetPtr
qemuDomainPCIAddressSetCreate(virDomainDefPtr def)
goto no_memory;
if (!(addrs->used = virHashCreate(10)))
- goto no_memory;
+ goto error;
if (virDomainDeviceInfoIterate(def, qemuCollectPCIAddress, addrs) < 0)
goto error;
--
1.7.4