提交 0da6bd3d 编写于 作者: S Suqin Huang

hotplug rng devices in loop

Signed-off-by: NSuqin Huang <shuang@redhat.com>
上级 a7f0ebab
......@@ -4,18 +4,33 @@
monitor_type = qmp
monitors = qmp1
repeat_times = 1
rng_num = 4
sub_test_after_hotplug = rng_bat
rng_num = 1
read_rng_timeout = 360
no no_virtio_rng
Windows:
session_cmd_timeout = 240
read_rng_cmd = "X:\random_%PROCESSOR_ARCHITECTURE%.exe"
driver_name = "viorng"
rng_data_rex = "0x\w"
driver_id_cmd = X:\devcon\wxp_x86\devcon.exe find * | find "VirtIO"
driver_check_cmd = X:\devcon\wxp_x86\devcon.exe status @DRIVER_ID
driver_id_pattern = "(.*?):.*?VirtIO RNG Device"
Linux:
session_cmd_timeout = 360
driver_verifier_cmd = "cat /sys/devices/virtual/misc/hw_random/rng_current"
read_rng_cmd = "dd if=/dev/hwrng bs=1 count=10 2>/dev/null|hexdump"
driver_name = "virtio"
rng_data_rex = "\w+"
restart_rngd = "service rngd restart"
stop_rngd = "service rngd stop"
variants:
- multi_rngs:
repeat_times = 1
rng_num = 4
test_after_hotplug = rng_bat
- repeat_in_loop:
repeat_times = 500
rng_num = 1
test_before_hotplug = rng_bat
test_after_hotplug = rng_bat
......@@ -23,47 +23,103 @@ def run(test, params, env):
:param env: Dictionary with test environment
"""
def get_rng_id(vm):
device_list = []
for device in vm.devices:
if isinstance(device, qdevices.QDevice):
if device.get_param("driver") == "virtio-rng-pci":
device_list.append(device)
return device_list
def hotplug_rng(vm, dev):
error_context.context("Hotplug %s" % dev, logging.info)
output = dev.hotplug(vm.monitor)
time.sleep(5)
error_context.context("Check %s from qtree after hotplug" % dev,
logging.info)
qtree_output = dev.verify_hotplug(output, vm.monitor)
if not qtree_output:
msg = "no % device in qtree after hotplug" % dev
raise exceptions.TestFail(msg)
logging.info("%s is hotpluged successfully" % dev)
def unplug_rng(vm, dev):
error_context.context("Hot-unplug %s" % dev, logging.info)
output = dev.unplug(vm.monitor)
time.sleep(5)
error_context.context("Check %s from qtree after unplug" % dev,
logging.info)
qtree_output = dev.verify_unplug(output, vm.monitor)
if not qtree_output:
msg = "Still get %s in qtree after unplug" % dev
raise exceptions.TestFail(msg)
logging.info("%s is unpluged successfully" % dev)
def restart_rngd(vm):
if params.get("restart_rngd"):
session = vm.wait_for_login()
error_context.context("Restart rngd service", logging.info)
status, output = session.cmd_status_output("service rngd restart")
if status != 0:
raise exceptions.TestError(output)
session.close()
def stop_rngd(vm):
if params.get("stop_rngd"):
session = vm.wait_for_login()
error_context.context("Disable rngd service before unplug",
logging.info)
status, output = session.cmd_status_output(params.get("stop_rngd"))
if status != 0:
raise exceptions.TestError(output)
session.close()
login_timeout = int(params.get("login_timeout", 360))
repeat_times = int(params.get("repeat_times", 1))
rng_num = int(params.get("rng_num", 1))
test_before_hotplug = params.get("test_before_hotplug")
test_after_hotplug = params.get("test_after_hotplug")
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
vm.wait_for_login(timeout=login_timeout)
if test_before_hotplug:
restart_rngd(vm)
error_context.context("Run %s before hotplug" % test_before_hotplug)
utils_test.run_virt_sub_test(test, params, env, test_before_hotplug)
# Unplug attached rng device
device_ids = get_rng_id(vm)
if device_ids:
stop_rngd(vm)
time.sleep(5)
for device in device_ids:
unplug_rng(vm, device)
for i in xrange(repeat_times):
dev_list = []
logging.info("Hotplug/unplug rng devices the %sth times", (i+1))
error_context.context("Hotplug/unplug rng devices the %s time"
% (i+1), logging.info)
for num in xrange(rng_num):
vm.devices.set_dirty()
new_dev = qdevices.QDevice("virtio-rng-pci",
{'id': 'virtio-rng-pci-%d' % num})
hotplug_rng(vm, new_dev)
dev_list.append(new_dev)
error_context.context("Hotplug %s" % new_dev, logging.info)
output = new_dev.hotplug(vm.monitor)
time.sleep(2)
error_context.context("Check %sfrom qtree after hotplug" % new_dev,
# Run test after hotplug
if test_after_hotplug and i == xrange(repeat_times)[-1]:
restart_rngd(vm)
error_context.context("Run %s after hotplug" % test_after_hotplug,
logging.info)
qtree_output = new_dev.verify_hotplug(output, vm.monitor)
if not qtree_output:
msg = "no % device in qtree after hotplug"
msg += "the %sth time" % (new_dev, i)
raise exceptions.TestFail(msg)
logging.info("virtio-rng-pci-%d is hotpluged successfully" % num)
sub_test = params.get("sub_test_after_hotplug")
if sub_test:
utils_test.run_virt_sub_test(test, params, env, sub_test)
utils_test.run_virt_sub_test(test, params, env,
test_after_hotplug)
stop_rngd(vm)
time.sleep(5)
for dev in dev_list:
error_context.context("Unplug %s" % dev, logging.info)
output = dev.unplug(vm.monitor)
time.sleep(2)
error_context.context("Check rng device from qtree after unplug",
logging.info)
qtree_output = dev.verify_unplug(output, vm.monitor)
if not qtree_output:
msg = "Still get %s in qtree after unplug %s times" % (dev, i)
raise exceptions.TestFail(msg)
logging.info("%s is unpluged successfully" % dev)
unplug_rng(vm, dev)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册