mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 01:04:59 +00:00
storage: volStorageBackendRBDRefreshVolInfo: refactor
use the ret variable for return value Signed-off-by: Yi Li <yili@winhong.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
b66f26c342
commit
453bdebe5d
@ -507,36 +507,30 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
|
||||
virStoragePoolObjPtr pool,
|
||||
virStorageBackendRBDStatePtr ptr)
|
||||
{
|
||||
int rc, ret = -1;
|
||||
int ret = -1;
|
||||
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
||||
rbd_image_t image = NULL;
|
||||
rbd_image_info_t info;
|
||||
uint64_t features;
|
||||
uint64_t flags;
|
||||
|
||||
if ((rc = rbd_open_read_only(ptr->ioctx, vol->name, &image, NULL)) < 0) {
|
||||
ret = rc;
|
||||
if ((ret = rbd_open_read_only(ptr->ioctx, vol->name, &image, NULL)) < 0) {
|
||||
virReportSystemError(errno, _("failed to open the RBD image '%s'"),
|
||||
vol->name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((rc = rbd_stat(image, &info, sizeof(info))) < 0) {
|
||||
ret = rc;
|
||||
if ((ret = rbd_stat(image, &info, sizeof(info))) < 0) {
|
||||
virReportSystemError(errno, _("failed to stat the RBD image '%s'"),
|
||||
vol->name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((rc = volStorageBackendRBDGetFeatures(image, vol->name, &features)) < 0) {
|
||||
ret = rc;
|
||||
if ((ret = volStorageBackendRBDGetFeatures(image, vol->name, &features)) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((rc = volStorageBackendRBDGetFlags(image, vol->name, &flags)) < 0) {
|
||||
ret = rc;
|
||||
if ((ret = volStorageBackendRBDGetFlags(image, vol->name, &flags)) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
vol->target.capacity = info.size;
|
||||
vol->type = VIR_STORAGE_VOL_NETWORK;
|
||||
@ -549,10 +543,8 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
|
||||
"Querying for actual allocation",
|
||||
def->source.name, vol->name);
|
||||
|
||||
if ((rc = virStorageBackendRBDSetAllocation(vol, image, &info)) < 0) {
|
||||
ret = rc;
|
||||
if ((ret = virStorageBackendRBDSetAllocation(vol, image, &info)) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
vol->target.allocation = info.obj_size * info.num_objs;
|
||||
}
|
||||
@ -568,8 +560,6 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
|
||||
VIR_FREE(vol->key);
|
||||
vol->key = g_strdup_printf("%s/%s", def->source.name, vol->name);
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (image)
|
||||
rbd_close(image);
|
||||
|
Loading…
Reference in New Issue
Block a user