Change in vdsm[ovirt-3.6]: image: copy - set VM metadata images format to RAW
derez at redhat.com
derez at redhat.com
Wed Nov 25 09:18:19 UTC 2015
Hello Adam Litke, Francesco Romani,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/49144
to review the following change.
Change subject: image: copy - set VM metadata images format to RAW
......................................................................
image: copy - set VM metadata images format to RAW
Since commit 0b61c4851a528fd6354d9ab77a68085c41f35dc9
copy of internal raw volumes is done using 'qemu-img convert'
instead of invoking 'dd'.
Consequently, exporting VM metadata images (produce during
live snapshot) fails on qemu-img convert - since the images
'impersonate' to qcow2 (the format in .meta file is cow,
whereas the real format is raw).
Hence, we try to identify the VM metadata image on
'_interImagesCopy' and set its format to RAW
so qemuimg.convert won't fail (QImgError: "Image is
not in qcow2 format").
This approach is a workaround since it's done merely to
conceal the aforementioned miscorrelation, however,
it seems to be simpler than fixing the root cause
(see https://gerrit.ovirt.org/#/c/48768/).
Note: this fix is merely for passing the correct argument
to qemu-img on convert (raw format). I.e. the .meta file of
the target files will still contain the wrong format (cow).
Change-Id: Icaad6599260a2631f580e17404d25554a19ec670
Bug-Url: https://bugzilla.redhat.com/1282239
Signed-off-by: Daniel Erez <derez at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/49002
Reviewed-by: Adam Litke <alitke at redhat.com>
Reviewed-by: Nir Soffer <nsoffer at redhat.com>
Continuous-Integration: Jenkins CI
Reviewed-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/storage/image.py
1 file changed, 26 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/44/49144/1
diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index 791b48c..fcb1fca 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -67,6 +67,9 @@
RENAME_RANDOM_STRING_LEN = 8
+# Size in blocks of the conf file generated during RAM snapshot operation.
+VM_CONF_SIZE_BLK = 20
+
# Temporary size of a volume when we optimize out the prezeroing
TEMPORARY_VOLUME_SIZE = 20480 # in sectors (10M)
@@ -430,8 +433,7 @@
try:
dstVol = destDom.produceVolume(imgUUID=imgUUID,
volUUID=srcVol.volUUID)
- srcFormat = volume.fmt2str(srcVol.getFormat())
- dstFormat = volume.fmt2str(dstVol.getFormat())
+ srcFormat, dstFormat = self._detect_format(srcVol, dstVol)
parentVol = dstVol.getParentVolume()
@@ -465,6 +467,28 @@
# teardown volumes
self.__cleanupMove(srcLeafVol, dstLeafVol)
+ def _detect_format(self, srcVol, dstVol):
+ """
+ VM metadata image format is RAW, whereas in .meta file it's COW:
+ see bz#1282239. Hence, detecting metadata files by size and format
+ mis-correlation.
+ """
+ src_format = srcVol.getFormat()
+ size_in_blk = srcVol.getSize()
+ if src_format == volume.COW_FORMAT and size_in_blk == VM_CONF_SIZE_BLK:
+ info = qemuimg.info(srcVol.getVolumePath())
+ actual_format = info['format']
+
+ if actual_format == qemuimg.FORMAT.RAW:
+ self.log.warning("Incorrect volume format %r has been detected"
+ " for volume %r, using the actual format %r.",
+ qemuimg.FORMAT.QCOW2,
+ srcVol.volUUID,
+ qemuimg.FORMAT.RAW)
+ return qemuimg.FORMAT.RAW, qemuimg.FORMAT.RAW
+
+ return volume.fmt2str(src_format), volume.fmt2str(dstVol.getFormat())
+
def _finalizeDestinationImage(self, destDom, imgUUID, chains, force):
for srcVol in chains['srcChain']:
try:
--
To view, visit https://gerrit.ovirt.org/49144
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icaad6599260a2631f580e17404d25554a19ec670
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Daniel Erez <derez at redhat.com>
Gerrit-Reviewer: Adam Litke <alitke at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
More information about the vdsm-patches
mailing list