Change in vdsm[ovirt-3.5]: qemuimg: Create qcow2 compat 0.10 images when converting exi...
nsoffer at redhat.com
nsoffer at redhat.com
Mon Sep 29 15:19:59 UTC 2014
Hello Federico Simoncelli, Allon Mureinik, Dan Kenigsberg, Francesco Romani,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/33494
to review the following change.
Change subject: qemuimg: Create qcow2 compat 0.10 images when converting existing images
......................................................................
qemuimg: Create qcow2 compat 0.10 images when converting existing images
Commit 1f7c3ac2c handled only creation of new images. This patch adds the
required -o compat=0.10 option when converting existing images.
_supports_qcow2_compat() accepts a command argument and invokes the
specific command to detect if the compat option is supported.
Change-Id: I733fdd8c0e50a98627794c19c61b1d9bf6d6d6b1
Bug-Url: https://bugzilla.redhat.com/1139707
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
Reviewed-on: http://gerrit.ovirt.org/33349
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
Reviewed-by: Allon Mureinik <amureini at redhat.com>
Reviewed-by: Francesco Romani <fromani at redhat.com>
Reviewed-by: Federico Simoncelli <fsimonce at redhat.com>
---
M lib/vdsm/qemuimg.py
1 file changed, 17 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/94/33494/1
diff --git a/lib/vdsm/qemuimg.py b/lib/vdsm/qemuimg.py
index c36bc26..2aa130a 100644
--- a/lib/vdsm/qemuimg.py
+++ b/lib/vdsm/qemuimg.py
@@ -115,7 +115,7 @@
if format:
cmd.extend(("-f", format))
- if format == FORMAT.QCOW2 and _supports_qcow2_compat():
+ if format == FORMAT.QCOW2 and _supports_qcow2_compat('create'):
cmd.extend(('-o', 'compat=' + QCOW2_COMPAT))
if backing:
@@ -137,12 +137,24 @@
raise QImgError(rc, out, err)
-def _supports_qcow2_compat():
+def _supports_qcow2_compat(command):
"""
+ qemu-img "create" and "convert" commands support a "compat" option in
+ recent versions. This will run the specified command using the "-o ?"
+ option to find if "compat" option is available.
+
+ Raises KeyError if called with another command.
+
TODO: Remove this when qemu versions providing the "compat" option are
available on all platforms.
"""
- cmd = [_qemuimg.cmd, "create", "-f", FORMAT.QCOW2, "-o", "?", "/dev/null"]
+ # Older qemu-img requires all filenames although unneeded
+ args = {"create": ("-f", ("/dev/null",)),
+ "convert": ("-O", ("/dev/null", "/dev/null"))}
+ flag, dummy_files = args[command]
+
+ cmd = [_qemuimg.cmd, command, flag, FORMAT.QCOW2, "-o", "?"]
+ cmd.extend(dummy_files)
rc, out, err = utils.execCmd(cmd, raw=True)
@@ -188,6 +200,8 @@
if dstFormat:
cmd.extend(("-O", dstFormat))
+ if dstFormat == FORMAT.QCOW2 and _supports_qcow2_compat('convert'):
+ cmd.extend(('-o', 'compat=' + QCOW2_COMPAT))
cmd.append(dstImage)
--
To view, visit http://gerrit.ovirt.org/33494
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I733fdd8c0e50a98627794c19c61b1d9bf6d6d6b1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
More information about the vdsm-patches
mailing list