Change in vdsm[master]: image: Remove redundant activate and deactivate of the same ...
nsoffer at redhat.com
nsoffer at redhat.com
Fri Oct 4 19:42:45 UTC 2013
Nir Soffer has posted comments on this change.
Change subject: image: Remove redundant activate and deactivate of the same volume
......................................................................
Patch Set 1: Code-Review-1
(2 comments)
Usage of try-finally is unsafe.
....................................................
File vdsm/storage/image.py
Line 919:
Line 920: # We should prepare/teardown volume for every single rebase.
Line 921: # The reason is recheckIfLeaf at the end of the rebase, that change
Line 922: # volume permissions to RO for internal volumes.
Line 923: srcVol.prepare(rw=True, chainrw=True, setrw=True)
If srcVol.prepare raise, tmpvol will not be teardown. Not related to this patch - just to make sure we do not forget this. See bellow for safe way to do this.
Line 924: try:
Line 925: # Step 2: Rebase successor on top of tmpVol
Line 926: # qemu-img rebase -b tmpBackingFile -F backingFormat -f srcFormat
Line 927: # src
Line 937: unsafe=True, rollback=False)
Line 938: finally:
Line 939: srcVol.teardown(sdUUID=srcVol.sdUUID, volUUID=srcVol.volUUID)
Line 940: tmpVol.teardown(sdUUID=tmpVol.sdUUID, volUUID=tmpVol.volUUID,
Line 941: justme=True)
If srcVol.teardown raise an exception, tmpVol.teardown will be skipped. Even if now teardown never raises, it may in the future.
The safe way to do this is to nest try-finally blocks:
prepare this
try:
work with this
prepare that
try:
work with that
finally:
teardown that
finally:
teardown this
Line 942:
Line 943: # Step 4: Delete temporary volume
Line 944: tmpVol.delete(postZero=False, force=True)
Line 945:
--
To view, visit http://gerrit.ovirt.org/19854
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I3d615fd8e9b199cef1340360c7f68b19919b0caa
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan at redhat.com>
Gerrit-Reviewer: Ayal Baron <abaron at redhat.com>
Gerrit-Reviewer: Eduardo <ewarszaw at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
More information about the vdsm-patches
mailing list