Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
d3116c66
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,发现更多精彩内容 >>
未验证
提交
d3116c66
编写于
4月 10, 2020
作者:
Y
Yanan Fu
提交者:
GitHub
4月 10, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2112 from nanliu-r/hot-unplug_port_during_data_transfer
virtio_serial:Hot-unplug port during data transferring
上级
bfc04828
7a8bd6c0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
97 addition
and
80 deletion
+97
-80
qemu/tests/cfg/virtio_port_hotplug.cfg
qemu/tests/cfg/virtio_port_hotplug.cfg
+9
-7
qemu/tests/virtio_port_hotplug.py
qemu/tests/virtio_port_hotplug.py
+48
-35
qemu/tests/virtio_serial_file_transfer.py
qemu/tests/virtio_serial_file_transfer.py
+40
-38
未找到文件。
qemu/tests/cfg/virtio_port_hotplug.cfg
浏览文件 @
d3116c66
...
...
@@ -29,14 +29,16 @@
unplug_chardev_vc1 = yes
unplug_chardev_vc2 = yes
- @unplug_port:
serials += " vc1 vc2"
serial_type_vc1 = virtserialport
serial_type_vc2 = virtconsole
file_transfer_serial_port = vc1
unplug_device = vc1 vc2
serials += " vs1 vs2"
serial_type_vs1 = virtserialport
serial_type_vs2 = virtserialport
unplug_device = vs1 vs2
check_module = no
unplug_chardev_vs1 = no
unplug_chardev_vs2 = no
filesize = 100
unplug_chardev_vc1 = no
unplug_chardev_vc2 = no
Linux:
filesize = 2000
- unplug_port_chardev_pci:
type = virtio_serial_unplug_port_chardev_pci
sleep_time = 0.5
...
...
qemu/tests/virtio_port_hotplug.py
浏览文件 @
d3116c66
...
...
@@ -2,9 +2,10 @@ import time
import
logging
from
avocado.utils
import
process
from
virttest
import
utils_test
from
virttest
import
error_context
from
qemu.tests.virtio_serial_file_transfer
import
transfer_data
from
qemu.tests.vioser_in_use
import
run_bg_test
from
qemu.tests.virtio_serial_file_transfer
import
transfer_data
@
error_context
.
context_aware
...
...
@@ -13,7 +14,7 @@ def run(test, params, env):
Test hot unplug virtio serial devices.
1) Start guest with virtio serial device(s).
2) Run serial data trainsfer in background
(windows only)
2) Run serial data trainsfer in background
3) Load module in guest os(linux only).
4) For each of the virtio serial ports, do following steps one by one:
4.1) Unload module in guest(linux only)
...
...
@@ -28,35 +29,46 @@ def run(test, params, env):
:param params: Dictionary with the test parameters.
:param env: Dictionary with test environment.
"""
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
os_type
=
params
[
"os_type"
]
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
if
params
[
"os_type"
]
==
"windows"
:
run_bg_test
(
test
,
params
,
vm
)
for
repeat
in
range
(
int
(
params
.
get
(
"repeat_times"
,
1
))):
repeat
+=
1
module
=
params
.
get
(
"modprobe_module"
)
check_module
=
params
.
get_boolean
(
"check_module"
,
"yes"
)
session
=
vm
.
wait_for_login
()
if
os_type
==
"windows"
:
driver_name
=
params
[
"driver_name"
]
session
=
utils_test
.
qemu
.
windrv_check_running_verifier
(
session
,
vm
,
test
,
driver_name
)
if
module
and
check_module
:
error_context
.
context
(
"Load module %s"
%
module
,
logging
.
info
)
session
.
cmd
(
"modprobe %s"
%
module
)
time
.
sleep
(
1
)
session
.
close
()
for
port
in
params
.
objects
(
"serials"
):
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
module
=
params
.
get
(
"modprobe_module"
)
if
module
:
error_context
.
context
(
"Load module %s"
%
module
,
logging
.
info
)
session
.
cmd
(
"modprobe %s"
%
module
)
for
port
in
params
.
objects
(
"serials"
)
:
port_params
=
params
.
object_params
(
port
)
if
not
port_params
[
'serial_type'
].
startswith
(
'virt'
):
continue
virtio_port
=
vm
.
devices
.
get
(
port
)
if
not
virtio_port
:
test
.
fail
(
"Virtio Port '%s' not found"
%
port
)
chardev_qid
=
virtio_port
.
get_param
(
"chardev"
)
try
:
port_chardev
=
vm
.
devices
.
get_by_qid
(
chardev_qid
)[
0
]
except
IndexError
:
test
.
error
(
"Failed to get device %s"
%
chardev_qid
)
if
module
:
port_params
=
params
.
object_params
(
port
)
if
not
port_params
[
'serial_type'
].
startswith
(
'virt'
)
:
continue
virtio_port
=
vm
.
devices
.
get
(
port
)
if
not
virtio_port
:
test
.
fail
(
"Virtio Port '%s' not found"
%
port
)
chardev_qid
=
virtio_port
.
get_param
(
"chardev"
)
try
:
port_chardev
=
vm
.
devices
.
get_by_qid
(
chardev_qid
)[
0
]
except
IndexError
:
test
.
error
(
"Failed to get device %s"
%
chardev_qid
)
if
port_params
[
'serial_type'
]
==
'virtserialport'
:
params
[
'file_transfer_serial_port'
]
=
port
run_bg_test
(
test
,
params
,
vm
)
for
repeat
in
range
(
params
.
get_numeric
(
"repeat_times"
,
1
))
:
repeat
+=
1
if
module
and
check_module
:
error_context
.
context
(
"Unload module %s"
%
module
,
logging
.
info
)
session
.
cmd
(
"modprobe -r %s"
%
module
)
time
.
sleep
(
1
)
error_context
.
context
(
"Unplug virtio port '%s' in %d tune(s)"
%
(
port
,
repeat
),
logging
.
info
)
vm
.
devices
.
simple_unplug
(
virtio_port
,
vm
.
monitor
)
...
...
@@ -68,20 +80,21 @@ def run(test, params, env):
time
.
sleep
(
0.5
)
vm
.
devices
.
simple_hotplug
(
port_chardev
,
vm
.
monitor
)
vm
.
devices
.
simple_hotplug
(
virtio_port
,
vm
.
monitor
)
if
module
:
if
module
and
check_module
:
error_context
.
context
(
"Load module %s"
%
module
,
logging
.
info
)
session
.
cmd
(
"modprobe %s"
%
module
)
time
.
sleep
(
1
)
session
.
close
()
host_script
=
params
[
'host_script'
]
check_pid_cmd
=
'pgrep -f %s'
%
host_script
host_proc_pid
=
process
.
getoutput
(
check_pid_cmd
,
shell
=
True
)
if
host_proc_pid
:
logging
.
info
(
"Kill the first serial process on host"
)
result
=
process
.
system
(
'kill -9 %s'
%
host_proc_pid
,
shell
=
True
)
if
result
!=
0
:
logging
.
error
(
"Failed to kill the first serial process on host!"
)
if
transfer_data
(
params
,
vm
)
is
not
True
:
test
.
fail
(
"Serial data transfter test failed."
)
host_script
=
params
[
'host_script'
]
check_pid_cmd
=
'pgrep -f %s'
host_proc_pid
=
process
.
getoutput
(
check_pid_cmd
%
host_script
,
shell
=
True
)
if
host_proc_pid
:
logging
.
info
(
"Kill the first serial process on host"
)
result
=
process
.
system
(
'kill -9 %s'
%
host_proc_pid
,
shell
=
True
)
if
result
!=
0
:
logging
.
error
(
"Failed to kill the first serial process on host!"
)
if
transfer_data
(
params
,
vm
)
is
not
True
:
test
.
fail
(
"Serial data transfter test failed."
)
vm
.
reboot
()
vm
.
verify_kernel_crash
()
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
...
...
qemu/tests/virtio_serial_file_transfer.py
浏览文件 @
d3116c66
...
...
@@ -171,44 +171,46 @@ def transfer_data(params, vm, host_file_name=None, guest_file_name=None,
"""
session
=
vm
.
wait_for_login
()
os_type
=
params
[
"os_type"
]
guest_path
=
params
.
get
(
"guest_script_folder"
,
"C:
\\
"
)
guest_scripts
=
params
.
get
(
"guest_scripts"
,
"VirtIoChannel_guest_send_receive.py"
)
copy_scripts
(
guest_scripts
,
guest_path
,
vm
)
port_name
=
params
[
"file_transfer_serial_port"
]
port_type
,
port_path
=
get_virtio_port_property
(
vm
,
port_name
)
file_size
=
int
(
params
.
get
(
"filesize"
,
10
))
transfer_timeout
=
int
(
params
.
get
(
"transfer_timeout"
,
720
))
host_dir
=
data_dir
.
get_tmp_dir
()
guest_dir
=
params
.
get
(
"tmp_dir"
,
'/var/tmp/'
)
host_file_size
,
guest_file_size
,
host_action
,
guest_action
\
=
get_command_options
(
sender
,
file_size
)
if
not
host_file_name
:
host_file_name
=
generate_data_file
(
host_dir
,
host_file_size
)
if
not
guest_file_name
:
guest_file_name
=
generate_data_file
(
guest_dir
,
guest_file_size
,
session
)
host_script
=
params
.
get
(
"host_script"
,
"serial_host_send_receive.py"
)
host_script
=
os
.
path
.
join
(
data_dir
.
get_root_dir
(),
"shared"
,
"deps"
,
"serial"
,
host_script
)
python_bin
=
'`command -v python python3 | head -1`'
host_cmd
=
(
"%s %s -t %s -s %s -f %s -a %s"
%
(
python_bin
,
host_script
,
port_type
,
port_path
,
host_file_name
,
host_action
))
guest_script
=
os
.
path
.
join
(
guest_path
,
params
[
'guest_script'
])
python_bin
=
params
.
get
(
'python_bin'
,
python_bin
)
guest_cmd
=
(
"%s %s -d %s -f %s -a %s"
%
(
python_bin
,
guest_script
,
port_name
,
guest_file_name
,
guest_action
))
result
=
_transfer_data
(
session
,
host_cmd
,
guest_cmd
,
transfer_timeout
,
sender
)
if
os_type
==
"windows"
:
guest_file_name
=
guest_file_name
.
replace
(
"/"
,
"
\\
"
)
if
clean_file
:
clean_cmd
=
params
[
'clean_cmd'
]
os
.
remove
(
host_file_name
)
session
.
cmd
(
'%s %s'
%
(
clean_cmd
,
guest_file_name
))
session
.
close
()
try
:
guest_path
=
params
.
get
(
"guest_script_folder"
,
"C:
\\
"
)
guest_scripts
=
params
.
get
(
"guest_scripts"
,
"VirtIoChannel_guest_send_receive.py"
)
copy_scripts
(
guest_scripts
,
guest_path
,
vm
)
port_name
=
params
[
"file_transfer_serial_port"
]
port_type
,
port_path
=
get_virtio_port_property
(
vm
,
port_name
)
file_size
=
int
(
params
.
get
(
"filesize"
,
10
))
transfer_timeout
=
int
(
params
.
get
(
"transfer_timeout"
,
720
))
host_dir
=
data_dir
.
get_tmp_dir
()
guest_dir
=
params
.
get
(
"tmp_dir"
,
'/var/tmp/'
)
host_file_size
,
guest_file_size
,
host_action
,
guest_action
\
=
get_command_options
(
sender
,
file_size
)
if
not
host_file_name
:
host_file_name
=
generate_data_file
(
host_dir
,
host_file_size
)
if
not
guest_file_name
:
guest_file_name
=
generate_data_file
(
guest_dir
,
guest_file_size
,
session
)
host_script
=
params
.
get
(
"host_script"
,
"serial_host_send_receive.py"
)
host_script
=
os
.
path
.
join
(
data_dir
.
get_root_dir
(),
"shared"
,
"deps"
,
"serial"
,
host_script
)
python_bin
=
'`command -v python python3 | head -1`'
host_cmd
=
(
"%s %s -t %s -s %s -f %s -a %s"
%
(
python_bin
,
host_script
,
port_type
,
port_path
,
host_file_name
,
host_action
))
guest_script
=
os
.
path
.
join
(
guest_path
,
params
[
'guest_script'
])
python_bin
=
params
.
get
(
'python_bin'
,
python_bin
)
guest_cmd
=
(
"%s %s -d %s -f %s -a %s"
%
(
python_bin
,
guest_script
,
port_name
,
guest_file_name
,
guest_action
))
result
=
_transfer_data
(
session
,
host_cmd
,
guest_cmd
,
transfer_timeout
,
sender
)
finally
:
if
os_type
==
"windows"
:
guest_file_name
=
guest_file_name
.
replace
(
"/"
,
"
\\
"
)
if
clean_file
:
clean_cmd
=
params
[
'clean_cmd'
]
os
.
remove
(
host_file_name
)
session
.
cmd
(
'%s %s'
%
(
clean_cmd
,
guest_file_name
))
session
.
close
()
return
result
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录