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;
}
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
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,
&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
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) {
_("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() */
char *imgname,
char *snapname)
{
- int ret = -1;
int r = -1;
VIR_DEBUG("Creating RBD snapshot %s@%s", imgname, snapname);
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
char *snapname)
{
int r = -1;
- int ret = -1;
int protected;
VIR_DEBUG("Querying if RBD snapshot %s@%s is protected", imgname, snapname);
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) {
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
uint64_t stripe_count)
{
int r = -1;
- int ret = -1;
unsigned long long offset = 0;
unsigned long long length;
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",
offset += length;
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
static int
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
virStorageVolDefPtr vol)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
- int ret = -1;
int volmode_needed = -1;
g_autoptr(virCommand) cmd = NULL;
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
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
{
int backend_type;
virStorageBackendPtr backend;
- char *ret = NULL;
if (virConnectFindStoragePoolSourcesEnsureACL(conn) < 0)
return NULL;
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);
}
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.
}
virStoragePoolObjRemoveVol(obj, voldef);
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
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;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
virReportSystemError(errno,
_("cannot extend file '%s'"),
vol->target.path);
- goto cleanup;
+ return ret;
}
/* Avoid issues with older kernel's <linux/fs.h> namespace pollution. */
virReportSystemError(errno,
_("cannot allocate %llu bytes in file '%s'"),
vol->target.allocation, vol->target.path);
- goto cleanup;
+ return ret;
}
}
#endif
* 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.
ret = -errno;
virReportSystemError(errno, _("cannot fill file '%s'"),
vol->target.path);
- goto cleanup;
+ return ret;
}
}
ret = -errno;
virReportSystemError(errno, _("cannot sync data to file '%s'"),
vol->target.path);
- goto cleanup;
+ return ret;
}
- cleanup:
return ret;
}
char **block_device)
{
char *blockp = NULL;
- int retval = -1;
/* old-style; just parse out the sd */
if (!(blockp = strrchr(block_name, ':'))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to parse block name %s"),
block_name);
- goto cleanup;
+ return -1;
} else {
blockp++;
*block_device = g_strdup(blockp);
VIR_DEBUG("Block device is '%s'", *block_device);
}
- retval = 0;
- cleanup:
- return retval;
+ return 0;
}