if (VIR_ALLOC_N(zerobuf, wbytes) < 0) {
ret = -errno;
- virReportOOMError();
goto cleanup;
}
if (VIR_ALLOC_N(buf, rbytes) < 0) {
ret = -errno;
- virReportOOMError();
goto cleanup;
}
}
if (VIR_ALLOC(enc_secret) < 0 || VIR_REALLOC_N(enc->secrets, 1) < 0 ||
- VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ VIR_ALLOC(def) < 0)
goto cleanup;
- }
def->ephemeral = false;
def->private = false;
*/
if ('/' != *(vol->backingStore.path) &&
virAsprintf(&absolutePath, "%s/%s", pool->def->target.path,
- vol->backingStore.path) < 0) {
- virReportOOMError();
+ vol->backingStore.path) < 0)
return NULL;
- }
accessRetCode = access(absolutePath ? absolutePath
: vol->backingStore.path, R_OK);
VIR_FREE(absolutePath);
/* Size in MB - yes different units to qemu-img :-( */
if (virAsprintf(&size, "%llu",
- VIR_DIV_UP(vol->capacity, (1024 * 1024))) < 0) {
- virReportOOMError();
+ VIR_DIV_UP(vol->capacity, (1024 * 1024))) < 0)
return -1;
- }
cmd = virCommandNewArgList("qcow-create", size, vol->target.path, NULL);
target->perms.uid = sb.st_uid;
target->perms.gid = sb.st_gid;
- if (!target->timestamps && VIR_ALLOC(target->timestamps) < 0) {
- virReportOOMError();
+ if (!target->timestamps && VIR_ALLOC(target->timestamps) < 0)
return -1;
- }
target->timestamps->atime = get_stat_atime(&sb);
target->timestamps->btime = get_stat_birthtime(&sb);
target->timestamps->ctime = get_stat_ctime(&sb);
if (virAsprintf(&stablepath, "%s/%s",
pool->def->target.path,
dent->d_name) == -1) {
- virReportOOMError();
closedir(dh);
return NULL;
}
char **groups;
/* Compile all regular expressions */
- if (VIR_ALLOC_N(reg, nregex) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(reg, nregex) < 0)
return -1;
- }
for (i = 0; i < nregex; i++) {
err = regcomp(®[i], regex[i], REG_EXTENDED);
}
/* Storage for matched variables */
- if (VIR_ALLOC_N(groups, totgroups) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(groups, totgroups) < 0)
goto cleanup;
- }
- if (VIR_ALLOC_N(vars, maxvars+1) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(vars, maxvars+1) < 0)
goto cleanup;
- }
virCommandSetOutputFD(cmd, &fd);
if (virCommandRunAsync(cmd, NULL) < 0) {
if (n_columns == 0)
return -1;
- if (VIR_ALLOC_N(v, n_columns) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(v, n_columns) < 0)
return -1;
- }
for (i = 0; i < n_columns; i++)
v[i] = NULL;
char *tmp, *devpath;
if (vol == NULL) {
- if (VIR_ALLOC(vol) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(vol) < 0)
return -1;
- }
if (VIR_REALLOC_N(pool->volumes.objs,
pool->volumes.count+1) < 0) {
- virReportOOMError();
virStorageVolDefFree(vol);
return -1;
}
}
if (vol->source.extents == NULL) {
- if (VIR_ALLOC(vol->source.extents) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(vol->source.extents) < 0)
return -1;
- }
vol->source.nextent = 1;
if (virStrToLong_ull(groups[3], NULL, 10,
/* XXX Only support one extended partition */
switch (virStorageBackendDiskPartTypeToCreate(pool)) {
case VIR_STORAGE_VOL_DISK_TYPE_PRIMARY:
- if (virAsprintf(partFormat, "primary %s", partedFormat) < 0) {
- virReportOOMError();
+ if (virAsprintf(partFormat, "primary %s", partedFormat) < 0)
return -1;
- }
break;
case VIR_STORAGE_VOL_DISK_TYPE_LOGICAL:
/* make sure we have a extended partition */
if (pool->volumes.objs[i]->target.format ==
VIR_STORAGE_VOL_DISK_EXTENDED) {
if (virAsprintf(partFormat, "logical %s",
- partedFormat) < 0) {
- virReportOOMError();
+ partedFormat) < 0)
return -1;
- }
break;
}
}
*capacity = meta->capacity;
if (encryption != NULL && meta->encrypted) {
- if (VIR_ALLOC(*encryption) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(*encryption) < 0)
goto cleanup;
- }
switch (target->format) {
case VIR_STORAGE_FILE_QCOW:
if (!(src = virStoragePoolSourceListNewSource(&state->list)))
goto cleanup;
- if (VIR_ALLOC_N(src->hosts, 1) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(src->hosts, 1) < 0)
goto cleanup;
- }
src->nhost = 1;
if (VIR_STRDUP(src->hosts[0].name, state->host) < 0 ||
goto cleanup;
retval = virStoragePoolSourceListFormat(&state.list);
- if (retval == NULL) {
- virReportOOMError();
+ if (retval == NULL)
goto cleanup;
- }
cleanup:
for (i = 0; i < state.list.nsources; i++)
if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
if (virAsprintf(&src, "%s:%s",
pool->def->source.hosts[0].name,
- pool->def->source.dir) == -1) {
- virReportOOMError();
+ pool->def->source.dir) == -1)
return -1;
- }
} else {
if (VIR_STRDUP(src, pool->def->source.devices[0].path) < 0)
int backingStoreFormat;
if (VIR_ALLOC(vol) < 0)
- goto no_memory;
+ goto cleanup;
if (VIR_STRDUP(vol->name, ent->d_name) < 0)
goto cleanup;
if (virAsprintf(&vol->target.path, "%s/%s",
pool->def->target.path,
vol->name) == -1)
- goto no_memory;
+ goto cleanup;
if (VIR_STRDUP(vol->key, vol->target.path) < 0)
goto cleanup;
if (VIR_REALLOC_N(pool->volumes.objs,
pool->volumes.count+1) < 0)
- goto no_memory;
+ goto cleanup;
pool->volumes.objs[pool->volumes.count++] = vol;
vol = NULL;
}
return 0;
-no_memory:
- virReportOOMError();
- /* fallthrough */
-
cleanup:
if (dir)
closedir(dir);
VIR_FREE(vol->target.path);
if (virAsprintf(&vol->target.path, "%s/%s",
pool->def->target.path,
- vol->name) == -1) {
- virReportOOMError();
+ vol->name) == -1)
return -1;
- }
if (virFileExists(vol->target.path)) {
virReportError(VIR_ERR_OPERATION_INVALID,
if (VIR_ALLOC_N(vol->target.encryption->secrets, 1) < 0 ||
VIR_ALLOC(encsec) < 0) {
VIR_FREE(vol->target.encryption->secrets);
- virReportOOMError();
virSecretFree(sec);
return -1;
}
port = source->hosts[0].port;
if (strchr(host, ':')) {
- if (virAsprintf(&portal, "[%s]:%d,1", host, port) < 0)
- virReportOOMError();
+ ignore_value(virAsprintf(&portal, "[%s]:%d,1", host, port));
} else {
- if (virAsprintf(&portal, "%s:%d,1", host, port) < 0)
- virReportOOMError();
+ ignore_value(virAsprintf(&portal, "%s:%d,1", host, port));
}
return portal;
if (virAsprintf(&temp_ifacename,
"libvirt-iface-%08llx",
- (unsigned long long)virRandomBits(30)) < 0) {
- virReportOOMError();
+ (unsigned long long)virRandomBits(30)) < 0)
return -1;
- }
VIR_DEBUG("Attempting to create interface '%s' with IQN '%s'",
temp_ifacename, initiatoriqn);
uint32_t host;
if (virAsprintf(&sysfs_path,
- "/sys/class/iscsi_session/session%s/device", session) < 0) {
- virReportOOMError();
+ "/sys/class/iscsi_session/session%s/device", session) < 0)
return -1;
- }
if (virStorageBackendISCSIGetHostNumber(sysfs_path, &host) < 0) {
virReportSystemError(errno,
if (VIR_REALLOC_N(list->targets, list->ntargets + 1) < 0) {
VIR_FREE(target);
- virReportOOMError();
return -1;
}
&ntargets, &targets) < 0)
goto cleanup;
- if (VIR_ALLOC_N(list.sources, ntargets) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(list.sources, ntargets) < 0)
goto cleanup;
- }
for (i = 0; i < ntargets; i++) {
if (VIR_ALLOC_N(list.sources[i].devices, 1) < 0 ||
- VIR_ALLOC_N(list.sources[i].hosts, 1) < 0) {
- virReportOOMError();
+ VIR_ALLOC_N(list.sources[i].hosts, 1) < 0)
goto cleanup;
- }
list.sources[i].nhost = 1;
list.sources[i].hosts[0] = source->hosts[0];
list.sources[i].initiator = source->initiator;
list.nsources++;
}
- if (!(ret = virStoragePoolSourceListFormat(&list))) {
- virReportOOMError();
+ if (!(ret = virStoragePoolSourceListFormat(&list)))
goto cleanup;
- }
cleanup:
if (list.sources) {
/* Or a completely new volume */
if (vol == NULL) {
- if (VIR_ALLOC(vol) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(vol) < 0)
return -1;
- }
is_new_vol = true;
vol->type = VIR_STORAGE_VOL_BLOCK;
goto cleanup;
if (VIR_REALLOC_N(pool->volumes.objs,
- pool->volumes.count + 1)) {
- virReportOOMError();
+ pool->volumes.count + 1))
goto cleanup;
- }
}
if (vol->target.path == NULL) {
if (virAsprintf(&vol->target.path, "%s/%s",
- pool->def->target.path, vol->name) < 0) {
- virReportOOMError();
+ pool->def->target.path, vol->name) < 0)
goto cleanup;
- }
}
/* Skips the backingStore of lv created with "--virtualsize",
*/
if (groups[1] && !STREQ(groups[1], "") && (groups[1][0] != '[')) {
if (virAsprintf(&vol->backingStore.path, "%s/%s",
- pool->def->target.path, groups[1]) < 0) {
- virReportOOMError();
+ pool->def->target.path, groups[1]) < 0)
goto cleanup;
- }
vol->backingStore.format = VIR_STORAGE_POOL_LOGICAL_LVM2;
}
/* Finally fill in extents information */
if (VIR_REALLOC_N(vol->source.extents,
- vol->source.nextent + nextents) < 0) {
- virReportOOMError();
+ vol->source.nextent + nextents) < 0)
goto cleanup;
- }
if (virStrToLong_ull(groups[6], NULL, 10, &length) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
goto cleanup;
for (i = 1; i < nextents; i++) {
- if (VIR_REALLOC_N(regex, strlen(regex) + strlen(regex_unit) + 2) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(regex, strlen(regex) + strlen(regex_unit) + 2) < 0)
goto cleanup;
- }
/* "," is the separator of "devices" field */
strcat(regex, ",");
strncat(regex, regex_unit, strlen(regex_unit));
}
- if (VIR_ALLOC(reg) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(reg) < 0)
goto cleanup;
- }
/* Each extent has a "path:offset" pair, and vars[0] will
* be the whole matched string.
*/
nvars = (nextents * 2) + 1;
- if (VIR_ALLOC_N(vars, nvars) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(vars, nvars) < 0)
goto cleanup;
- }
err = regcomp(reg, regex, REG_EXTENDED);
if (err != 0) {
else
VIR_FREE(vgname);
- if (VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1) != 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1) != 0)
goto error;
- }
dev = &thisSource->devices[thisSource->ndevice];
thisSource->ndevice++;
char *path;
*isActive = false;
- if (virAsprintf(&path, "/dev/%s", pool->def->source.name) < 0) {
- virReportOOMError();
+ if (virAsprintf(&path, "/dev/%s", pool->def->source.name) < 0)
return -1;
- }
if (access(path, F_OK) == 0)
*isActive = true;
if (virAsprintf(&vol->target.path, "%s/%s",
pool->def->target.path,
- vol->name) == -1) {
- virReportOOMError();
+ vol->name) == -1)
return -1;
- }
cmd = virCommandNewArgList(LVCREATE,
"--name", vol->name,
virCheckFlags(0, -1);
if (virAsprintf(&volpath, "%s/%s",
- pool->def->source.name, vol->name) < 0) {
- virReportOOMError();
+ pool->def->source.name, vol->name) < 0)
goto cleanup;
- }
virFileWaitForDevices();
virStorageVolDefPtr vol;
int ret = -1;
- if (VIR_ALLOC(vol) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(vol) < 0)
goto cleanup;
- }
vol->type = VIR_STORAGE_VOL_BLOCK;
- if (virAsprintf(&(vol->name), "dm-%u", devnum) < 0) {
- virReportOOMError();
+ if (virAsprintf(&(vol->name), "dm-%u", devnum) < 0)
goto cleanup;
- }
- if (virAsprintf(&vol->target.path, "/dev/%s", dev) < 0) {
- virReportOOMError();
+ if (virAsprintf(&vol->target.path, "/dev/%s", dev) < 0)
goto cleanup;
- }
if (virStorageBackendMpathUpdateVolTargetInfo(&vol->target,
&vol->allocation,
goto cleanup;
if (VIR_REALLOC_N(pool->volumes.objs,
- pool->volumes.count + 1) < 0) {
- virReportOOMError();
+ pool->volumes.count + 1) < 0)
goto cleanup;
- }
pool->volumes.objs[pool->volumes.count++] = vol;
pool->def->capacity += vol->capacity;
pool->def->allocation += vol->allocation;
if (is_mpath == 1) {
- if (virAsprintf(&map_device, "mapper/%s", names->name) < 0) {
- virReportOOMError();
+ if (virAsprintf(&map_device, "mapper/%s", names->name) < 0)
goto out;
- }
if (virStorageBackendGetMinorNumber(names->name, &minor) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
VIR_FREE(vol->target.path);
if (virAsprintf(&vol->target.path, "%s/%s",
pool->def->source.name,
- vol->name) == -1) {
- virReportOOMError();
+ vol->name) == -1)
goto cleanup;
- }
VIR_FREE(vol->key);
if (virAsprintf(&vol->key, "%s/%s",
pool->def->source.name,
- vol->name) == -1) {
- virReportOOMError();
+ vol->name) == -1)
goto cleanup;
- }
ret = 0;
while (true) {
if (VIR_ALLOC_N(names, max_size) < 0)
- goto out_of_memory;
+ goto cleanup;
len = rbd_list(ptr.ioctx, names, &max_size);
if (len >= 0)
if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count + 1) < 0) {
virStoragePoolObjClearVols(pool);
- goto out_of_memory;
+ goto cleanup;
}
if (STREQ(name, ""))
break;
if (VIR_ALLOC(vol) < 0)
- goto out_of_memory;
+ goto cleanup;
if (VIR_STRDUP(vol->name, name) < 0) {
VIR_FREE(vol);
VIR_FREE(names);
virStorageBackendRBDCloseRADOSConn(ptr);
return ret;
-
-out_of_memory:
- virReportOOMError();
- goto cleanup;
}
static int virStorageBackendRBDDeleteVol(virConnectPtr conn,
int retval = 0;
if (virAsprintf(&type_path, "/sys/bus/scsi/devices/%u:%u:%u:%u/type",
- host, bus, target, lun) < 0) {
- virReportOOMError();
+ host, bus, target, lun) < 0)
goto out;
- }
typefile = fopen(type_path, "r");
if (typefile == NULL) {
int retval = 0;
if (VIR_ALLOC(vol) < 0) {
- virReportOOMError();
retval = -1;
goto out;
}
* just leave 'host' out
*/
if (virAsprintf(&(vol->name), "unit:%u:%u:%u", bus, target, lun) < 0) {
- virReportOOMError();
retval = -1;
goto free_vol;
}
if (virAsprintf(&devpath, "/dev/%s", dev) < 0) {
- virReportOOMError();
retval = -1;
goto free_vol;
}
if (VIR_REALLOC_N(pool->volumes.objs,
pool->volumes.count + 1) < 0) {
- virReportOOMError();
retval = -1;
goto free_vol;
}
struct dirent *block_dirent = NULL;
int retval = 0;
- if (virAsprintf(&block_path, "%s/block", lun_path) < 0) {
- virReportOOMError();
+ if (virAsprintf(&block_path, "%s/block", lun_path) < 0)
goto out;
- }
VIR_DEBUG("Looking for block device in '%s'", block_path);
int retval = 0;
if (virAsprintf(&lun_path, "/sys/bus/scsi/devices/%u:%u:%u:%u",
- host, bus, target, lun) < 0) {
- virReportOOMError();
+ host, bus, target, lun) < 0)
goto out;
- }
lun_dir = opendir(lun_path);
if (lun_dir == NULL) {
VIR_DEBUG("Triggering rescan of host %d", host);
if (virAsprintf(&path, "/sys/class/scsi_host/host%u/scan", host) < 0) {
- virReportOOMError();
retval = -1;
goto out;
}
if (getHostNumber(name, &host) < 0)
goto cleanup;
- if (virAsprintf(&path, "/sys/class/scsi_host/host%d", host) < 0) {
- virReportOOMError();
+ if (virAsprintf(&path, "/sys/class/scsi_host/host%d", host) < 0)
goto cleanup;
- }
if (access(path, F_OK) == 0)
*isActive = true;
VIR_FREE(vol->key);
if (virAsprintf(&vol->key, "%s/%s",
- pool->def->source.name, vol->name) == -1) {
- virReportOOMError();
+ pool->def->source.name, vol->name) == -1)
goto cleanup;
- }
VIR_FREE(vol->target.path);
ignore_value(VIR_STRDUP(vol->target.path, vol->name));
*/
if (virAsprintf(&driverState->configDir,
"%s/storage", base) == -1)
- goto out_of_memory;
+ goto error;
if (virAsprintf(&driverState->autostartDir,
"%s/storage/autostart", base) == -1)
- goto out_of_memory;
+ goto error;
VIR_FREE(base);
storageDriverUnlock(driverState);
return 0;
-out_of_memory:
- virReportOOMError();
error:
VIR_FREE(base);
storageDriverUnlock(driverState);
goto cleanup;
}
- if (VIR_ALLOC_N(tmp_vols, obj->volumes.count + 1) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(tmp_vols, obj->volumes.count + 1) < 0)
goto cleanup;
- }
for (i = 0; i < obj->volumes.count; i++) {
if (!virStoragePoolListAllVolumesCheckACL(pool->conn, obj->def,
}
if (VIR_REALLOC_N(pool->volumes.objs,
- pool->volumes.count+1) < 0) {
- virReportOOMError();
+ pool->volumes.count+1) < 0)
goto cleanup;
- }
if (!backend->createVol) {
virReportError(VIR_ERR_NO_SUPPORT,
virStorageVolDefPtr buildvoldef = NULL;
if (VIR_ALLOC(buildvoldef) < 0) {
- virReportOOMError();
voldef = NULL;
goto cleanup;
}
goto cleanup;
if (VIR_REALLOC_N(pool->volumes.objs,
- pool->volumes.count+1) < 0) {
- virReportOOMError();
+ pool->volumes.count+1) < 0)
goto cleanup;
- }
/* 'Define' the new volume so we get async progress reporting */
if (backend->createVol(obj->conn, pool, newvol) < 0) {
ret = storageVolZeroSparseFile(def, st.st_size, fd);
} else {
- if (VIR_ALLOC_N(writebuf, st.st_blksize) != 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(writebuf, st.st_blksize) < 0)
goto out;
- }
ret = storageWipeExtent(def,
fd,