提交 cfdb17d3 编写于 作者: Z zhencliu

Supported ceph image extending and shrinking

  1. Only ceph was supported
  2. Extended and shrinked ceph image
Signed-off-by: NZhenchao Liu <zhencliu@redhat.com>
上级 912ec5fa
# Network storage backends:
# ceph
# The following testing scenarios are covered:
# extend remote image
# shrink remote image
# Note:
# Both -blockdev & -drive were supported
- block_resize_with_remote_storage:
no RHEL.4
only ceph
type = remote_block_resize
extend_ratio = 1.5
shrink_ratio = 0.9
disk_change_ratio = "${extend_ratio} ${shrink_ratio}"
accept_ratio = 0.005
qcow2:
Host_RHEL.m6, Host_RHEL.m7.u0, Host_RHEL.m7.u1, Host_RHEL.m7.u2, Host_RHEL.m7.u3, Host_RHEL.m7.u4, Host_RHEL.m7.u5:
disk_change_ratio = ${extend_ratio}
ide, ahci:
need_reboot = yes
virtio_scsi:
guest_prepare_cmd = "echo 1 > /sys/block/sdb/device/rescan"
RHEL.5:
need_reboot = yes
Host_RHEL.m6..ide:
blk_extra_params_stg = "wwn=0x5000123456789abc"
images += " stg"
image_size_stg = 10G
image_name_stg = images/stg
create_image_stg = yes
remove_image_stg = yes
force_create_image_stg = yes
blk_extra_params_stg = "serial=TARGET_DISK0"
format_disk = no
import logging
import json
from avocado.utils import wait
from virttest import error_context
from virttest import utils_disk
from virttest import qemu_storage
from virttest import data_dir
from virttest.qemu_capabilities import Flags
@error_context.context_aware
def run(test, params, env):
"""
KVM block resize test:
1) Start guest with both data disk and system disk.
2) Extend/shrink data disk in guest.
3) Verify the data disk size match expected size.
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
def verify_disk_size(session, os_type, disk):
"""
Verify the current block size match with the expected size.
"""
current_size = utils_disk.get_disk_size(session, os_type, disk)
accept_ratio = float(params.get("accept_ratio", 0))
if (current_size <= block_size and
current_size >= block_size * (1 - accept_ratio)):
logging.info("Block Resizing Finished !!! \n"
"Current size %s is same as the expected %s",
current_size, block_size)
return True
else:
logging.error("Current: %s\nExpect: %s\n" % (current_size,
block_size))
return False
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
timeout = float(params.get("login_timeout", 240))
os_type = params["os_type"]
img_size = params.get("image_size_stg", "10G")
data_image = params.get("images").split()[-1]
data_image_params = params.object_params(data_image)
img = qemu_storage.QemuImg(data_image_params, data_dir.get_data_dir(),
data_image)
filters = {}
data_image_dev = ""
if vm.check_capability(Flags.BLOCKDEV):
filters = {"driver": data_image_params.get("image_format", "qcow2")}
else:
filters = {"file": img.image_filename}
# get format node-name(-blockdev) or device name(-drive)
for dev in vm.devices.get_by_params(filters):
if dev.aobject == data_image:
data_image_dev = dev.get_qid()
if not data_image_dev:
test.error("Cannot find device to resize.")
block_virtual_size = json.loads(img.info(force_share=True,
output="json"))["virtual-size"]
session = vm.wait_for_login(timeout=timeout)
disk = sorted(utils_disk.get_linux_disks(session).keys())[0]
for ratio in params.objects("disk_change_ratio"):
block_size = int(int(block_virtual_size) * float(ratio))
error_context.context("Change disk size to %s in monitor"
% block_size, logging.info)
if vm.check_capability(Flags.BLOCKDEV):
args = (None, block_size, data_image_dev)
else:
args = (data_image_dev, block_size)
vm.monitor.block_resize(*args)
# to apply the new size
if params.get("guest_prepare_cmd", ""):
session.cmd(params.get("guest_prepare_cmd"))
if params.get("need_reboot") == "yes":
session = vm.reboot(session=session)
if not wait.wait_for(lambda: verify_disk_size(session, os_type,
disk), 20, 0, 1, "Block Resizing"):
test.fail("The current block size is not the same as expected.\n")
session.close()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册