Federico Simoncelli has uploaded a new change for review.

Change subject: volume: unify the backing file path logic in a function
......................................................................

volume: unify the backing file path logic in a function

This patch unifies the backing file path computation logic in a single
function (getBackingVolumePath).

Change-Id: I7575f4dd3c6918dfee72ac4c23f27a56a8390b9b
Signed-off-by: Federico Simoncelli <[email protected]>
---
M vdsm/storage/image.py
M vdsm/storage/volume.py
2 files changed, 11 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/18/26918/1

diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index 4de9e2c..2cf8e7a 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -871,8 +871,8 @@
 
         srcVol.prepare(rw=True, chainrw=True, setrw=True)
         try:
-            backingVolPath = os.path.join('..', srcVolParams['imgUUID'],
-                                          volParams['volUUID'])
+            backingVolPath = volume.getBackingVolumePath(
+                srcVolParams['imgUUID'], volParams['volUUID'])
             srcVol.rebase(volParams['volUUID'], backingVolPath,
                           volParams['volFormat'], unsafe=False, rollback=True)
         finally:
@@ -926,8 +926,8 @@
             # Step 2: Rebase successor on top of tmpVol
             #   qemu-img rebase -b tmpBackingFile -F backingFormat -f srcFormat
             #   src
-            backingVolPath = os.path.join('..', srcVolParams['imgUUID'],
-                                          newUUID)
+            backingVolPath = volume.getBackingVolumePath(
+                srcVolParams['imgUUID'], newUUID)
             srcVol.rebase(newUUID, backingVolPath, volParams['volFormat'],
                           unsafe=False, rollback=True)
         finally:
@@ -1012,8 +1012,8 @@
         #   src
         for ch in chList:
             ch.prepare(rw=True, chainrw=True, setrw=True, force=True)
-            backingVolPath = os.path.join('..', srcVolParams['imgUUID'],
-                                          srcVolParams['volUUID'])
+            backingVolPath = volume.getBackingVolumePath(
+                srcVolParams['imgUUID'], srcVolParams['volUUID'])
             try:
                 ch.rebase(srcVolParams['volUUID'], backingVolPath,
                           volParams['volFormat'], unsafe=True, rollback=True)
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index 7f1eaf1..535d503 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -117,6 +117,10 @@
     return None
 
 
+def getBackingVolumePath(imgUUID, volUUID):
+    return os.path.join('..', imgUUID, volUUID)
+
+
 class VmVolumeInfo(object):
     TYPE_PATH = "path"
     TYPE_NETWORK = "network"
@@ -204,7 +208,7 @@
             try:
                 (rc, out, err) = qemuRebase(
                     vol.getVolumePath(), vol.getFormat(),
-                    os.path.join('..', srcImg, srcParent),
+                    getBackingVolumePath(srcImg, srcParent),
                     int(dstFormat), misc.parseBool(unsafe),
                     vars.task.aborting, False)
                 if rc:


-- 
To view, visit http://gerrit.ovirt.org/26918
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7575f4dd3c6918dfee72ac4c23f27a56a8390b9b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to