[PATCH] rbd: Set r variable so it can be returned should an error occur

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <wido@xxxxxxxxx>
---
 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 e20a54d..8c7a80d 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);
-- 
1.9.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]