Change in vdsm[master]: image: use qemu-img convert to copy internal volumes

Federico Simoncelli fsimonce at redhat.com
Wed Sep 24 22:02:11 UTC 2014


Federico Simoncelli has uploaded a new change for review.

Change subject: image: use qemu-img convert to copy internal volumes
......................................................................

image: use qemu-img convert to copy internal volumes

According to the qemu-img manual:

 You can use the backing_file option to force the output image to be
 created as a copy on write image of the specified base image; the
 backing_file should have the same content as the input's base image,
 however the path, image format, etc may differ.

The benefits to use qemu-img convert instead of dd to copy the internal
volumes are:

- we unify operations under just one tool that is specific for image
  manipulations

- copying images from block domains we won't copy the entire chunk
  (1Gb) but only the amount of data really in use

The downside is the additional call to getParentVolume (that seems
trascurable compared to the amount of data that we're going to copy).

Change-Id: I1c740d88d52ca678d6c02d0ea500d2459c26560c
Signed-off-by: Federico Simoncelli <fsimonce at redhat.com>
---
M vdsm/storage/image.py
1 file changed, 18 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/55/33355/1

diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index 9855a26..306722b 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -430,21 +430,25 @@
                 try:
                     dstVol = destDom.produceVolume(imgUUID=imgUUID,
                                                    volUUID=srcVol.volUUID)
-                    srcFmt = srcVol.getFormat()
-                    if srcFmt == volume.RAW_FORMAT:
-                        srcFmtStr = volume.fmt2str(srcFmt)
-                        dstFmtStr = volume.fmt2str(dstVol.getFormat())
-                        self.log.debug("start qemu convert")
-                        qemuimg.convert(srcVol.getVolumePath(),
-                                        dstVol.getVolumePath(),
-                                        vars.task.aborting,
-                                        srcFmtStr, dstFmtStr)
+                    srcFmtStr = volume.fmt2str(srcVol.getFormat())
+                    dstFmtStr = volume.fmt2str(dstVol.getFormat())
+
+                    pntVol = dstVol.getParentVolume()
+
+                    if pntVol is not None:
+                        pntBakPath = volume.getBackingVolumePath(
+                            imgUUID, pntVol.volUUID)
+                        pntFmtStr = volume.fmt2str(pntVol.getFormat())
                     else:
-                        srcSize = srcVol.getVolumeSize(bs=1)
-                        misc.ddWatchCopy(srcVol.getVolumePath(),
-                                         dstVol.getVolumePath(),
-                                         vars.task.aborting,
-                                         size=srcSize)
+                        pntBakPath = None
+                        pntFmtStr = None
+
+                    self.log.debug("start qemu convert")
+                    qemuimg.convert(srcVol.getVolumePath(),
+                                    dstVol.getVolumePath(),
+                                    vars.task.aborting,
+                                    srcFmtStr, dstFmtStr,
+                                    pntBakPath, pntFmtStr)
                 except ActionStopped:
                     raise
                 except se.StorageException:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1c740d88d52ca678d6c02d0ea500d2459c26560c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce at redhat.com>


More information about the vdsm-patches mailing list