Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
dd3009f4
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,发现更多精彩内容 >>
提交
dd3009f4
编写于
8月 12, 2016
作者:
X
Xu Tian
提交者:
GitHub
8月 12, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #713 from xutian/virtio_port_hotplug
tp-qemu: add virtio port hotplug/unplug tests
上级
2eaece5b
f8fa996b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
114 addition
and
0 deletion
+114
-0
qemu/tests/cfg/virtio_port_hotplug.cfg
qemu/tests/cfg/virtio_port_hotplug.cfg
+19
-0
qemu/tests/virtio_port_hotplug.py
qemu/tests/virtio_port_hotplug.py
+95
-0
未找到文件。
qemu/tests/cfg/virtio_port_hotplug.cfg
0 → 100644
浏览文件 @
dd3009f4
- virtio_port_hotplug:
type = virtio_port_hotplug
virtio_ports = vc1 vc2
virtio_port_type = serialport
unplug_device = vc1 vc2
device_type_vc1 = serialport
device_type_vc2 = console
kill_vm = yes
kill_vm_on_error = yes
repeat_times = 100
Linux:
modprobe_module = virtio_console
variants:
- unplug_chardev:
unplug_chardev_vc1 = yes
unplug_chardev_vc2 = yes
- @unplug_port:
unplug_chardev_vc1 = no
unplug_chardev_vc2 = no
qemu/tests/virtio_port_hotplug.py
0 → 100644
浏览文件 @
dd3009f4
import
time
import
logging
from
autotest.client.shared
import
error
from
avocado.core
import
exceptions
from
virttest.qemu_devices
import
qdevices
@
error
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Test hot unplug virtio serial devices.
1) Start guest with virtio serial device(s).
2) Load module in guest os.
3) For each of the virtio serial ports, do following steps one by one:
3.1) Unload module in guest
3.2) Hot-unplug the virtio serial port
3.3) Hotplug the devices
3.4) Reload module in the guest
4) Repeat step2,3 100 times
5) Reboot VM to make sure the guest kernel not panic.
:param test: QEMU test object.
:param params: Dictionary with the test parameters.
:param env: Dictionary with test environment.
"""
def
get_virtio_port_by_name
(
vm
,
name
):
"""
Get virtio port object by name in VM.
:param name: name of the port
"""
for
device
in
vm
.
devices
:
if
isinstance
(
device
,
qdevices
.
QDevice
):
if
device
.
get_param
(
"name"
)
==
name
:
return
device
return
None
def
get_virtio_port_name_by_params
(
params
,
tag
):
"""
Get virtio port name via params according tag.
:param params: test params.
:param tag: port name or tag(eg, vc1).
"""
prefix
=
params
.
get
(
'virtio_port_name_prefix'
)
index
=
params
.
objects
(
"virtio_ports"
).
index
(
tag
)
if
prefix
:
return
"%s%d"
%
(
prefix
,
index
)
return
tag
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
for
repeat
in
xrange
(
int
(
params
.
get
(
"repeat_times"
,
1
))):
repeat
+=
1
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
module
=
params
.
get
(
"modprobe_module"
)
if
module
:
error
.
context
(
"Load module %s"
%
module
,
logging
.
info
)
session
.
cmd
(
"modprobe %s"
%
module
)
for
port
in
params
.
objects
(
"virtio_ports"
):
port_params
=
params
.
object_params
(
port
)
port_name
=
get_virtio_port_name_by_params
(
port_params
,
port
)
virtio_port
=
get_virtio_port_by_name
(
vm
,
port_name
)
if
not
virtio_port
:
raise
exceptions
.
TestFail
(
"Virtio Port named '%s' not found"
%
port_name
)
chardev_qid
=
virtio_port
.
get_param
(
"chardev"
)
port_chardev
=
vm
.
devices
.
get_by_qid
(
chardev_qid
)[
0
]
if
module
:
error
.
context
(
"Unload module %s"
%
module
,
logging
.
info
)
session
.
cmd
(
"modprobe -r %s"
%
module
)
error
.
context
(
"Unplug virtio port '%s' in %d tune(s)"
%
(
port
,
repeat
),
logging
.
info
)
virtio_port
.
unplug
(
vm
.
monitor
)
if
port_params
.
get
(
"unplug_chardev"
)
==
"yes"
:
error
.
context
(
"Unplug chardev '%s' for virtio port '%s'"
%
(
port
,
chardev_qid
),
logging
.
info
)
port_chardev
.
unplug
(
vm
.
monitor
)
time
.
sleep
(
0.5
)
port_chardev
.
hotplug
(
vm
.
monitor
)
virtio_port
.
hotplug
(
vm
.
monitor
)
if
module
:
error
.
context
(
"Load module %s"
%
module
,
logging
.
info
)
session
.
cmd
(
"modprobe %s"
%
module
)
session
.
close
()
vm
.
reboot
()
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
session
.
close
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录