From a5a383adc17f708204fdaeb3dead2a4f3cebf4fd Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Fri, 15 Jan 2016 13:52:16 +0100 Subject: [PATCH] rbd: Set r variable so it can be returned should an error occur This was reported in bug #1298024 where r would be filled with the return code of rbd_open(). Should rbd_snap_unprotect() fail for any reason the virReportSystemError call would return 'Success' since rbd_open() succeeded. https://bugzilla.redhat.com/show_bug.cgi?id=1298024 Signed-off-by: Wido den Hollander --- src/storage/storage_backend_rbd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c index e20a54d35d..8c7a80d8c8 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -473,7 +473,8 @@ static int virStorageBackendRBDCleanupSnapshots(rados_ioctx_t ioctx, if (snap_count > 0) { for (i = 0; i < snap_count; i++) { - if (rbd_snap_is_protected(image, snaps[i].name, &protected)) { + r = rbd_snap_is_protected(image, snaps[i].name, &protected); + if (r < 0) { virReportSystemError(-r, _("failed to verify if snapshot '%s/%s@%s' is protected"), source->name, vol->name, snaps[i].name); @@ -485,7 +486,8 @@ static int virStorageBackendRBDCleanupSnapshots(rados_ioctx_t ioctx, "unprotected", source->name, vol->name, snaps[i].name); - if (rbd_snap_unprotect(image, snaps[i].name) < 0) { + r = rbd_snap_unprotect(image, snaps[i].name); + if (r < 0) { virReportSystemError(-r, _("failed to unprotect snapshot '%s/%s@%s'"), source->name, vol->name, snaps[i].name); -- GitLab