Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
86dc7f41
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,发现更多精彩内容 >>
未验证
提交
86dc7f41
编写于
11月 10, 2017
作者:
B
Balamuruhan S
提交者:
GitHub
11月 10, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1078 from balamuruhans/sriov_HP
sr_iov.cfg: Added sriov hotplug testcases
上级
3b2ba8f1
30d1e9e9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
108 addition
and
40 deletion
+108
-40
qemu/tests/cfg/sr_iov.cfg
qemu/tests/cfg/sr_iov.cfg
+19
-15
qemu/tests/sr_iov_hotplug.py
qemu/tests/sr_iov_hotplug.py
+89
-25
未找到文件。
qemu/tests/cfg/sr_iov.cfg
浏览文件 @
86dc7f41
...
...
@@ -29,35 +29,39 @@
nics = 'nic1 nic2'
pci_assignable = vf
image_snapshot = yes
-
vf
_hotplug:
-
sriov
_hotplug:
type = sr_iov_hotplug
nics = nic1
pci_assignable_nic1 = no
reference_cmd = lspci
find_pci_cmd = 'lspci | tail -n1'
pci_test_cmd = 'echo %s; nslookup www.redhat.com'
pci_num = 2
repeat_times = 2
wait_secs_for_hook_up = 3
assign_static_ip = "yes"
variants:
- vf_hotplug:
repeat_times = 2
- vf_hotplug_500:
repeat_times = 500
test_timeout = 10000
variants:
- with_hugepage:
only hugepages
- without_hugepage:
only smallpages
variants:
- @normal:
- with_reboot:
vm_reboot = "yes"
- with_stop_resume:
vm_stop = "yes"
vm_resume = "yes"
- vf_hot_unplug:
type = pci_hotunplug
pci_assignable = vf
reference_cmd = lspci
nics = "nic1 nic2 nic3"
unplug_pci_num = 2
- vf_hotplug_500:
type = sr_iov_hotplug
nics = nic1
pci_assignable_nic1 = no
reference_cmd = lspci
find_pci_cmd = 'lspci | tail -n1'
pci_test_cmd = 'echo %s; nslookup www.redhat.com'
wait_secs_for_hook_up = 3
pci_num = 2
repeat_times = 500
test_timeout = 10000
assign_static_ip = "yes"
- vf_guest_suspend:
no Host_RHEL.m6
variants:
...
...
qemu/tests/sr_iov_hotplug.py
浏览文件 @
86dc7f41
...
...
@@ -9,6 +9,8 @@ from virttest import utils_net
from
virttest
import
test_setup
from
virttest
import
error_context
iface_scripts
=
[]
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
...
...
@@ -34,6 +36,7 @@ def run(test, params, env):
def
check_interface
(
iface
,
nic_filter
):
cmd
=
"ifconfig %s"
%
str
(
iface
)
session
=
vm
.
wait_for_serial_login
(
timeout
=
timeout
)
status
,
output
=
session
.
cmd_status_output
(
cmd
)
if
status
:
test
.
error
(
"Guest command '%s' fail with output: %s."
%
(
cmd
,
output
))
...
...
@@ -113,24 +116,51 @@ def run(test, params, env):
". Output: %r"
%
(
pci_add_cmd
,
add_output
))
return
after_add
def
clean_network_scripts
():
logging
.
debug
(
"Clean up network scripts in guest"
)
session
=
vm
.
wait_for_serial_login
(
timeout
=
timeout
)
if
"ubuntu"
in
vm
.
get_distro
().
lower
():
iface_script
=
"/etc/network/interfaces"
cmd
=
"cat %s.BACKUP"
%
iface_script
if
not
session
.
cmd_status
(
cmd
):
cmd
=
"mv %s.BACKUP %s"
%
(
iface_script
,
iface_script
)
status
,
output
=
session
.
cmd_status_output
(
cmd
)
if
status
:
test
.
error
(
"Failed to cleanup network script in guest: "
"%s"
%
output
)
else
:
global
iface_scripts
for
iface_script
in
iface_scripts
:
cmd
=
"rm -f %s"
%
iface_script
status
,
output
=
session
.
cmd_status_output
(
cmd
)
if
status
:
test
.
error
(
"Failed to delete iface_script"
)
iface_scripts
.
remove
(
iface_script
)
# Hot add a pci device
def
add_device
(
pci_num
):
global
iface_scripts
reference_cmd
=
params
[
"reference_cmd"
]
find_pci_cmd
=
params
[
"find_pci_cmd"
]
info_pci_ref
=
vm
.
monitor
.
info
(
"pci"
)
session
=
vm
.
wait_for_serial_login
(
timeout
=
timeout
)
reference
=
session
.
cmd_output
(
reference_cmd
)
active_nics
=
get_active_network_device
(
session
,
nic_filter
)
logging
.
debug
(
"Active nics before hotplug - %s"
,
active_nics
)
# Stop the VM monitor and try hot adding SRIOV dev
if
params
.
get
(
"vm_stop"
,
"no"
)
==
"yes"
:
logging
.
debug
(
"stop the monitor of the VM before hotplug"
)
vm
.
pause
()
try
:
# get function for adding device.
add_fuction
=
local_functions
[
"%s_iov"
%
cmd_type
]
add_fu
n
ction
=
local_functions
[
"%s_iov"
%
cmd_type
]
except
Exception
:
test
.
error
(
"No function for adding sr-iov dev with '%s'"
%
cmd_type
)
after_add
=
None
if
add_fuction
:
if
add_fu
n
ction
:
# Do add pci device.
after_add
=
add_fuction
(
pci_num
)
after_add
=
add_fu
n
ction
(
pci_num
)
try
:
# Define a helper function to compare the output
...
...
@@ -147,12 +177,23 @@ def run(test, params, env):
# Define a helper function to catch PCI device string
def
_find_pci
():
output
=
session
.
cmd_output
(
find_pci_cmd
)
if
re
.
search
(
match_string
,
output
,
re
.
IGNORECASE
):
output
=
session
.
cmd_output
(
"lspci -nn"
)
if
re
.
search
(
vf_filter
,
output
,
re
.
IGNORECASE
):
return
True
else
:
return
False
# Resume the VM
if
params
.
get
(
"vm_resume"
,
"no"
)
==
"yes"
:
logging
.
debug
(
"resuming the VM after hotplug"
)
vm
.
resume
()
# Reboot the VM
if
params
.
get
(
"vm_reboot"
,
"no"
)
==
"yes"
:
logging
.
debug
(
"Rebooting the VM after hotplug"
)
vm
.
reboot
()
session
=
vm
.
wait_for_serial_login
(
timeout
=
timeout
)
error_context
.
context
(
"Start checking new added device"
)
# Compare the output of 'info pci'
if
after_add
==
info_pci_ref
:
...
...
@@ -166,36 +207,40 @@ def run(test, params, env):
if
not
utils_misc
.
wait_for
(
_find_pci
,
test_timeout
,
3
,
3
):
test
.
fail
(
"New add device not found in guest. "
"Command was:
%s"
%
find_pci_cmd
)
"Command was:
lspci -nn"
)
# Assign static IP to the hotplugged interface
if
params
.
get
(
"assign_static_ip"
,
"no"
)
==
"yes"
:
cmd
=
[]
cmd
=
"service networking restart"
static_ip
=
ip_gen
.
next
()
net_mask
=
params
.
get
(
"static_net_mask"
,
"255.255.255.0"
)
broadcast
=
params
.
get
(
"static_broadcast"
,
"10.10.10.255"
)
pci_id
=
utils_misc
.
get_pci_id_using_filter
(
match_string
,
pci_id
=
utils_misc
.
get_pci_id_using_filter
(
vf_filter
,
session
)
logging
.
debug
(
"PCIs associated with %s - %s"
,
match_string
,
logging
.
debug
(
"PCIs associated with %s - %s"
,
vf_filter
,
', '
.
join
(
map
(
str
,
pci_id
)))
for
each_pci
in
pci_id
:
iface_name
=
utils_misc
.
get_interface_from_pci_id
(
each_pci
,
session
)
logging
.
debug
(
"Interface associated with PCI %s - %s"
,
each_pci
,
iface_name
)
mac
=
session
.
cmd_output
(
"ethtool -P %s"
%
iface_name
)
mac
=
mac
.
split
(
"Permanent address:"
)[
-
1
].
strip
()
logging
.
debug
(
"mac address of %s: %s"
,
iface_name
,
mac
)
# backup the network script for other distros
if
"ubuntu"
not
in
vm
.
get_distro
().
lower
():
cmd
=
"service network restart"
iface_scripts
.
append
(
utils_net
.
get_network_cfg_file
(
iface_name
))
if
not
check_interface
(
str
(
iface_name
),
nic_filter
):
cmd
.
append
(
"ifconfig %s %s"
%
(
iface_name
,
static_ip
))
cmd
.
append
(
"ifconfig %s netmask %s"
%
(
iface_name
,
net_mask
))
cmd
.
append
(
"ifconfig %s broadcast %s"
%
(
iface_name
,
broadcast
))
cmd
.
append
(
"ifconfig %s up"
%
iface_name
)
for
each_cmd
in
cmd
:
status
,
output
=
session
.
cmd_status_output
(
each_cmd
)
if
status
:
test
.
error
(
"Failed to set static ip in guest: "
"%s"
%
output
)
utils_net
.
create_network_script
(
iface_name
,
mac
,
boot_proto
=
"static"
,
net_mask
=
net_mask
,
vm
=
vm
,
ip_addr
=
static_ip
)
status
,
output
=
session
.
cmd_status_output
(
cmd
)
if
status
:
test
.
error
(
"Failed to set static ip in guest: "
"%s"
%
output
)
# Test the newly added device
if
not
utils_misc
.
wait_for
(
_check_ip
,
120
,
3
,
3
):
ifconfig
=
session
.
cmd_output
(
"ifconfig -a"
)
...
...
@@ -242,8 +287,7 @@ def run(test, params, env):
pci_num_range
=
int
(
params
.
get
(
"pci_num"
,
1
))
rp_times
=
int
(
params
.
get
(
"repeat_times"
,
1
))
pci_model
=
params
.
get
(
"pci_model"
,
"pci-assign"
)
# Need udpate match_string if you use a card other than 82576
match_string
=
params
.
get
(
"match_string"
,
"82576"
)
vf_filter
=
params
.
get
(
"vf_filter_re"
)
generate_mac
=
params
.
get
(
"generate_mac"
,
"yes"
)
nic_filter
=
params
[
"nic_interface_filter"
]
devices
=
[]
...
...
@@ -263,7 +307,7 @@ def run(test, params, env):
driver_option
=
params
.
get
(
"driver_option"
),
host_set_flag
=
params
.
get
(
"host_setup_flag"
),
kvm_params
=
params
.
get
(
"kvm_default"
),
vf_filter_re
=
params
.
get
(
"vf_filter_re"
)
,
vf_filter_re
=
vf_filter
,
pf_filter_re
=
params
.
get
(
"pf_filter_re"
),
device_driver
=
device_driver
,
pa_type
=
params
.
get
(
"pci_assignable"
))
...
...
@@ -301,6 +345,19 @@ def run(test, params, env):
pci_info
=
[]
if
params
.
get
(
"assign_static_ip"
,
"no"
)
==
"yes"
:
ip_gen
=
utils_net
.
gen_ipv4_addr
(
exclude_ips
=
[])
# backup the network script file if it is ubuntu
if
"ubuntu"
in
vm
.
get_distro
().
lower
():
session
=
vm
.
wait_for_serial_login
(
timeout
=
timeout
)
iface_script
=
"/etc/network/interfaces"
cmd
=
"cat %s"
%
iface_script
if
not
session
.
cmd_status
(
cmd
):
logging
.
debug
(
"Backup network script in guest - %s"
,
iface_script
)
cmd
=
"cp %s %s.BACKUP"
%
(
iface_script
,
iface_script
)
status
,
output
=
session
.
cmd_status_output
(
cmd
)
if
status
:
test
.
error
(
"Failed to backup in guest: %s"
%
output
)
for
pci_num
in
xrange
(
pci_num_range
):
msg
=
"Start hot-adding %sth pci device,"
%
(
pci_num
+
1
)
msg
+=
" repeat %d"
%
(
j
+
1
)
...
...
@@ -320,9 +377,16 @@ def run(test, params, env):
msg
+=
" repeat %d"
%
(
j
+
1
)
error_context
.
context
(
msg
,
logging
.
info
)
pci_del
(
-
(
pci_num
+
1
))
# cleanup network script after hot deleting pci device
clean_network_scripts
()
finally
:
# clean network scripts on error
clean_network_scripts
()
if
params
.
get
(
"enable_set_link"
,
"yes"
)
==
"yes"
:
error_context
.
context
(
"Re-enabling the primary link(s) of guest"
,
logging
.
info
)
for
nic
in
vm
.
virtnet
:
vm
.
set_link
(
nic
.
device_id
,
up
=
True
)
if
session
:
session
.
close
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录