提交 029c7c7c 编写于 作者: Y Yiqiao Pu

Merge pull request #16 from spcui/qemu_img_fix

qemu.tests: qemu_img.py bugs fix
......@@ -22,21 +22,26 @@
image_name_large = create_large_image
remove_image_large = yes
variants:
- cluster_512:
image_cluster_size = 512
- cluster_1024:
image_cluster_size = 1024
- cluster_4096:
image_cluster_size = 4096
- cluster_1M:
image_cluster_size = 1M
- cluster_2M:
image_cluster_size = 2M
- @cluster_size_default:
- cluster_size:
no Host_RHEL.5
variants:
- cluster_512:
image_cluster_size = 512
- cluster_1024:
image_cluster_size = 1024
- cluster_4096:
image_cluster_size = 4096
- cluster_1M:
image_cluster_size = 1M
- cluster_2M:
image_cluster_size = 2M
variants:
- non-preallocated:
no raw
preallocated = off
- preallocated:
no Host_RHEL.5
no raw
preallocated = metadata
- convert:
......
......@@ -76,7 +76,7 @@ def run(test, params, env):
def _create(cmd, img_name, fmt, img_size=None, base_img=None,
base_img_fmt=None, encrypted="no",
preallocated="no", cluster_size=None):
preallocated="off", cluster_size=None):
"""
Simple wrapper of 'qemu-img create'
......@@ -87,22 +87,33 @@ def run(test, params, env):
:param base_img: base image if create a snapshot image
:param base_img_fmt: base image format if create a snapshot image
:param encrypted: indicates whether the created image is encrypted
:param preallocated: if preallocation when create image,
allowed values: off, metadata. Default is "off"
:param cluster_size: the cluster size for the image
"""
cmd += " create"
if encrypted == "yes":
cmd += " -e"
if base_img:
cmd += " -b %s" % base_img
if base_img_fmt:
cmd += " -F %s" % base_img_fmt
cmd += " -f %s" % fmt
options = []
if preallocated != "off":
options.append("preallocation=%s" % preallocated)
if cluster_size is not None:
options.append("cluster_size=%s" % cluster_size)
if options:
cmd +=" -o %s" % ",".join(options)
cmd += " %s" % img_name
if img_size:
cmd += " %s" % img_size
if preallocated == "yes":
cmd += " -o preallocation=metadata"
if cluster_size is not None:
cmd += " -o cluster_size=%s" % cluster_size
msg = "Creating image %s by command %s" % (img_name, cmd)
error.context(msg, logging.info)
utils.system(cmd, verbose=False)
......@@ -126,7 +137,8 @@ def run(test, params, env):
img = device
_create(cmd, img_name=img, fmt=image_format,
img_size=params["image_size_large"],
preallocated=params.get("preallocated", "no"))
preallocated=params.get("preallocated", "off"),
cluster_size=params.get("image_cluster_size"))
os.remove(img)
def _convert(cmd, output_fmt, img_name, output_filename,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册