提交 fbb4b210 编写于 作者: Z zhencliu

Supported iscsi and ceph images' convert

  1. Added cfg/remote_image_convert.cfg and remote_convert.py
  2. The following testing scenarios are covered:
     2.1 remote -> local -> remote
     2.2 remote -> remote
     2.3 cache mode tested in remote->local raw->remote raw
         as well as remote->remote raw
Signed-off-by: NZhenchao Liu <zhencliu@redhat.com>
上级 93ea0623
# Network storage backends:
# iscsi_direct
# ceph
# Cache mode:
# remote image1 -> remote raw image2
# remote image1 -> local raw image2 -> remote raw image3
# The following testing scenarios are covered:
# remote image1 -> local image -> remote image2
# remote image1 -> remote image2
- remote_image_convert:
only iscsi_direct ceph
virt_test_type = qemu
type = remote_convert
start_vm = no
kill_vm = yes
force_create_image = no
guest_temp_file = "/var/tmp/convert.tmp"
md5sum_bin = "md5sum"
convert_source = ${images}
convert_target = convert
image_name_convert = "images/image_convert"
variants:
- @default:
- cache_mode:
# only for remote->remote raw image converting and
# remote->local->remote raw image converting
only remote_to_remote.fmt_raw_convert remote_to_local_to_remote.fmt_raw_remote.fmt_raw_convert
source_cache_mode = none
variants:
- none:
cache_mode = none
- writeback:
cache_mode = writeback
- unsafe:
cache_mode = unsafe
- directsync:
cache_mode = directsync
- writethrough:
cache_mode = writethrough
variants:
# target image is 'convert'
- fmt_raw_convert:
image_format_convert = raw
- fmt_qcow2_convert:
image_format_convert = qcow2
- fmt_luks_convert:
image_format_convert = luks
image_secret_convert = convert
variants:
- remote_to_local_to_remote:
# target image is 'convert', converted from remote
enable_iscsi_convert = no
enable_ceph_convert = no
image_raw_device_convert = no
storage_type_convert = filesystem
# target image is 'remote', converted from local
convert_target_remote = remote
image_name_remote = "images/image_convert_remote"
iscsi_direct:
lun_remote = 1
variants:
# target image is 'remote'
- fmt_raw_remote:
image_format_remote = raw
- fmt_qcow2_remote:
image_format_remote = qcow2
- fmt_luks_remote:
image_format_remote = luks
image_secret_remote = convert_remote
- remote_to_remote:
# target image is 'convert', converted from remote
iscsi_direct:
lun_convert = 1
import logging
from virttest import data_dir
from virttest import qemu_storage
from virttest import storage
from avocado import fail_on
from avocado.utils import process
from provider import qemu_img_utils as img_utils
def run(test, params, env):
"""
Convert remote image.
1) Start VM and create a tmp file, record its md5sum, shutdown VM
2) Convert image
3) Start VM by the converted image and then check the md5sum
"""
def _check_file(boot_image, md5_value):
logging.debug("Check md5sum.")
vm = img_utils.boot_vm_with_images(test, params, env, (boot_image,))
session = vm.wait_for_login()
guest_temp_file = params["guest_temp_file"]
md5sum_bin = params.get("md5sum_bin", "md5sum")
img_utils.check_md5sum(guest_temp_file, md5sum_bin, session,
md5_value_to_check=md5_value)
session.close()
vm.destroy()
vm = img_utils.boot_vm_with_images(test, params, env)
session = vm.wait_for_login()
guest_temp_file = params["guest_temp_file"]
md5sum_bin = params.get("md5sum_bin", "md5sum")
sync_bin = params.get("sync_bin", "sync")
logging.info("Create temporary file on guest: %s", guest_temp_file)
img_utils.save_random_file_to_vm(vm, guest_temp_file, 2048 * 512,
sync_bin)
md5_value = img_utils.check_md5sum(guest_temp_file, md5sum_bin, session)
logging.info("Get md5 value of the temporary file: %s", md5_value)
session.close()
vm.destroy()
root_dir = data_dir.get_data_dir()
# Make a list of all source and target image pairs
img_pairs = [(params["convert_source"], params["convert_target"])]
if params.get("convert_target_remote"):
# local -> remote
img_pairs.append((params["convert_target"],
params["convert_target_remote"]))
# Convert images
for source, target in img_pairs:
params["convert_source"] = source
params["convert_target"] = target
source_params = params.object_params(source)
target_params = params.object_params(target)
source_image = qemu_storage.QemuImg(source_params, root_dir, source)
target_image = qemu_storage.QemuImg(target_params, root_dir, target)
# remove the target
target_filename = storage.get_image_filename(target_params, root_dir)
storage.file_remove(target_params, target_filename)
# Convert source to target
cache_mode = params.get("cache_mode")
source_cache_mode = params.get("source_cache_mode")
logging.info("Convert %s to %s", source, target)
fail_on((process.CmdError,))(source_image.convert)(
params, root_dir, cache_mode=cache_mode,
source_cache_mode=source_cache_mode)
_check_file(target, md5_value)
# Remove images converted
for _, target in img_pairs:
target_params = params.object_params(target)
target_image = qemu_storage.QemuImg(target_params, root_dir, target)
target_image.remove()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册