Adam Litke has uploaded a new change for review.

Change subject: storage: Pass only srcVol to workarounds.detect_format
......................................................................

storage: Pass only srcVol to workarounds.detect_format

When copying an image we do not change the format of the volumes on the
fly.  Therefore the destination volume format will always be the same as
that of the source volume.  Given this we can simplify the function so
that it only receives the source volume and only returns one format
which should be used for the source and destination volumes.

Change-Id: I6c3be993a1326ec2b4e85d93602e8afed39561a1
Signed-off-by: Adam Litke <ali...@redhat.com>
---
M tests/storage_workarounds_test.py
M vdsm/storage/image.py
M vdsm/storage/workarounds.py
3 files changed, 15 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/61/64261/1

diff --git a/tests/storage_workarounds_test.py 
b/tests/storage_workarounds_test.py
index afd646e..09d7ce4 100644
--- a/tests/storage_workarounds_test.py
+++ b/tests/storage_workarounds_test.py
@@ -53,10 +53,9 @@
         expect the workaround to report both volumes as RAW.
         """
         with fake_file_env() as env:
-            src = make_volume(env, VM_CONF_SIZE, md_fmt='cow', real_fmt='raw')
-            dst = make_volume(env, VM_CONF_SIZE, md_fmt='cow', real_fmt='raw')
-            self.assertEqual((qemuimg.FORMAT.RAW, qemuimg.FORMAT.RAW),
-                             workarounds.detect_format(src, dst))
+            vol = make_volume(env, VM_CONF_SIZE, md_fmt='cow', real_fmt='raw')
+            self.assertEqual(qemuimg.FORMAT.RAW,
+                             workarounds.detect_format(vol))
 
     def test_bad_format_other_size(self):
         """
@@ -65,17 +64,15 @@
         """
         size = 2 * VM_CONF_SIZE
         with fake_file_env() as env:
-            src = make_volume(env, size, md_fmt='cow', real_fmt='raw')
-            dst = make_volume(env, size, md_fmt='cow', real_fmt='raw')
-            self.assertEqual((qemuimg.FORMAT.QCOW2, qemuimg.FORMAT.QCOW2),
-                             workarounds.detect_format(src, dst))
+            vol = make_volume(env, size, md_fmt='cow', real_fmt='raw')
+            self.assertEqual(qemuimg.FORMAT.QCOW2,
+                             workarounds.detect_format(vol))
 
     def test_cow_vm_conf_disk(self):
         """
         When a VM configuration disk is actually COW format report it correctly
         """
         with fake_file_env() as env:
-            src = make_volume(env, VM_CONF_SIZE, md_fmt='cow', real_fmt='cow')
-            dst = make_volume(env, VM_CONF_SIZE, md_fmt='cow', real_fmt='cow')
-            self.assertEqual((qemuimg.FORMAT.QCOW2, qemuimg.FORMAT.QCOW2),
-                             workarounds.detect_format(src, dst))
+            vol = make_volume(env, VM_CONF_SIZE, md_fmt='cow', real_fmt='cow')
+            self.assertEqual(qemuimg.FORMAT.QCOW2,
+                             workarounds.detect_format(vol))
diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index 4833931..ca5d783 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -455,8 +455,7 @@
                 try:
                     dstVol = destDom.produceVolume(imgUUID=imgUUID,
                                                    volUUID=srcVol.volUUID)
-                    srcFormat, dstFormat = workarounds.detect_format(srcVol,
-                                                                     dstVol)
+                    volFormat = workarounds.detect_format(srcVol)
 
                     parentVol = dstVol.getParentVolume()
 
@@ -471,8 +470,8 @@
                     operation = qemuimg.convert(
                         srcVol.getVolumePath(),
                         dstVol.getVolumePath(),
-                        srcFormat=srcFormat,
-                        dstFormat=dstFormat,
+                        srcFormat=volFormat,
+                        dstFormat=volFormat,
                         backing=backing,
                         backingFormat=backingFormat)
                     with utils.stopwatch("Copy volume %s" % srcVol.volUUID):
diff --git a/vdsm/storage/workarounds.py b/vdsm/storage/workarounds.py
index 7cea63d..8b40277 100644
--- a/vdsm/storage/workarounds.py
+++ b/vdsm/storage/workarounds.py
@@ -29,7 +29,7 @@
 VM_CONF_SIZE_BLK = 20
 
 
-def detect_format(srcVol, dstVol):
+def detect_format(srcVol):
     """
     set VM metadata images format to RAW
 
@@ -58,6 +58,6 @@
                         qemuimg.FORMAT.QCOW2,
                         srcVol.volUUID,
                         qemuimg.FORMAT.RAW)
-            return qemuimg.FORMAT.RAW, qemuimg.FORMAT.RAW
+            return qemuimg.FORMAT.RAW
 
-    return sc.fmt2str(src_format), sc.fmt2str(dstVol.getFormat())
+    return sc.fmt2str(src_format)


-- 
To view, visit https://gerrit.ovirt.org/64261
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c3be993a1326ec2b4e85d93602e8afed39561a1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <ali...@redhat.com>
_______________________________________________
vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org
To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org

Reply via email to