diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c index 5d7337093681a6006e38f1b0a4d0da7b50e42dba..5f2469f4f9a3856841ae9c13366a149675f208fd 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -279,6 +279,24 @@ virStorageBackendRBDCloseRADOSConn(virStorageBackendRBDStatePtr ptr) return ret; } +static int +volStorageBackendRBDGetFeatures(rbd_image_t image, + const char *volname, + uint64_t *features) +{ + int r, ret = -1; + + if ((r = rbd_get_features(image, features)) < 0) { + virReportSystemError(-r, _("failed to get the features of RBD image " + "%s"), volname); + goto cleanup; + } + ret = 0; + + cleanup: + return ret; +} + static int volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol, virStoragePoolObjPtr pool, @@ -685,11 +703,8 @@ virStorageBackendRBDImageInfo(rbd_image_t image, goto cleanup; } - if ((r = rbd_get_features(image, features)) < 0) { - virReportSystemError(-r, _("failed to get the features of RBD image %s"), - volname); + if (volStorageBackendRBDGetFeatures(image, volname, features) < 0) goto cleanup; - } if ((r = rbd_get_stripe_unit(image, stripe_unit)) < 0) { virReportSystemError(-r, _("failed to get the stripe unit of RBD image %s"),