virReportError(VIR_ERR_NO_STORAGE_POOL,
_("no storage pool with matching name '%s'"),
obj->pool);
- goto out;
+ goto cleanup;
}
if (!virStoragePoolObjIsActive(pool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->def->name);
- goto out;
+ goto cleanup;
}
vol = virStorageVolDefFindByName(pool, obj->name);
virReportError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"),
obj->name);
- goto out;
+ goto cleanup;
}
if (virStorageVolDownloadEnsureACL(obj->conn, pool->def, vol) < 0)
- goto out;
+ goto cleanup;
if (vol->building) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("volume '%s' is still being allocated."),
vol->name);
- goto out;
+ goto cleanup;
}
if (virFDStreamOpenFile(stream,
vol->target.path,
offset, length,
O_RDONLY) < 0)
- goto out;
+ goto cleanup;
ret = 0;
-out:
+cleanup:
if (pool)
virStoragePoolObjUnlock(pool);
virReportError(VIR_ERR_NO_STORAGE_POOL,
_("no storage pool with matching name '%s'"),
obj->pool);
- goto out;
+ goto cleanup;
}
if (!virStoragePoolObjIsActive(pool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->def->name);
- goto out;
+ goto cleanup;
}
vol = virStorageVolDefFindByName(pool, obj->name);
virReportError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"),
obj->name);
- goto out;
+ goto cleanup;
}
if (virStorageVolUploadEnsureACL(obj->conn, pool->def, vol) < 0)
- goto out;
+ goto cleanup;
if (vol->building) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("volume '%s' is still being allocated."),
vol->name);
- goto out;
+ goto cleanup;
}
/* Not using O_CREAT because the file is required to
vol->target.path,
offset, length,
O_WRONLY) < 0)
- goto out;
+ goto cleanup;
ret = 0;
-out:
+cleanup:
if (pool)
virStoragePoolObjUnlock(pool);
virReportError(VIR_ERR_NO_STORAGE_POOL,
_("no storage pool with matching name '%s'"),
obj->pool);
- goto out;
+ goto cleanup;
}
if (!virStoragePoolObjIsActive(pool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->def->name);
- goto out;
+ goto cleanup;
}
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
- goto out;
+ goto cleanup;
vol = virStorageVolDefFindByName(pool, obj->name);
virReportError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"),
obj->name);
- goto out;
+ goto cleanup;
}
if (virStorageVolResizeEnsureACL(obj->conn, pool->def, vol) < 0)
- goto out;
+ goto cleanup;
if (vol->building) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("volume '%s' is still being allocated."),
vol->name);
- goto out;
+ goto cleanup;
}
if (flags & VIR_STORAGE_VOL_RESIZE_DELTA) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("can't shrink capacity below "
"existing allocation"));
- goto out;
+ goto cleanup;
}
if (abs_capacity < vol->capacity &&
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Can't shrink capacity below current "
"capacity with shrink flag explicitly specified"));
- goto out;
+ goto cleanup;
}
if (abs_capacity > vol->capacity + pool->def->available) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Not enough space left on storage pool"));
- goto out;
+ goto cleanup;
}
if (!backend->resizeVol) {
virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("storage pool does not support changing of "
"volume capacity"));
- goto out;
+ goto cleanup;
}
if (backend->resizeVol(obj->conn, pool, vol, abs_capacity, flags) < 0)
- goto out;
+ goto cleanup;
vol->capacity = abs_capacity;
if (flags & VIR_STORAGE_VOL_RESIZE_ALLOCATE)
ret = 0;
-out:
+cleanup:
if (pool)
virStoragePoolObjUnlock(pool);
_("Failed to truncate volume with "
"path '%s' to 0 bytes"),
vol->target.path);
- goto out;
+ return ret;
}
ret = ftruncate(fd, size);
vol->target.path, (uintmax_t)size);
}
-out:
return ret;
}
_("Failed to seek to position %ju in volume "
"with path '%s'"),
(uintmax_t)extent_start, vol->target.path);
- goto out;
+ goto cleanup;
}
remaining = extent_length;
"storage volume with path '%s'"),
write_size, vol->target.path);
- goto out;
+ goto cleanup;
}
*bytes_wiped += written;
virReportSystemError(errno,
_("cannot sync data to volume with path '%s'"),
vol->target.path);
- goto out;
+ goto cleanup;
}
VIR_DEBUG("Wrote %zu bytes to volume with path '%s'",
ret = 0;
-out:
+cleanup:
return ret;
}
virReportSystemError(errno,
_("Failed to open storage volume with path '%s'"),
def->target.path);
- goto out;
+ goto cleanup;
}
if (fstat(fd, &st) == -1) {
virReportSystemError(errno,
_("Failed to stat storage volume with path '%s'"),
def->target.path);
- goto out;
+ goto cleanup;
}
if (algorithm != VIR_STORAGE_VOL_WIPE_ALG_ZERO) {
def->target.path, NULL);
if (virCommandRun(cmd, NULL) < 0)
- goto out;
+ goto cleanup;
ret = 0;
- goto out;
+ goto cleanup;
} else {
if (S_ISREG(st.st_mode) && st.st_blocks < (st.st_size / DEV_BSIZE)) {
ret = storageVolZeroSparseFile(def, st.st_size, fd);
} else {
if (VIR_ALLOC_N(writebuf, st.st_blksize) < 0)
- goto out;
+ goto cleanup;
ret = storageWipeExtent(def,
fd,
}
}
-out:
+cleanup:
virCommandFree(cmd);
VIR_FREE(writebuf);
VIR_FORCE_CLOSE(fd);
virReportError(VIR_ERR_NO_STORAGE_POOL,
_("no storage pool with matching name '%s'"),
obj->pool);
- goto out;
+ goto cleanup;
}
if (!virStoragePoolObjIsActive(pool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->def->name);
- goto out;
+ goto cleanup;
}
vol = virStorageVolDefFindByName(pool, obj->name);
virReportError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"),
obj->name);
- goto out;
+ goto cleanup;
}
if (virStorageVolWipePatternEnsureACL(obj->conn, pool->def, vol) < 0)
- goto out;
+ goto cleanup;
if (vol->building) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("volume '%s' is still being allocated."),
vol->name);
- goto out;
+ goto cleanup;
}
if (storageVolWipeInternal(vol, algorithm) == -1) {
- goto out;
+ goto cleanup;
}
ret = 0;
-out:
+cleanup:
if (pool) {
virStoragePoolObjUnlock(pool);
}