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 <wido@widodh.nl>
This commit is contained in:
Wido den Hollander 2016-01-15 13:52:16 +01:00 committed by Ján Tomko
parent 7f866e54df
commit a5a383adc1

View File

@ -473,7 +473,8 @@ static int virStorageBackendRBDCleanupSnapshots(rados_ioctx_t ioctx,
if (snap_count > 0) { if (snap_count > 0) {
for (i = 0; i < snap_count; i++) { 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"), virReportSystemError(-r, _("failed to verify if snapshot '%s/%s@%s' is protected"),
source->name, vol->name, source->name, vol->name,
snaps[i].name); snaps[i].name);
@ -485,7 +486,8 @@ static int virStorageBackendRBDCleanupSnapshots(rados_ioctx_t ioctx,
"unprotected", source->name, vol->name, "unprotected", source->name, vol->name,
snaps[i].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'"), virReportSystemError(-r, _("failed to unprotect snapshot '%s/%s@%s'"),
source->name, vol->name, source->name, vol->name,
snaps[i].name); snaps[i].name);