提交 9905c69e 编写于 作者: C Christophe Fergeau 提交者: Eric Blake

remove no longer needed calls to virReportOOMError

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
consistently 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.
上级 7f1c65e5
......@@ -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;
......
......@@ -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,
......
......@@ -121,7 +121,6 @@ virNWFilterHashTableCreate(int n) {
}
ret->hashTable = virHashCreate(n);
if (!ret->hashTable) {
virReportOOMError();
VIR_FREE(ret);
return NULL;
}
......
......@@ -1037,8 +1037,6 @@ virNWFilterDomainFWUpdateCB(void *payload,
cb->err = virHashAddEntry(cb->skipInterfaces,
net->ifname,
(void *)~0);
if (cb->err)
virReportOOMError();
}
break;
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -995,10 +995,8 @@ qemuProcessWaitForMonitor(struct qemud_driver* driver,
* Note that the monitor itself can be on a pty, so we still need to try the
* log output method. */
paths = virHashCreate(0);
if (paths == NULL) {
virReportOOMError();
if (paths == NULL)
goto cleanup;
}
qemuDomainObjEnterMonitorWithDriver(driver, vm);
qemuDomainObjPrivatePtr priv = vm->privateData;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册