提交 2400922d 编写于 作者: L Lucas Meneghel Rodrigues

virt: Adds multihost hot-plug and hot-unplug block dev tests.

steps:
  1) start VM
  2) hot-plug hot-unplug block dev
  3) migrate
  4) check VM

conf:
  only (multihost_mig_tests=hotplug_disk_test).hotplug
  only (multihost_mig_tests=hotplug_disk_test).unplug
Signed-off-by: NJiří Župka <jzupka@redhat.com>
上级 92e32196
......@@ -281,6 +281,40 @@
second_floppy_name = "images/test_floppy.img"
floppy_name_host2 = "images/test_floppy2.img"
- hotplug_disk_test:
type = migration_multi_host
start_vm_host1 = yes
not_preprocess_host1 = no
force_create_image = yes
force_create_image_image1 = no
remove_image = yes
remove_image_image1 = no
image_size_hot_disk = 1G
image_name_hot_disk = images/hot_plug
migration_sync_vms = yes
strict_mode = yes
variants:
- unplug:
images_host1 = "${images} hot_disk"
pre_sub_test = migration_multi_host_helper_tests
helper_test_host1 = hot_unplug_block_dev
unplug_block = " hot_disk"
check_vm_before_migration = no
check_vm_needs_restart_host2 = no
reuse_previous_config_host2 = yes
attempts = 100
attempts_timeout = 1
- hotplug:
images_host2 = "${images} hot_disk"
pre_sub_test = migration_multi_host_helper_tests
helper_test_host1 = hot_plug_block_dev
plug_block = " hot_disk"
check_vm_before_migration = no
check_vm_needs_restart_host2 = no
reuse_previous_config_host2 = yes
attempts = 100
attempts_timeout = 1
- cpuflags_multi_host:
not_preprocess_host1 = yes
variants:
......
......@@ -48,6 +48,9 @@ def run_migration_multi_host(test, params, env):
% pre_sub_test, logging.info)
utils_test.run_virt_sub_test(test, params, env, pre_sub_test)
if params.get("check_vm_before_migration", "yes") == "no":
params['check_vm_needs_restart'] = "no"
mig = mig_type(test, params, env, False)
mig._hosts_barrier([srchost, dsthost],
{'src': srchost, 'dst': dsthost, "vms": vms[0]},
......
import re
import time
from autotest.client.shared import error
from virttest import utils_test
from virttest import remote
from virttest import virt_vm
from virttest import utils_misc
class MiniSubtest(object):
def __new__(cls, *args, **kargs):
self = super(MiniSubtest, cls).__new__(cls)
ret = None
if args is None:
args = []
try:
ret = self.test(*args, **kargs)
finally:
if hasattr(self, "clean"):
self.clean()
return ret
@error.context_aware
def run_migration_multi_host_helper_tests(test, params, env):
"""
KVM multi-host migration test:
:param test: kvm test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
class hot_unplug_block_dev(MiniSubtest):
def test(self):
attempts = int(params.get("attempts", "100"))
attempt_timeout = int(params.get("attempt_timeout", "1"))
vms = params.get("vms").split(" ")
vm = env.get_vm(vms[0])
for block in params.objects("unplug_block"):
for _ in range(attempts):
if vm.devices.simple_unplug(vm.devices["drive_%s" % block],
vm.monitor)[1] is True:
break
else:
time.sleep(attempt_timeout)
for _ in range(attempts):
if vm.devices.simple_unplug(vm.devices[block],
vm.monitor)[1] is True:
break
else:
time.sleep(attempt_timeout)
class hot_plug_block_dev(MiniSubtest):
def test(self):
def get_index(vm, index):
while vm.index_in_use.get(str(index)):
index += 1
return index
attempts = int(params.get("attempts", "1"))
attempt_timeout = int(params.get("attempt_timeout", "1"))
vms = params.get("vms").split(" ")
vm = env.get_vm(vms[0])
devices = vm.devices
for image_name in params.objects("plug_block"):
# FIXME: Use qemu_devices for handling indexes
image_params = params.object_params(image_name)
if image_params.get("boot_drive") == "no":
continue
if params.get("index_enable") == "yes":
drive_index = image_params.get("drive_index")
if drive_index:
index = drive_index
else:
vm.last_driver_index = get_index(vm,
vm.last_driver_index)
index = str(vm.last_driver_index)
vm.last_driver_index += 1
else:
index = None
image_bootindex = None
image_boot = image_params.get("image_boot")
if not re.search("boot=on\|off", devices.get_help_text(),
re.MULTILINE):
if image_boot in ['yes', 'on', True]:
image_bootindex = str(vm.last_boot_index)
vm.last_boot_index += 1
image_boot = "unused"
image_bootindex = image_params.get('bootindex',
image_bootindex)
else:
if image_boot in ['yes', 'on', True]:
if vm.last_boot_index > 0:
image_boot = False
vm.last_boot_index += 1
image_params = params.object_params(image_name)
if image_params.get("boot_drive") == "no":
continue
devs = vm.devices.images_define_by_params(image_name,
image_params,
'disk',
index,
image_boot,
image_bootindex)
for dev in devs:
for _ in range(attempts):
if (vm.devices.simple_hotplug(dev,
vm.monitor)[1] is True):
return
time.sleep(attempt_timeout)
test_type = params.get("helper_test")
if (test_type in locals()):
tests_group = locals()[test_type]
tests_group()
else:
raise error.TestFail("Test group '%s' is not defined in"
" cpuflags test" % test_type)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册