]> xenbits.xensource.com Git - libvirt.git/commitdiff
rbd: Set r variable so it can be returned should an error occur
authorWido den Hollander <wido@widodh.nl>
Fri, 15 Jan 2016 12:52:16 +0000 (13:52 +0100)
committerJán Tomko <jtomko@redhat.com>
Mon, 18 Jan 2016 13:06:24 +0000 (14:06 +0100)
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@widodh.nl>
src/storage/storage_backend_rbd.c

index e20a54d35d40d07d29cd623176f384453f69e724..8c7a80d8c8c6a39cc879973728a4370d9f1d0c24 100644 (file)
@@ -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);