Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
5762af7e
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,发现更多精彩内容 >>
未验证
提交
5762af7e
编写于
1月 18, 2018
作者:
X
Xu Han
提交者:
GitHub
1月 18, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1205 from kimi1978wy/1528169
mac_change: Get correct mac when boot with multi-queue
上级
c2caf795
b042c823
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
28 deletion
+35
-28
generic/tests/mac_change.py
generic/tests/mac_change.py
+35
-28
未找到文件。
generic/tests/mac_change.py
浏览文件 @
5762af7e
import
re
import
logging
from
autotest.client.shared
import
error
from
virttest
import
error_context
from
virttest
import
utils_misc
from
virttest
import
utils_net
from
virttest
import
utils_test
def
check_guest_mac
(
mac
,
vm
,
device_id
=
None
):
error
.
context
(
"Check mac address via monitor"
,
logging
.
info
)
network_info
=
vm
.
monitor
.
info
(
"network"
)
@
error_context
.
context_aware
def
check_guest_mac
(
test
,
mac
,
vm
,
device_id
=
None
):
"""
check mac address of guest via qmp.
:param test: test object
:param mac: mac address of guest
:param vm: target vm
:param device_id: id of network pci device
"""
error_context
.
context
(
"Check mac address via monitor"
,
logging
.
info
)
network_info
=
str
(
vm
.
monitor
.
info
(
"network"
))
if
not
device_id
:
device_id
=
vm
.
virtnet
[
0
].
device_id
if
device_id
not
in
str
(
network_info
):
err
=
"Could not find device '%s' from query-network monitor command."
err
+=
"query-network command output: %s"
%
str
(
network_info
)
raise
error
.
TestFail
(
err
)
for
info
in
str
(
network_info
).
splitlines
():
if
re
.
match
(
device_id
,
info
.
strip
(),
re
.
I
)
and
mac
not
in
info
:
err
=
"Cold not get correct mac from qmp command!"
err
+=
"query-network command output: %s"
%
str
(
network_info
)
raise
error
.
TestFail
(
err
)
if
device_id
not
in
network_info
:
err
=
"Could not find device '%s' from query-network monitor command.
\n
"
err
+=
"query-network command output: %s"
%
network_info
test
.
error
(
err
)
if
not
re
.
search
((
"%s.*%s"
%
(
device_id
,
mac
)),
network_info
,
re
.
M
|
re
.
I
):
err
=
"Could not get correct mac from qmp command!
\n
"
err
+=
"query-network command output: %s"
%
network_info
test
.
fail
(
err
)
@
error
.
context_aware
@
error
_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Change MAC address of guest.
...
...
@@ -60,7 +67,7 @@ def run(test, params, env):
os_variant
=
params
.
get
(
"os_variant"
)
change_cmd_pattern
=
params
.
get
(
"change_cmd"
)
logging
.
info
(
"The initial MAC address is %s"
,
old_mac
)
check_guest_mac
(
old_mac
,
vm
)
check_guest_mac
(
test
,
old_mac
,
vm
)
if
os_type
==
"linux"
:
interface
=
utils_net
.
get_linux_ifname
(
session_serial
,
old_mac
)
if
params
.
get
(
"shutdown_int"
,
"yes"
)
==
"yes"
:
...
...
@@ -87,7 +94,7 @@ def run(test, params, env):
session
.
cmd
(
copy_cmd
)
# Start change MAC address
error
.
context
(
"Changing MAC address to %s"
%
new_mac
,
logging
.
info
)
error
_context
.
context
(
"Changing MAC address to %s"
%
new_mac
,
logging
.
info
)
if
os_type
==
"linux"
:
change_cmd
=
change_cmd_pattern
%
(
interface
,
new_mac
)
else
:
...
...
@@ -97,8 +104,8 @@ def run(test, params, env):
session_serial
.
cmd_output_safe
(
change_cmd
)
# Verify whether MAC address was changed to the new one
error
.
context
(
"Verify the new mac address, and restart the network"
,
logging
.
info
)
error
_context
.
context
(
"Verify the new mac address, and restart the network"
,
logging
.
info
)
if
os_type
==
"linux"
:
if
params
.
get
(
"shutdown_int"
,
"yes"
)
==
"yes"
:
int_activate_cmd
=
params
.
get
(
"int_activate_cmd"
,
...
...
@@ -119,7 +126,7 @@ def run(test, params, env):
o
=
session_serial
.
cmd_output_safe
(
"ipconfig /all"
)
if
not
re
.
findall
(
"%s"
%
"-"
.
join
(
new_mac
.
split
(
":"
)),
o
,
re
.
I
):
raise
error
.
TestF
ail
(
"Guest mac change failed"
)
test
.
f
ail
(
"Guest mac change failed"
)
logging
.
info
(
"Guest mac have been modified successfully"
)
if
params
.
get
(
"nettype"
)
!=
"macvtap"
:
...
...
@@ -132,13 +139,13 @@ def run(test, params, env):
session
.
close
()
# Re-log into guest and check if session is responsive
error
.
context
(
"Re-log into the guest"
,
logging
.
info
)
error
_context
.
context
(
"Re-log into the guest"
)
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
if
not
session
.
is_responsive
():
raise
error
.
TestFail
(
"The new session is not responsive."
)
test
.
error
(
"The new session is not responsive."
)
if
params
.
get
(
"reboot_vm_after_mac_changed"
)
==
"yes"
:
error
.
context
(
"Reboot guest and check the the mac address by "
"monitor"
,
logging
.
info
)
error
_context
.
context
(
"Reboot guest and check the the mac address by "
"monitor"
,
logging
.
info
)
mac_check
=
new_mac
if
os_type
==
"linux"
:
nic
=
vm
.
virtnet
[
0
]
...
...
@@ -147,13 +154,13 @@ def run(test, params, env):
mac_check
=
old_mac
session_serial
=
vm
.
reboot
(
session_serial
,
serial
=
True
)
check_guest_mac
(
mac_check
,
vm
)
check_guest_mac
(
test
,
mac_check
,
vm
)
if
params
.
get
(
"file_transfer"
,
"no"
)
==
"yes"
:
error
.
context
(
"File transfer between host and guest."
,
logging
.
info
)
error
_context
.
context
(
"File transfer between host and guest."
,
logging
.
info
)
utils_test
.
run_file_transfer
(
test
,
params
,
env
)
else
:
check_guest_mac
(
new_mac
,
vm
)
check_guest_mac
(
test
,
new_mac
,
vm
)
finally
:
if
os_type
==
"windows"
:
clean_cmd_pattern
=
params
.
get
(
"clean_cmd"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录