mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
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.
This commit is contained in:
parent
7f1c65e551
commit
9905c69e4f
@ -394,10 +394,8 @@ VIR_ENUM_IMPL(virDomainTimerMode, VIR_DOMAIN_TIMER_MODE_LAST,
|
|||||||
int virDomainObjListInit(virDomainObjListPtr doms)
|
int virDomainObjListInit(virDomainObjListPtr doms)
|
||||||
{
|
{
|
||||||
doms->objs = virHashCreate(50);
|
doms->objs = virHashCreate(50);
|
||||||
if (!doms->objs) {
|
if (!doms->objs)
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1061,7 +1059,6 @@ virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
|
|||||||
virUUIDFormat(def->uuid, uuidstr);
|
virUUIDFormat(def->uuid, uuidstr);
|
||||||
if (virHashAddEntry(doms->objs, uuidstr, domain) < 0) {
|
if (virHashAddEntry(doms->objs, uuidstr, domain) < 0) {
|
||||||
VIR_FREE(domain);
|
VIR_FREE(domain);
|
||||||
virReportOOMError();
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8189,10 +8186,8 @@ static virDomainObjPtr virDomainLoadStatus(virCapsPtr caps,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virHashAddEntry(doms->objs, uuidstr, obj) < 0) {
|
if (virHashAddEntry(doms->objs, uuidstr, obj) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
|
|
||||||
if (notify)
|
if (notify)
|
||||||
(*notify)(obj, 1, opaque);
|
(*notify)(obj, 1, opaque);
|
||||||
@ -8750,7 +8745,6 @@ virDomainSnapshotObjPtr virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr s
|
|||||||
|
|
||||||
if (virHashAddEntry(snapshots->objs, snap->def->name, snap) < 0) {
|
if (virHashAddEntry(snapshots->objs, snap->def->name, snap) < 0) {
|
||||||
VIR_FREE(snap);
|
VIR_FREE(snap);
|
||||||
virReportOOMError();
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8761,10 +8755,8 @@ virDomainSnapshotObjPtr virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr s
|
|||||||
int virDomainSnapshotObjListInit(virDomainSnapshotObjListPtr snapshots)
|
int virDomainSnapshotObjListInit(virDomainSnapshotObjListPtr snapshots)
|
||||||
{
|
{
|
||||||
snapshots->objs = virHashCreate(50);
|
snapshots->objs = virHashCreate(50);
|
||||||
if (!snapshots->objs) {
|
if (!snapshots->objs)
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9053,10 +9045,8 @@ int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
|
|||||||
_("could not close file %s"),
|
_("could not close file %s"),
|
||||||
path);
|
path);
|
||||||
|
|
||||||
if (virHashAddEntry(paths, path, (void*)0x1) < 0) {
|
if (virHashAddEntry(paths, path, (void*)0x1) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
depth++;
|
depth++;
|
||||||
nextpath = meta.backingStore;
|
nextpath = meta.backingStore;
|
||||||
|
@ -2300,10 +2300,8 @@ virNWFilterTriggerVMFilterRebuild(virConnectPtr conn)
|
|||||||
.skipInterfaces = virHashCreate(0),
|
.skipInterfaces = virHashCreate(0),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!cb.skipInterfaces) {
|
if (!cb.skipInterfaces)
|
||||||
virReportOOMError();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < nCallbackDriver; i++) {
|
for (i = 0; i < nCallbackDriver; i++) {
|
||||||
callbackDrvArray[i]->vmFilterRebuild(conn,
|
callbackDrvArray[i]->vmFilterRebuild(conn,
|
||||||
|
@ -121,7 +121,6 @@ virNWFilterHashTableCreate(int n) {
|
|||||||
}
|
}
|
||||||
ret->hashTable = virHashCreate(n);
|
ret->hashTable = virHashCreate(n);
|
||||||
if (!ret->hashTable) {
|
if (!ret->hashTable) {
|
||||||
virReportOOMError();
|
|
||||||
VIR_FREE(ret);
|
VIR_FREE(ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1037,8 +1037,6 @@ virNWFilterDomainFWUpdateCB(void *payload,
|
|||||||
cb->err = virHashAddEntry(cb->skipInterfaces,
|
cb->err = virHashAddEntry(cb->skipInterfaces,
|
||||||
net->ifname,
|
net->ifname,
|
||||||
(void *)~0);
|
(void *)~0);
|
||||||
if (cb->err)
|
|
||||||
virReportOOMError();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -165,7 +165,6 @@ virNWFilterLockIface(const char *ifname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (virHashAddEntry(ifaceLockMap, ifname, ifaceLock)) {
|
while (virHashAddEntry(ifaceLockMap, ifname, ifaceLock)) {
|
||||||
virReportOOMError();
|
|
||||||
VIR_FREE(ifaceLock);
|
VIR_FREE(ifaceLock);
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
}
|
}
|
||||||
@ -825,7 +824,6 @@ virNWFilterLearnInit(void) {
|
|||||||
|
|
||||||
pendingLearnReq = virHashCreate(0);
|
pendingLearnReq = virHashCreate(0);
|
||||||
if (!pendingLearnReq) {
|
if (!pendingLearnReq) {
|
||||||
virReportOOMError();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -848,7 +846,6 @@ virNWFilterLearnInit(void) {
|
|||||||
|
|
||||||
ifaceLockMap = virHashCreate(0);
|
ifaceLockMap = virHashCreate(0);
|
||||||
if (!ifaceLockMap) {
|
if (!ifaceLockMap) {
|
||||||
virReportOOMError();
|
|
||||||
virNWFilterLearnShutdown();
|
virNWFilterLearnShutdown();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -526,7 +526,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
|
|
||||||
virUUIDFormat(dom->def->uuid, uuidstr);
|
virUUIDFormat(dom->def->uuid, uuidstr);
|
||||||
if (virHashAddEntry(driver->domains.objs, uuidstr, dom) < 0)
|
if (virHashAddEntry(driver->domains.objs, uuidstr, dom) < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
|
|
||||||
virDomainObjUnlock(dom);
|
virDomainObjUnlock(dom);
|
||||||
dom = NULL;
|
dom = NULL;
|
||||||
|
@ -753,7 +753,7 @@ qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def)
|
|||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (!(addrs->used = virHashCreate(10)))
|
if (!(addrs->used = virHashCreate(10)))
|
||||||
goto no_memory;
|
goto error;
|
||||||
|
|
||||||
if (virDomainDeviceInfoIterate(def, qemuCollectPCIAddress, addrs) < 0)
|
if (virDomainDeviceInfoIterate(def, qemuCollectPCIAddress, addrs) < 0)
|
||||||
goto error;
|
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
|
* Note that the monitor itself can be on a pty, so we still need to try the
|
||||||
* log output method. */
|
* log output method. */
|
||||||
paths = virHashCreate(0);
|
paths = virHashCreate(0);
|
||||||
if (paths == NULL) {
|
if (paths == NULL)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user