mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
Remove unnecessary curly brackets in src/storage/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
5cca4cd16f
commit
e7a1da8aeb
@ -91,9 +91,8 @@ int main(int argc, char **argv)
|
|||||||
if (VIR_STRDUP_QUIET(canonical_path, path) < 0)
|
if (VIR_STRDUP_QUIET(canonical_path, path) < 0)
|
||||||
return 2;
|
return 2;
|
||||||
} else {
|
} else {
|
||||||
if (virFileResolveLink(path, &canonical_path) != 0) {
|
if (virFileResolveLink(path, &canonical_path) != 0)
|
||||||
return 2;
|
return 2;
|
||||||
}
|
|
||||||
|
|
||||||
partsep = *canonical_path &&
|
partsep = *canonical_path &&
|
||||||
c_isdigit(canonical_path[strlen(canonical_path)-1]) ? "p" : "";
|
c_isdigit(canonical_path[strlen(canonical_path)-1]) ? "p" : "";
|
||||||
|
@ -182,9 +182,8 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
if (ioctl(fd, BLKBSZGET, &wbytes) < 0) {
|
if (ioctl(fd, BLKBSZGET, &wbytes) < 0)
|
||||||
wbytes = 0;
|
wbytes = 0;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if ((wbytes == 0) && fstat(fd, &st) == 0)
|
if ((wbytes == 0) && fstat(fd, &st) == 0)
|
||||||
wbytes = st.st_blksize;
|
wbytes = st.st_blksize;
|
||||||
@ -395,9 +394,8 @@ createRawFile(int fd, virStorageVolDefPtr vol,
|
|||||||
(vol->target.allocation < inputvol->target.capacity);
|
(vol->target.allocation < inputvol->target.capacity);
|
||||||
|
|
||||||
ret = virStorageBackendCopyToFD(vol, inputvol, fd, &remain, want_sparse);
|
ret = virStorageBackendCopyToFD(vol, inputvol, fd, &remain, want_sparse);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remain && need_alloc) {
|
if (remain && need_alloc) {
|
||||||
@ -631,9 +629,8 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
|
|||||||
virCommandSetGID(cmd, -1);
|
virCommandSetGID(cmd, -1);
|
||||||
|
|
||||||
if (!filecreated) {
|
if (!filecreated) {
|
||||||
if (virCommandRun(cmd, NULL) < 0) {
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
if (stat(vol->target.path, &st) < 0) {
|
if (stat(vol->target.path, &st) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("failed to create %s"), vol->target.path);
|
_("failed to create %s"), vol->target.path);
|
||||||
|
@ -171,9 +171,8 @@ virStorageBackendDiskMakeFreeExtent(virStoragePoolObjPtr pool,
|
|||||||
return -1; /* Don't bother to re-alloc freeExtents - it'll be free'd shortly */
|
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 */
|
/* 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;
|
dev->freeExtents[dev->nfreeExtent].start = SECTOR_SIZE;
|
||||||
}
|
|
||||||
|
|
||||||
pool->def->available +=
|
pool->def->available +=
|
||||||
(dev->freeExtents[dev->nfreeExtent].end -
|
(dev->freeExtents[dev->nfreeExtent].end -
|
||||||
@ -349,9 +348,8 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virStorageBackendDiskReadGeometry(pool) != 0) {
|
if (virStorageBackendDiskReadGeometry(pool) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
return virStorageBackendDiskReadPartitions(pool, NULL);
|
return virStorageBackendDiskReadPartitions(pool, NULL);
|
||||||
}
|
}
|
||||||
@ -467,9 +465,8 @@ virStorageBackendDiskPartTypeToCreate(virStoragePoolObjPtr pool)
|
|||||||
partType == VIR_STORAGE_VOL_DISK_TYPE_EXTENDED)
|
partType == VIR_STORAGE_VOL_DISK_TYPE_EXTENDED)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
if (count >= 4) {
|
if (count >= 4)
|
||||||
return VIR_STORAGE_VOL_DISK_TYPE_LOGICAL;
|
return VIR_STORAGE_VOL_DISK_TYPE_LOGICAL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for all other cases, all partitions are primary */
|
/* for all other cases, all partitions are primary */
|
||||||
@ -587,9 +584,8 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool,
|
|||||||
}
|
}
|
||||||
/* if we are creating a logical partition, we need one extra
|
/* if we are creating a logical partition, we need one extra
|
||||||
block between partitions (or actually move start one block) */
|
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;
|
size -= SECTOR_SIZE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (size > neededSize &&
|
if (size > neededSize &&
|
||||||
(smallestSize == 0 ||
|
(smallestSize == 0 ||
|
||||||
@ -659,9 +655,8 @@ virStorageBackendDiskCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virStorageBackendDiskPartFormat(pool, vol, &partFormat) != 0) {
|
if (virStorageBackendDiskPartFormat(pool, vol, &partFormat) != 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
virCommandAddArg(cmd, partFormat);
|
virCommandAddArg(cmd, partFormat);
|
||||||
|
|
||||||
if (virStorageBackendDiskPartBoundaries(pool, &startOffset,
|
if (virStorageBackendDiskPartBoundaries(pool, &startOffset,
|
||||||
|
@ -639,9 +639,8 @@ virStorageBackendFileSystemProbe(const char *device,
|
|||||||
error:
|
error:
|
||||||
VIR_FREE(libblkid_format);
|
VIR_FREE(libblkid_format);
|
||||||
|
|
||||||
if (probe != NULL) {
|
if (probe != NULL)
|
||||||
blkid_free_probe(probe);
|
blkid_free_probe(probe);
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -737,9 +736,8 @@ virStorageBackendMakeFileSystem(virStoragePoolObjPtr pool,
|
|||||||
ok_to_mkfs = true;
|
ok_to_mkfs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok_to_mkfs) {
|
if (ok_to_mkfs)
|
||||||
ret = virStorageBackendExecuteMKFS(device, format);
|
ret = virStorageBackendExecuteMKFS(device, format);
|
||||||
}
|
|
||||||
|
|
||||||
error:
|
error:
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -119,14 +119,12 @@ virStorageBackendIsMultipath(const char *dev_name)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STREQ(target_type, "multipath")) {
|
if (STREQ(target_type, "multipath"))
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (dmt != NULL) {
|
if (dmt != NULL)
|
||||||
dm_task_destroy(dmt);
|
dm_task_destroy(dmt);
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,21 +136,17 @@ virStorageBackendGetMinorNumber(const char *dev_name, uint32_t *minor)
|
|||||||
struct dm_task *dmt;
|
struct dm_task *dmt;
|
||||||
struct dm_info info;
|
struct dm_info info;
|
||||||
|
|
||||||
if (!(dmt = dm_task_create(DM_DEVICE_INFO))) {
|
if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
if (!dm_task_set_name(dmt, dev_name)) {
|
if (!dm_task_set_name(dmt, dev_name))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
if (!dm_task_run(dmt)) {
|
if (!dm_task_run(dmt))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
if (!dm_task_get_info(dmt, &info)) {
|
if (!dm_task_get_info(dmt, &info))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
*minor = info.minor;
|
*minor = info.minor;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -177,9 +171,8 @@ virStorageBackendCreateVols(virStoragePoolObjPtr pool,
|
|||||||
do {
|
do {
|
||||||
is_mpath = virStorageBackendIsMultipath(names->name);
|
is_mpath = virStorageBackendIsMultipath(names->name);
|
||||||
|
|
||||||
if (is_mpath < 0) {
|
if (is_mpath < 0)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
if (is_mpath == 1) {
|
if (is_mpath == 1) {
|
||||||
|
|
||||||
@ -193,9 +186,8 @@ virStorageBackendCreateVols(virStoragePoolObjPtr pool,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virStorageBackendMpathNewVol(pool, minor, map_device) < 0) {
|
if (virStorageBackendMpathNewVol(pool, minor, map_device) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
VIR_FREE(map_device);
|
VIR_FREE(map_device);
|
||||||
}
|
}
|
||||||
@ -247,9 +239,8 @@ virStorageBackendGetMaps(virStoragePoolObjPtr pool)
|
|||||||
virStorageBackendCreateVols(pool, names);
|
virStorageBackendCreateVols(pool, names);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (dmt != NULL) {
|
if (dmt != NULL)
|
||||||
dm_task_destroy(dmt);
|
dm_task_destroy(dmt);
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,13 +330,11 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr conn,
|
|||||||
ptr.cluster = NULL;
|
ptr.cluster = NULL;
|
||||||
ptr.ioctx = NULL;
|
ptr.ioctx = NULL;
|
||||||
|
|
||||||
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) {
|
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) {
|
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
struct rados_cluster_stat_t clusterstat;
|
struct rados_cluster_stat_t clusterstat;
|
||||||
r = rados_cluster_stat(ptr.cluster, &clusterstat);
|
r = rados_cluster_stat(ptr.cluster, &clusterstat);
|
||||||
@ -428,17 +426,14 @@ static int virStorageBackendRBDDeleteVol(virConnectPtr conn,
|
|||||||
|
|
||||||
VIR_DEBUG("Removing RBD image %s/%s", pool->def->source.name, vol->name);
|
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"));
|
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;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) {
|
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
r = rbd_remove(ptr.ioctx, vol->name);
|
r = rbd_remove(ptr.ioctx, vol->name);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
@ -555,17 +550,14 @@ static int virStorageBackendRBDRefreshVol(virConnectPtr conn,
|
|||||||
ptr.ioctx = NULL;
|
ptr.ioctx = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) {
|
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) {
|
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (volStorageBackendRBDRefreshVolInfo(vol, pool, &ptr) < 0) {
|
if (volStorageBackendRBDRefreshVolInfo(vol, pool, &ptr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
@ -589,13 +581,11 @@ static int virStorageBackendRBDResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) {
|
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) {
|
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
r = rbd_open(ptr.ioctx, vol->name, &image, NULL);
|
r = rbd_open(ptr.ioctx, vol->name, &image, NULL);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
@ -256,9 +256,8 @@ getNewStyleBlockDevice(const char *lun_path,
|
|||||||
|
|
||||||
while ((direrr = virDirRead(block_dir, &block_dirent, block_path)) > 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;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (VIR_STRDUP(*block_device, block_dirent->d_name) < 0) {
|
if (VIR_STRDUP(*block_device, block_dirent->d_name) < 0) {
|
||||||
closedir(block_dir);
|
closedir(block_dir);
|
||||||
@ -397,9 +396,8 @@ processLU(virStoragePoolObjPtr pool,
|
|||||||
VIR_DEBUG("%u:%u:%u:%u is a Direct-Access LUN",
|
VIR_DEBUG("%u:%u:%u:%u is a Direct-Access LUN",
|
||||||
host, bus, target, 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;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
if (virStorageBackendSCSINewLun(pool,
|
if (virStorageBackendSCSINewLun(pool,
|
||||||
host, bus, target, lun,
|
host, bus, target, lun,
|
||||||
|
@ -484,9 +484,8 @@ storageConnectListDefinedStoragePools(virConnectPtr conn,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
storageDriverUnlock();
|
storageDriverUnlock();
|
||||||
for (i = 0; i < got; i++) {
|
for (i = 0; i < got; i++)
|
||||||
VIR_FREE(names[i]);
|
VIR_FREE(names[i]);
|
||||||
}
|
|
||||||
memset(names, 0, nnames * sizeof(*names));
|
memset(names, 0, nnames * sizeof(*names));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1650,9 +1649,8 @@ storageVolCreateXML(virStoragePoolPtr obj,
|
|||||||
/* Wipe any key the user may have suggested, as volume creation
|
/* Wipe any key the user may have suggested, as volume creation
|
||||||
* will generate the canonical key. */
|
* will generate the canonical key. */
|
||||||
VIR_FREE(voldef->key);
|
VIR_FREE(voldef->key);
|
||||||
if (backend->createVol(obj->conn, pool, voldef) < 0) {
|
if (backend->createVol(obj->conn, pool, voldef) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
pool->volumes.objs[pool->volumes.count++] = voldef;
|
pool->volumes.objs[pool->volumes.count++] = voldef;
|
||||||
volobj = virGetStorageVol(obj->conn, pool->def->name, voldef->name,
|
volobj = virGetStorageVol(obj->conn, pool->def->name, voldef->name,
|
||||||
@ -1830,9 +1828,8 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
|
|||||||
* Wipe any key the user may have suggested, as volume creation
|
* Wipe any key the user may have suggested, as volume creation
|
||||||
* will generate the canonical key. */
|
* will generate the canonical key. */
|
||||||
VIR_FREE(newvol->key);
|
VIR_FREE(newvol->key);
|
||||||
if (backend->createVol(obj->conn, pool, newvol) < 0) {
|
if (backend->createVol(obj->conn, pool, newvol) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
pool->volumes.objs[pool->volumes.count++] = newvol;
|
pool->volumes.objs[pool->volumes.count++] = newvol;
|
||||||
volobj = virGetStorageVol(obj->conn, pool->def->name, newvol->name,
|
volobj = virGetStorageVol(obj->conn, pool->def->name, newvol->name,
|
||||||
|
Loading…
Reference in New Issue
Block a user