Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
778e68e6
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,发现更多精彩内容 >>
提交
778e68e6
编写于
5月 27, 2016
作者:
X
Xu Tian
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #639 from luckyh/ethtool
generic.tests.ethtool: set offload status atomically
上级
76724bae
9b68ef50
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
38 deletion
+37
-38
generic/tests/ethtool.py
generic/tests/ethtool.py
+37
-38
未找到文件。
generic/tests/ethtool.py
浏览文件 @
778e68e6
...
...
@@ -38,7 +38,7 @@ def run(test, params, env):
find a way to get it installed using yum/apt-get/
whatever
"""
def
ethtool_get
(
session
,
f_type
):
def
ethtool_get
(
session
):
feature_pattern
=
{
'tx'
:
'tx.*checksumming'
,
'rx'
:
'rx.*checksumming'
,
...
...
@@ -48,53 +48,55 @@ def run(test, params, env):
'gro'
:
'generic.*receive.*offload'
,
'lro'
:
'large.*receive.*offload'
,
}
o
=
session
.
cmd
(
"ethtool -k %s"
%
ethname
)
try
:
result
=
re
.
findall
(
"%s: (.*)"
%
feature_pattern
.
get
(
f_type
),
o
)[
0
]
logging
.
debug
(
"(%s) %s: %s"
,
ethname
,
f_type
,
result
)
return
result
except
IndexError
:
logging
.
debug
(
"(%s) %s: failed to get status"
,
ethname
,
f_type
)
status
=
{}
for
f
in
feature_pattern
.
keys
():
try
:
status
[
f
]
=
re
.
findall
(
"%s: (.*)"
%
feature_pattern
.
get
(
f
),
o
)[
0
]
except
IndexError
:
status
[
f
]
=
None
logging
.
debug
(
"(%s) failed to get status '%s'"
,
ethname
,
f
)
logging
.
debug
(
"(%s) offload status: '%s'"
,
ethname
,
str
(
status
))
return
status
def
ethtool_set
(
session
,
f_type
,
status
):
def
ethtool_set
(
session
,
status
):
"""
Set ethernet device offload status
:param f_type: Offload type name
:param status: New status will be changed to
"""
txt
=
"Set
ethernet device offload status.
"
txt
+=
"
(%s) %s: set status %s"
%
(
ethname
,
f_type
,
status
)
txt
=
"Set
offload status for device
"
txt
+=
"
'%s': %s"
%
(
ethname
,
str
(
status
)
)
error
.
context
(
txt
,
logging
.
info
)
if
status
not
in
[
"off"
,
"on"
]:
return
False
if
ethtool_get
(
session
,
f_type
)
==
status
:
return
True
err_msg
=
"(%s) %s: set status %s failed"
%
(
ethname
,
f_type
,
status
)
cmd
=
"ethtool -K %s %s %s"
%
(
ethname
,
f_type
,
status
)
cmd
=
"ethtool -K %s "
%
ethname
cmd
+=
" "
.
join
([
o
+
' '
+
s
for
o
,
s
in
status
.
items
()])
err_msg
=
"Failed to set offload status for device '%s'"
%
ethname
try
:
session
.
cmd_output_safe
(
cmd
)
except
aexpect
.
ShellCmdError
,
e
:
logging
.
error
(
"%s, detail: %s"
,
err_msg
,
e
)
return
False
if
ethtool_get
(
session
,
f_type
)
==
status
:
return
True
curr_status
=
dict
((
k
,
v
)
for
k
,
v
in
ethtool_get
(
session
).
items
()
if
k
in
status
.
keys
())
if
curr_status
!=
status
:
logging
.
error
(
"%s, got: '%s', expect: '%s'"
,
err_msg
,
str
(
curr_status
),
str
(
status
))
return
False
logging
.
error
(
err_msg
)
return
True
def
ethtool_save_params
(
session
):
error
.
context
(
"Saving ethtool configuration"
,
logging
.
info
)
for
i
in
supported_features
:
feature_status
[
i
]
=
ethtool_get
(
session
,
i
)
pretest_status
=
ethtool_get
(
session
)
def
ethtool_restore_params
(
session
):
error
.
context
(
"Restoring ethtool configuration"
,
logging
.
info
)
for
i
in
supported_features
:
ethtool_set
(
session
,
i
,
feature_status
[
i
])
ethtool_set
(
session
,
pretest_status
)
def
compare_md5sum
(
name
):
txt
=
"Comparing md5sum of the files on guest and host"
...
...
@@ -215,7 +217,7 @@ def run(test, params, env):
error
.
context
(
"Check whether ethtool installed in guest."
)
session
.
cmd
(
"ethtool -h"
)
mtu
=
1514
feature
_status
=
{}
pretest
_status
=
{}
filename
=
"/tmp/ethtool.dd"
guest_ip
=
vm
.
get_address
()
error
.
context
(
"Try to get ethernet device name in guest."
)
...
...
@@ -243,17 +245,14 @@ def run(test, params, env):
for
f_type
in
supported_features
:
callback
=
test_matrix
[
f_type
][
0
]
for
i
in
test_matrix
[
f_type
][
2
]:
if
not
ethtool_set
(
session
,
i
,
"off"
):
e_msg
=
"Failed to disable %s"
%
i
logging
.
error
(
e_msg
)
failed_tests
.
append
(
e_msg
)
for
i
in
[
f
for
f
in
test_matrix
[
f_type
][
1
]]
+
[
f_type
]:
if
not
ethtool_set
(
session
,
i
,
"on"
):
e_msg
=
"Failed to enable %s"
%
i
logging
.
error
(
e_msg
)
failed_tests
.
append
(
e_msg
)
offload_stat
=
{
f_type
:
"on"
}
offload_stat
.
update
(
dict
.
fromkeys
(
test_matrix
[
f_type
][
1
],
"on"
))
offload_stat
.
update
(
dict
.
fromkeys
(
test_matrix
[
f_type
][
2
],
"off"
))
if
not
ethtool_set
(
session
,
offload_stat
):
e_msg
=
"Failed to set offload status"
logging
.
error
(
e_msg
)
failed_tests
.
append
(
e_msg
)
txt
=
"Run callback function %s"
%
callback
.
func_name
error
.
context
(
txt
,
logging
.
info
)
...
...
@@ -266,7 +265,7 @@ def run(test, params, env):
logging
.
error
(
e_msg
)
failed_tests
.
append
(
e_msg
)
if
not
ethtool_set
(
session
,
f_type
,
"off"
):
if
not
ethtool_set
(
session
,
{
f_type
:
"off"
}
):
e_msg
=
"Failed to disable %s"
%
f_type
logging
.
error
(
e_msg
)
failed_tests
.
append
(
e_msg
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录