if (VIR_STRDUP_QUIET(canonical_path, path) < 0)
return 2;
} else {
- if (virFileResolveLink(path, &canonical_path) != 0) {
+ if (virFileResolveLink(path, &canonical_path) != 0)
return 2;
- }
partsep = *canonical_path &&
c_isdigit(canonical_path[strlen(canonical_path)-1]) ? "p" : "";
}
#ifdef __linux__
- if (ioctl(fd, BLKBSZGET, &wbytes) < 0) {
+ if (ioctl(fd, BLKBSZGET, &wbytes) < 0)
wbytes = 0;
- }
#endif
if ((wbytes == 0) && fstat(fd, &st) == 0)
wbytes = st.st_blksize;
(vol->target.allocation < inputvol->target.capacity);
ret = virStorageBackendCopyToFD(vol, inputvol, fd, &remain, want_sparse);
- if (ret < 0) {
+ if (ret < 0)
goto cleanup;
- }
}
if (remain && need_alloc) {
virCommandSetGID(cmd, -1);
if (!filecreated) {
- if (virCommandRun(cmd, NULL) < 0) {
+ if (virCommandRun(cmd, NULL) < 0)
return -1;
- }
if (stat(vol->target.path, &st) < 0) {
virReportSystemError(errno,
_("failed to create %s"), vol->target.path);
return -1; /* Don't bother to re-alloc freeExtents - it'll be free'd shortly */
/* first block reported as free, even if it is not */
- if (dev->freeExtents[dev->nfreeExtent].start == 0) {
+ if (dev->freeExtents[dev->nfreeExtent].start == 0)
dev->freeExtents[dev->nfreeExtent].start = SECTOR_SIZE;
- }
pool->def->available +=
(dev->freeExtents[dev->nfreeExtent].end -
return -1;
}
- if (virStorageBackendDiskReadGeometry(pool) != 0) {
+ if (virStorageBackendDiskReadGeometry(pool) != 0)
return -1;
- }
return virStorageBackendDiskReadPartitions(pool, NULL);
}
partType == VIR_STORAGE_VOL_DISK_TYPE_EXTENDED)
count++;
}
- if (count >= 4) {
+ if (count >= 4)
return VIR_STORAGE_VOL_DISK_TYPE_LOGICAL;
- }
}
/* for all other cases, all partitions are primary */
}
/* if we are creating a logical partition, we need one extra
block between partitions (or actually move start one block) */
- if (partType == VIR_STORAGE_VOL_DISK_TYPE_LOGICAL) {
+ if (partType == VIR_STORAGE_VOL_DISK_TYPE_LOGICAL)
size -= SECTOR_SIZE;
- }
}
if (size > neededSize &&
(smallestSize == 0 ||
goto cleanup;
}
- if (virStorageBackendDiskPartFormat(pool, vol, &partFormat) != 0) {
+ if (virStorageBackendDiskPartFormat(pool, vol, &partFormat) != 0)
goto cleanup;
- }
virCommandAddArg(cmd, partFormat);
if (virStorageBackendDiskPartBoundaries(pool, &startOffset,
error:
VIR_FREE(libblkid_format);
- if (probe != NULL) {
+ if (probe != NULL)
blkid_free_probe(probe);
- }
return ret;
}
ok_to_mkfs = true;
}
- if (ok_to_mkfs) {
+ if (ok_to_mkfs)
ret = virStorageBackendExecuteMKFS(device, format);
- }
error:
return ret;
goto out;
}
- if (STREQ(target_type, "multipath")) {
+ if (STREQ(target_type, "multipath"))
ret = 1;
- }
out:
- if (dmt != NULL) {
+ if (dmt != NULL)
dm_task_destroy(dmt);
- }
return ret;
}
struct dm_task *dmt;
struct dm_info info;
- if (!(dmt = dm_task_create(DM_DEVICE_INFO))) {
+ if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
goto out;
- }
- if (!dm_task_set_name(dmt, dev_name)) {
+ if (!dm_task_set_name(dmt, dev_name))
goto out;
- }
- if (!dm_task_run(dmt)) {
+ if (!dm_task_run(dmt))
goto out;
- }
- if (!dm_task_get_info(dmt, &info)) {
+ if (!dm_task_get_info(dmt, &info))
goto out;
- }
*minor = info.minor;
ret = 0;
do {
is_mpath = virStorageBackendIsMultipath(names->name);
- if (is_mpath < 0) {
+ if (is_mpath < 0)
goto out;
- }
if (is_mpath == 1) {
goto out;
}
- if (virStorageBackendMpathNewVol(pool, minor, map_device) < 0) {
+ if (virStorageBackendMpathNewVol(pool, minor, map_device) < 0)
goto out;
- }
VIR_FREE(map_device);
}
virStorageBackendCreateVols(pool, names);
out:
- if (dmt != NULL) {
+ if (dmt != NULL)
dm_task_destroy(dmt);
- }
return retval;
}
ptr.cluster = NULL;
ptr.ioctx = NULL;
- if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) {
+ if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0)
goto cleanup;
- }
- if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) {
+ if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0)
goto cleanup;
- }
struct rados_cluster_stat_t clusterstat;
r = rados_cluster_stat(ptr.cluster, &clusterstat);
VIR_DEBUG("Removing RBD image %s/%s", pool->def->source.name, vol->name);
- if (flags & VIR_STORAGE_VOL_DELETE_ZEROED) {
+ if (flags & VIR_STORAGE_VOL_DELETE_ZEROED)
VIR_WARN("%s", _("This storage backend does not supported zeroed removal of volumes"));
- }
- if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) {
+ if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0)
goto cleanup;
- }
- if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) {
+ if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0)
goto cleanup;
- }
r = rbd_remove(ptr.ioctx, vol->name);
if (r < 0) {
ptr.ioctx = NULL;
int ret = -1;
- if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) {
+ if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0)
goto cleanup;
- }
- if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) {
+ if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0)
goto cleanup;
- }
- if (volStorageBackendRBDRefreshVolInfo(vol, pool, &ptr) < 0) {
+ if (volStorageBackendRBDRefreshVolInfo(vol, pool, &ptr) < 0)
goto cleanup;
- }
ret = 0;
virCheckFlags(0, -1);
- if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) {
+ if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0)
goto cleanup;
- }
- if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) {
+ if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0)
goto cleanup;
- }
r = rbd_open(ptr.ioctx, vol->name, &image, NULL);
if (r < 0) {
while ((direrr = virDirRead(block_dir, &block_dirent, block_path)) > 0) {
- if (STREQLEN(block_dirent->d_name, ".", 1)) {
+ if (STREQLEN(block_dirent->d_name, ".", 1))
continue;
- }
if (VIR_STRDUP(*block_device, block_dirent->d_name) < 0) {
closedir(block_dir);
VIR_DEBUG("%u:%u:%u:%u is a Direct-Access LUN",
host, bus, target, lun);
- if (getBlockDevice(host, bus, target, lun, &block_device) < 0) {
+ if (getBlockDevice(host, bus, target, lun, &block_device) < 0)
goto out;
- }
if (virStorageBackendSCSINewLun(pool,
host, bus, target, lun,
cleanup:
storageDriverUnlock();
- for (i = 0; i < got; i++) {
+ for (i = 0; i < got; i++)
VIR_FREE(names[i]);
- }
memset(names, 0, nnames * sizeof(*names));
return -1;
}
/* Wipe any key the user may have suggested, as volume creation
* will generate the canonical key. */
VIR_FREE(voldef->key);
- if (backend->createVol(obj->conn, pool, voldef) < 0) {
+ if (backend->createVol(obj->conn, pool, voldef) < 0)
goto cleanup;
- }
pool->volumes.objs[pool->volumes.count++] = voldef;
volobj = virGetStorageVol(obj->conn, pool->def->name, voldef->name,
* Wipe any key the user may have suggested, as volume creation
* will generate the canonical key. */
VIR_FREE(newvol->key);
- if (backend->createVol(obj->conn, pool, newvol) < 0) {
+ if (backend->createVol(obj->conn, pool, newvol) < 0)
goto cleanup;
- }
pool->volumes.objs[pool->volumes.count++] = newvol;
volobj = virGetStorageVol(obj->conn, pool->def->name, newvol->name,