Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
0da6bd3d
T
tp-qemu
项目概览
openeuler
/
tp-qemu
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tp-qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0da6bd3d
编写于
9月 05, 2016
作者:
S
Suqin Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hotplug rng devices in loop
Signed-off-by:
N
Suqin Huang
<
shuang@redhat.com
>
上级
a7f0ebab
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
99 addition
and
28 deletion
+99
-28
qemu/tests/cfg/rng_hotplug.cfg
qemu/tests/cfg/rng_hotplug.cfg
+18
-3
qemu/tests/rng_hotplug.py
qemu/tests/rng_hotplug.py
+81
-25
未找到文件。
qemu/tests/cfg/rng_hotplug.cfg
浏览文件 @
0da6bd3d
...
...
@@ -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
qemu/tests/rng_hotplug.py
浏览文件 @
0da6bd3d
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录