Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
0da3d743
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,发现更多精彩内容 >>
未验证
提交
0da3d743
编写于
12月 04, 2017
作者:
B
Balamuruhan S
提交者:
GitHub
12月 04, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #991 from santwana/sriov
Modify SRIOV sanity test to include VF static IP configuration scenario
上级
86404503
c8e8812d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
116 addition
and
64 deletion
+116
-64
qemu/tests/cfg/sr_iov_sanity.cfg
qemu/tests/cfg/sr_iov_sanity.cfg
+5
-0
qemu/tests/sr_iov_sanity.py
qemu/tests/sr_iov_sanity.py
+111
-64
未找到文件。
qemu/tests/cfg/sr_iov_sanity.cfg
浏览文件 @
0da3d743
...
...
@@ -14,3 +14,8 @@
no Host_RHEL.m5, Host_RHEL.m6
- pci-assign:
device_driver = pci-assign
variants:
- with_hugepages:
only hugepages
- without_hugepages:
only smallpages
qemu/tests/sr_iov_sanity.py
浏览文件 @
0da3d743
import
os
import
re
import
time
import
random
import
logging
import
netaddr
from
autotest.client.shared
import
error
from
autotest.client.shared
import
utils
from
avocado.utils
import
process
from
virttest
import
utils_test
from
virttest
import
test_setup
from
virttest
import
utils_net
from
virttest
import
error_context
from
virttest
import
utils_misc
from
virttest
import
env_process
def
check_network_interface_ip
(
interface
,
ipv6
=
"no"
):
check_cmd
=
"ifconfig %s"
%
interface
status
=
util
s
.
system_output
(
check_cmd
)
output
=
proces
s
.
system_output
(
check_cmd
)
ip_re
=
"inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
if
ipv6
==
"yes"
:
ip_re
=
"inet6 (\S+)"
try
:
_ip
=
re
.
findall
(
ip_re
,
status
)[
0
]
_ip
=
re
.
findall
(
ip_re
,
output
)[
0
]
except
IndexError
:
_ip
=
None
return
_ip
def
ifup_down_interface
(
interface
,
action
=
"up"
):
def
ifup_down_interface
(
test
,
interface
,
action
=
"up"
):
check_cmd
=
"ifconfig %s"
%
interface
status
=
util
s
.
system_output
(
check_cmd
)
output
=
proces
s
.
system_output
(
check_cmd
)
if
action
==
"up"
:
if
not
check_network_interface_ip
(
interface
):
if
"UP"
in
status
.
splitlines
()[
0
]:
utils
.
system
(
"ifdown %s"
%
interface
,
timeout
=
120
,
ignore_status
=
True
)
utils
.
system
(
"ifup %s"
%
interface
,
timeout
=
120
,
ignore_status
=
True
)
if
"UP"
in
output
.
splitlines
()[
0
]:
process
.
system
(
"ifdown %s"
%
interface
,
timeout
=
120
,
ignore_status
=
True
)
process
.
system
(
"ifup %s"
%
interface
,
timeout
=
120
,
ignore_status
=
True
)
elif
action
==
"down"
:
if
"UP"
in
status
.
splitlines
()[
0
]:
util
s
.
system
(
"ifdown %s"
%
interface
,
timeout
=
120
,
ignore_status
=
True
)
if
"UP"
in
output
.
splitlines
()[
0
]:
proces
s
.
system
(
"ifdown %s"
%
interface
,
timeout
=
120
,
ignore_status
=
True
)
else
:
msg
=
"Unsupport action '%s' on network interface."
%
action
raise
error
.
TestE
rror
(
msg
)
test
.
e
rror
(
msg
)
@
error
.
context_aware
@
error
_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
SR-IOV devices sanity test:
...
...
@@ -63,15 +64,21 @@ def run(test, params, env):
device_driver
=
params
.
get
(
"device_driver"
,
"pci-assign"
)
repeat_time
=
int
(
params
.
get
(
"bind_repeat_time"
,
1
))
configure_on_host
=
int
(
params
.
get
(
"configure_on_host"
,
0
))
static_ip
=
int
(
params
.
get
(
"static_ip"
,
1
))
serial_login
=
params
.
get
(
"serial_login"
,
"no"
)
pci_assignable
=
test_setup
.
PciAssignable
(
driver
=
params
.
get
(
"driver"
),
driver_option
=
params
.
get
(
"driver_option"
),
host_set_flag
=
1
,
host_set_flag
=
params
.
get
(
"host_set_flag"
,
1
)
,
kvm_params
=
params
.
get
(
"kvm_default"
),
vf_filter_re
=
params
.
get
(
"vf_filter_re"
),
pf_filter_re
=
params
.
get
(
"pf_filter_re"
),
device_driver
=
device_driver
,
pa_type
=
params
.
get
(
"pci_assignable"
))
pa_type
=
params
.
get
(
"pci_assignable"
),
static_ip
=
static_ip
,
net_mask
=
params
.
get
(
"net_mask"
),
start_addr_PF
=
params
.
get
(
"start_addr_PF"
))
devices
=
[]
device_type
=
params
.
get
(
"device_type"
,
"vf"
)
...
...
@@ -79,13 +86,13 @@ def run(test, params, env):
device_num
=
pci_assignable
.
get_vfs_count
()
if
device_num
==
0
:
msg
=
" No VF device found even after running SR-IOV setup"
raise
error
.
TestFai
l
(
msg
)
test
.
cance
l
(
msg
)
elif
device_type
==
"pf"
:
device_num
=
len
(
pci_assignable
.
get_pf_vf_info
())
else
:
msg
=
"Unsupport device type '%s'."
%
device_type
msg
+=
" Please set device_type to 'vf' or 'pf'."
raise
error
.
TestE
rror
(
msg
)
test
.
e
rror
(
msg
)
for
i
in
xrange
(
device_num
):
device
=
{}
...
...
@@ -105,35 +112,39 @@ def run(test, params, env):
ethname_dict
=
[]
ips
=
{}
msg
=
"Configure all VFs in host."
error
.
context
(
msg
,
logging
.
info
)
for
pci_id
in
vf_pci_id
:
cmd
=
"ls /sys/bus/pci/devices/%s/net/"
%
pci_id
ethname
=
utils
.
system_output
(
cmd
).
strip
()
ethname_dict
.
append
(
ethname
)
network_script
=
os
.
path
.
join
(
"/etc/sysconfig/network-scripts"
,
"ifcfg-%s"
%
ethname
)
if
not
os
.
path
.
exists
(
network_script
):
error
.
context
(
"Create %s file."
%
network_script
,
logging
.
info
)
txt
=
"DEVICE=%s
\n
ONBOOT=yes
\n
BOOTPROTO=dhcp
\n
"
%
ethname
file
(
network_script
,
"w"
).
write
(
txt
)
msg
=
"Check whether VFs could get ip in host."
error
.
context
(
msg
,
logging
.
info
)
for
ethname
in
ethname_dict
:
ifup_down_interface
(
ethname
)
_ip
=
check_network_interface_ip
(
ethname
)
if
not
_ip
:
msg
=
"Interface '%s' could not get IP."
%
ethname
logging
.
error
(
msg
)
else
:
ips
[
ethname
]
=
_ip
logging
.
info
(
"Interface '%s' get IP '%s'"
,
ethname
,
_ip
)
# Not all test environments would have a dhcp server to serve IP for
# all mac addresses. So configure_on_host param has been
# introduced to choose whether configure VFs on host or not
if
configure_on_host
:
msg
=
"Configure all VFs in host."
error_context
.
context
(
msg
,
logging
.
info
)
for
pci_id
in
vf_pci_id
:
ethname
=
utils_misc
.
get_interface_from_pci_id
(
pci_id
)
mac
=
utils_net
.
generate_mac_address_simple
()
ethname_dict
.
append
(
ethname
)
# TODO:cleanup of the network scripts
try
:
utils_net
.
create_network_script
(
ethname
,
mac
,
"dhcp"
,
"255.255.255.0"
,
on_boot
=
"yes"
)
except
Exception
,
info
:
test
.
error
(
"Network script creation failed - %s"
%
info
)
msg
=
"Check whether VFs could get ip in host."
error_context
.
context
(
msg
,
logging
.
info
)
for
ethname
in
ethname_dict
:
utils_net
.
bring_down_ifname
(
ethname
)
_ip
=
check_network_interface_ip
(
ethname
)
if
not
_ip
:
msg
=
"Interface '%s' could not get IP."
%
ethname
logging
.
error
(
msg
)
else
:
ips
[
ethname
]
=
_ip
logging
.
info
(
"Interface '%s' get IP '%s'"
,
ethname
,
_ip
)
for
i
in
xrange
(
repeat_time
):
msg
=
"Bind/unbind device from host. Repeat %s/%s"
%
(
i
+
1
,
repeat_time
)
error
.
context
(
msg
,
logging
.
info
)
error
_context
.
context
(
msg
,
logging
.
info
)
bind_device_num
=
random
.
randint
(
1
,
device_num
)
pci_assignable
.
request_devs
(
devices
[:
bind_device_num
])
logging
.
info
(
"Sleep 3s before releasing vf to host."
)
...
...
@@ -149,28 +160,64 @@ def run(test, params, env):
msg
=
"lspci cannot report the correct PF/VF number."
msg
+=
" Correct number is '%s'"
%
device_num
msg
+=
" lspci report '%s'"
%
post_device_num
raise
error
.
TestF
ail
(
msg
)
dmesg
=
util
s
.
system_output
(
"dmesg"
)
test
.
f
ail
(
msg
)
dmesg
=
proces
s
.
system_output
(
"dmesg"
)
file_name
=
"host_dmesg_after_unbind_device.txt"
logging
.
info
(
"Log dmesg after bind/unbing device to '%s'."
,
file_name
)
utils_misc
.
log_line
(
file_name
,
dmesg
)
msg
=
"Check whether VFs still get ip in host."
error
.
context
(
msg
,
logging
.
info
)
for
ethname
in
ips
:
ifup_down_interfac
e
(
ethname
,
action
=
"up"
)
_ip
=
check_network_interface_ip
(
ethname
)
if
not
_ip
:
msg
=
"Interface '%s' could not get IP."
%
ethname
msg
+=
"Before bind/unbind it have IP '%s'."
%
ips
[
ethname
]
logging
.
error
(
msg
)
else
:
logging
.
info
(
"Interface '%s' get IP '%s'"
,
ethname
,
_ip
)
if
configure_on_host
:
msg
=
"Check whether VFs still get ip in host."
error_context
.
context
(
msg
,
logging
.
info
)
for
ethname
in
ips
:
utils_net
.
bring_up_ifnam
e
(
ethname
,
action
=
"up"
)
_ip
=
utils_net
.
get_ip_address_by_interface
(
ethname
,
ip_ver
=
"ipv4"
)
if
not
_ip
:
msg
=
"Interface '%s' could not get IP."
%
ethname
msg
+=
"Before bind/unbind it have IP '%s'."
%
ips
[
ethname
]
logging
.
error
(
msg
)
else
:
logging
.
info
(
"Interface '%s' get IP '%s'"
,
ethname
,
_ip
)
msg
=
"Try to boot up guest(s) with VF(s)."
error
.
context
(
msg
,
logging
.
info
)
error_context
.
context
(
msg
,
logging
.
info
)
regain_ip_cmd
=
params
.
get
(
"regain_ip_cmd"
,
None
)
timeout
=
int
(
params
.
get
(
"login_timeout"
,
30
))
for
vm_name
in
params
[
"vms"
].
split
(
" "
):
params
[
"start_vm"
]
=
"yes"
env_process
.
preprocess_vm
(
test
,
params
,
env
,
vm_name
)
vm
=
env
.
get_vm
(
vm_name
)
vm
.
verify_alive
()
vm
.
wait_for_login
(
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
)))
# User can opt for dhcp IP or a static IP configuration for probed
# interfaces inside guest. Added option for static IP configuration
# below
if
static_ip
:
if
'IP_addr_VF'
not
in
locals
():
IP_addr_VF
=
netaddr
.
IPAddress
(
params
.
get
(
"start_addr_VF"
))
net_mask
=
params
.
get
(
"net_mask"
)
if
not
IP_addr_VF
:
test
.
fail
(
"No IP address found, please"
"populate starting IP address in "
"configuration file"
)
session
=
vm
.
wait_for_serial_login
(
timeout
=
int
(
params
.
get
(
"login_timeout"
,
720
)))
rc
,
output
=
session
.
cmd_status_output
(
"ip li| grep -i 'BROADCAST'|awk '{print $2}'| sed 's/://'"
)
if
not
rc
:
iface_probed
=
output
.
splitlines
()
logging
.
info
(
"probed VF Interface(s) in guest: %s"
,
iface_probed
)
for
iface
in
iface_probed
:
mac
=
utils_net
.
get_linux_mac
(
session
,
iface
)
utils_net
.
set_guest_ip_addr
(
session
,
mac
,
IP_addr_VF
)
rc
,
output
=
utils_test
.
ping
(
str
(
IP_addr_VF
),
30
,
timeout
=
60
)
if
rc
!=
0
:
test
.
fail
(
"New nic failed ping test"
"with output:
\n
%s"
%
output
)
IP_addr_VF
=
IP_addr_VF
+
1
else
:
test
.
fail
(
"Fail to locate probed interfaces"
"for VFs, please check on respective"
"drivers in guest image"
)
else
:
# User has opted for DHCP IP inside guest
vm
.
verify_alive
()
vm
.
wait_for_login
(
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
)))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录