未验证 提交 bfd26ecb 编写于 作者: L Longxiang Lyu 提交者: GitHub

Merge pull request #2138 from hellohellenmao/1811588

New case of resize_short_overlay
- resize_short_overlay:
only qcow2
virt_test_type = qemu
type = resize_short_overlay
start_vm = no
force_create_image = no
remove_image = yes
images = "base mid top"
image_chain = "base mid top"
image_name_base = "images/base"
image_size_base = 2M
image_format_base = qcow2
image_name_mid = "images/mid"
image_size_mid = 1M
image_format_mid = qcow2
image_name_top = "images/top"
image_size_top = 2M
image_format_top = qcow2
# 2M - 1M ($image_size_top - $image_size_mid)
diff_size = 1M
base_cmd = "write -P1 0 ${image_size_base}"
top_cmd = "read -P0 ${image_size_mid} ${diff_size}"
import logging
from avocado import fail_on
from avocado.utils import process
from virttest import data_dir
from virttest.qemu_io import QemuIOSystem
from virttest.qemu_storage import QemuImg
def run(test, params, env):
"""
Check the data after resizing short overlay over longer backing files.
1. Create a qcow2 base image.
2. Create a middle snapshot file with smaller size.
3. Create a top snapshot with the size as the same as the one of base.
4. Write '1' to the base image file.
5. Check the data of the top image file.
6. Commit top image file.
7. Check the data in the middle image file.
:param test: VT test object.
:param params: Dictionary with the test parameters.
:param env: Dictionary with test environment.
"""
def _qemu_io(img, cmd):
"""Run qemu-io cmd to a given img."""
logging.info("Run qemu-io %s" % img.image_filename)
try:
QemuIOSystem(test, params, img.image_filename).cmd_output(cmd, 120)
except process.CmdError as err:
test.fail("qemu-io to '%s' failed: %s." % (img.image_filename, err))
images = params["image_chain"].split()
root_dir = data_dir.get_data_dir()
base = QemuImg(params.object_params(images[0]), root_dir, images[0])
mid = QemuImg(params.object_params(images[1]), root_dir, images[1])
top = QemuImg(params.object_params(images[-1]), root_dir, images[-1])
logging.info("Create base and snapshot files")
for image in (base, mid, top):
image.create(image.params)
_qemu_io(base, params["base_cmd"])
top_cmd = params["top_cmd"]
_qemu_io(top, top_cmd)
logging.info("Commit %s image file." % top.image_filename)
fail_on((process.CmdError,))(top.commit)()
_qemu_io(mid, top_cmd)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册