mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
storage: remove unneeded cleanup labels
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
3814e767d5
commit
abd2899d73
@ -58,36 +58,33 @@ virStorageBackendFileSystemNetFindPoolSourcesFunc(char **const groups,
|
||||
virNetfsDiscoverState *state = data;
|
||||
const char *name, *path;
|
||||
virStoragePoolSource *src = NULL;
|
||||
int ret = -1;
|
||||
|
||||
path = groups[0];
|
||||
|
||||
if (!(name = strrchr(path, '/'))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("invalid netfs path (no /): %s"), path);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
name += 1;
|
||||
if (*name == '\0') {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("invalid netfs path (ends in /): %s"), path);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(src = virStoragePoolSourceListNewSource(&state->list)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (VIR_ALLOC_N(src->hosts, 1) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
src->nhost = 1;
|
||||
|
||||
src->hosts[0].name = g_strdup(state->host);
|
||||
src->dir = g_strdup(path);
|
||||
src->format = VIR_STORAGE_POOL_NETFS_NFS;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -408,17 +408,15 @@ volStorageBackendRBDGetFeatures(rbd_image_t image,
|
||||
const char *volname,
|
||||
uint64_t *features)
|
||||
{
|
||||
int r, ret = -1;
|
||||
int r;
|
||||
|
||||
if ((r = rbd_get_features(image, features)) < 0) {
|
||||
virReportSystemError(-r, _("failed to get the features of RBD image "
|
||||
"%s"), volname);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if LIBRBD_VERSION_CODE > 265
|
||||
@ -464,7 +462,7 @@ virStorageBackendRBDSetAllocation(virStorageVolDefPtr vol,
|
||||
rbd_image_t *image,
|
||||
rbd_image_info_t *info)
|
||||
{
|
||||
int r, ret = -1;
|
||||
int r;
|
||||
size_t allocation = 0;
|
||||
|
||||
if ((r = rbd_diff_iterate2(image, NULL, 0, info->size, 0, 1,
|
||||
@ -472,17 +470,15 @@ virStorageBackendRBDSetAllocation(virStorageVolDefPtr vol,
|
||||
&allocation)) < 0) {
|
||||
virReportSystemError(-r, _("failed to iterate RBD image '%s'"),
|
||||
vol->name);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
VIR_DEBUG("Found %zu bytes allocated for RBD image %s",
|
||||
allocation, vol->name);
|
||||
|
||||
vol->target.allocation = allocation;
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
@ -960,14 +956,13 @@ virStorageBackendRBDImageInfo(rbd_image_t image,
|
||||
uint64_t *stripe_unit,
|
||||
uint64_t *stripe_count)
|
||||
{
|
||||
int ret = -1;
|
||||
int r = 0;
|
||||
uint8_t oldformat;
|
||||
|
||||
if ((r = rbd_get_old_format(image, &oldformat)) < 0) {
|
||||
virReportSystemError(-r, _("failed to get the format of RBD image %s"),
|
||||
volname);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (oldformat != 0) {
|
||||
@ -975,28 +970,25 @@ virStorageBackendRBDImageInfo(rbd_image_t image,
|
||||
_("RBD image %s is old format. Does not support "
|
||||
"extended features and striping"),
|
||||
volname);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (volStorageBackendRBDGetFeatures(image, volname, features) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if ((r = rbd_get_stripe_unit(image, stripe_unit)) < 0) {
|
||||
virReportSystemError(-r, _("failed to get the stripe unit of RBD image %s"),
|
||||
volname);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((r = rbd_get_stripe_count(image, stripe_count)) < 0) {
|
||||
virReportSystemError(-r, _("failed to get the stripe count of RBD image %s"),
|
||||
volname);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Callback function for rbd_diff_iterate() */
|
||||
@ -1111,7 +1103,6 @@ virStorageBackendRBDSnapshotCreate(rbd_image_t image,
|
||||
char *imgname,
|
||||
char *snapname)
|
||||
{
|
||||
int ret = -1;
|
||||
int r = -1;
|
||||
|
||||
VIR_DEBUG("Creating RBD snapshot %s@%s", imgname, snapname);
|
||||
@ -1119,13 +1110,10 @@ virStorageBackendRBDSnapshotCreate(rbd_image_t image,
|
||||
if ((r = rbd_snap_create(image, snapname)) < 0) {
|
||||
virReportSystemError(-r, _("failed to create RBD snapshot %s@%s"),
|
||||
imgname, snapname);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1134,7 +1122,6 @@ virStorageBackendRBDSnapshotProtect(rbd_image_t image,
|
||||
char *snapname)
|
||||
{
|
||||
int r = -1;
|
||||
int ret = -1;
|
||||
int protected;
|
||||
|
||||
VIR_DEBUG("Querying if RBD snapshot %s@%s is protected", imgname, snapname);
|
||||
@ -1142,7 +1129,7 @@ virStorageBackendRBDSnapshotProtect(rbd_image_t image,
|
||||
if ((r = rbd_snap_is_protected(image, snapname, &protected)) < 0) {
|
||||
virReportSystemError(-r, _("failed to verify if RBD snapshot %s@%s "
|
||||
"is protected"), imgname, snapname);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (protected == 0) {
|
||||
@ -1152,16 +1139,13 @@ virStorageBackendRBDSnapshotProtect(rbd_image_t image,
|
||||
if ((r = rbd_snap_protect(image, snapname)) < 0) {
|
||||
virReportSystemError(-r, _("failed to protect RBD snapshot %s@%s"),
|
||||
imgname, snapname);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
VIR_DEBUG("RBD Snapshot %s@%s is already protected", imgname, snapname);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1378,7 +1362,6 @@ virStorageBackendRBDVolWipeDiscard(rbd_image_t image,
|
||||
uint64_t stripe_count)
|
||||
{
|
||||
int r = -1;
|
||||
int ret = -1;
|
||||
unsigned long long offset = 0;
|
||||
unsigned long long length;
|
||||
|
||||
@ -1391,7 +1374,7 @@ virStorageBackendRBDVolWipeDiscard(rbd_image_t image,
|
||||
virReportSystemError(-r, _("discarding %llu bytes failed on "
|
||||
"RBD image %s at offset %llu"),
|
||||
length, imgname, offset);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
VIR_DEBUG("Discarded %llu bytes of RBD image %s at offset %llu",
|
||||
@ -1400,10 +1383,7 @@ virStorageBackendRBDVolWipeDiscard(rbd_image_t image,
|
||||
offset += length;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -68,16 +68,13 @@ virStorageBackendZFSVolModeNeeded(void)
|
||||
if ((ret < 0) || (exit_code != 2)) {
|
||||
VIR_WARN("Command 'zfs get' either failed "
|
||||
"to run or exited with unexpected status");
|
||||
goto cleanup;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (strstr(error, " volmode "))
|
||||
ret = 1;
|
||||
return 1;
|
||||
else
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -291,7 +288,6 @@ virStorageBackendZFSCreateVol(virStoragePoolObjPtr pool,
|
||||
virStorageVolDefPtr vol)
|
||||
{
|
||||
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
||||
int ret = -1;
|
||||
int volmode_needed = -1;
|
||||
g_autoptr(virCommand) cmd = NULL;
|
||||
|
||||
@ -311,7 +307,7 @@ virStorageBackendZFSCreateVol(virStoragePoolObjPtr pool,
|
||||
|
||||
volmode_needed = virStorageBackendZFSVolModeNeeded();
|
||||
if (volmode_needed < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
/**
|
||||
* $ zfs create -o volmode=dev -V 10240K test/volname
|
||||
* $ zfs create -o volmode=dev -s -V 10240K test/volname
|
||||
@ -342,15 +338,12 @@ virStorageBackendZFSCreateVol(virStoragePoolObjPtr pool,
|
||||
virCommandAddArgFormat(cmd, "%s/%s", def->source.name, vol->name);
|
||||
|
||||
if (virCommandRun(cmd, NULL) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (virStorageBackendZFSFindVols(pool, vol) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -621,7 +621,6 @@ storageConnectFindStoragePoolSources(virConnectPtr conn,
|
||||
{
|
||||
int backend_type;
|
||||
virStorageBackendPtr backend;
|
||||
char *ret = NULL;
|
||||
|
||||
if (virConnectFindStoragePoolSourcesEnsureACL(conn) < 0)
|
||||
return NULL;
|
||||
@ -630,24 +629,21 @@ storageConnectFindStoragePoolSources(virConnectPtr conn,
|
||||
if (backend_type < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unknown storage pool type %s"), type);
|
||||
goto cleanup;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
backend = virStorageBackendForType(backend_type);
|
||||
if (backend == NULL)
|
||||
goto cleanup;
|
||||
return NULL;
|
||||
|
||||
if (!backend->findPoolSources) {
|
||||
virReportError(VIR_ERR_NO_SUPPORT,
|
||||
_("pool type '%s' does not support source "
|
||||
"discovery"), type);
|
||||
goto cleanup;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = backend->findPoolSources(srcSpec, flags);
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return backend->findPoolSources(srcSpec, flags);
|
||||
}
|
||||
|
||||
|
||||
@ -1771,25 +1767,22 @@ storageVolDeleteInternal(virStorageBackendPtr backend,
|
||||
bool updateMeta)
|
||||
{
|
||||
virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj);
|
||||
int ret = -1;
|
||||
|
||||
if (!backend->deleteVol) {
|
||||
virReportError(VIR_ERR_NO_SUPPORT,
|
||||
"%s", _("storage pool does not support vol deletion"));
|
||||
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (backend->deleteVol(obj, voldef, flags) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
/* The disk backend updated the pool data including removing the
|
||||
* voldef from the pool (for both the deleteVol and the createVol
|
||||
* failure path. */
|
||||
if (def->type == VIR_STORAGE_POOL_DISK) {
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (def->type == VIR_STORAGE_POOL_DISK)
|
||||
return 0;
|
||||
|
||||
/* Update pool metadata - don't update meta data from error paths
|
||||
* in this module since the allocation/available weren't adjusted yet.
|
||||
@ -1801,10 +1794,8 @@ storageVolDeleteInternal(virStorageBackendPtr backend,
|
||||
}
|
||||
|
||||
virStoragePoolObjRemoveVol(obj, voldef);
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -2797,20 +2788,15 @@ static int
|
||||
storageConnectStoragePoolEventDeregisterAny(virConnectPtr conn,
|
||||
int callbackID)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (virConnectStoragePoolEventDeregisterAnyEnsureACL(conn) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (virObjectEventStateDeregisterID(conn,
|
||||
driver->storageEventState,
|
||||
callbackID, true) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -336,7 +336,7 @@ createRawFile(int fd, virStorageVolDefPtr vol,
|
||||
virReportSystemError(errno,
|
||||
_("cannot extend file '%s'"),
|
||||
vol->target.path);
|
||||
goto cleanup;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Avoid issues with older kernel's <linux/fs.h> namespace pollution. */
|
||||
@ -356,7 +356,7 @@ createRawFile(int fd, virStorageVolDefPtr vol,
|
||||
virReportSystemError(errno,
|
||||
_("cannot allocate %llu bytes in file '%s'"),
|
||||
vol->target.allocation, vol->target.path);
|
||||
goto cleanup;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -368,7 +368,7 @@ createRawFile(int fd, virStorageVolDefPtr vol,
|
||||
* been able to allocate the required space. */
|
||||
if ((ret = virStorageBackendCopyToFD(vol, inputvol, fd, &remain,
|
||||
!need_alloc, reflink_copy)) < 0)
|
||||
goto cleanup;
|
||||
return ret;
|
||||
|
||||
/* If the new allocation is greater than the original capacity,
|
||||
* but fallocate failed, fill the rest with zeroes.
|
||||
@ -381,7 +381,7 @@ createRawFile(int fd, virStorageVolDefPtr vol,
|
||||
ret = -errno;
|
||||
virReportSystemError(errno, _("cannot fill file '%s'"),
|
||||
vol->target.path);
|
||||
goto cleanup;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@ -389,10 +389,9 @@ createRawFile(int fd, virStorageVolDefPtr vol,
|
||||
ret = -errno;
|
||||
virReportSystemError(errno, _("cannot sync data to file '%s'"),
|
||||
vol->target.path);
|
||||
goto cleanup;
|
||||
return ret;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -3747,7 +3746,6 @@ getOldStyleBlockDevice(const char *lun_path G_GNUC_UNUSED,
|
||||
char **block_device)
|
||||
{
|
||||
char *blockp = NULL;
|
||||
int retval = -1;
|
||||
|
||||
/* old-style; just parse out the sd */
|
||||
if (!(blockp = strrchr(block_name, ':'))) {
|
||||
@ -3755,7 +3753,7 @@ getOldStyleBlockDevice(const char *lun_path G_GNUC_UNUSED,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to parse block name %s"),
|
||||
block_name);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
} else {
|
||||
blockp++;
|
||||
*block_device = g_strdup(blockp);
|
||||
@ -3763,9 +3761,7 @@ getOldStyleBlockDevice(const char *lun_path G_GNUC_UNUSED,
|
||||
VIR_DEBUG("Block device is '%s'", *block_device);
|
||||
}
|
||||
|
||||
retval = 0;
|
||||
cleanup:
|
||||
return retval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user