Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
34e578c4
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,发现更多精彩内容 >>
提交
34e578c4
编写于
9月 21, 2017
作者:
X
Xu Han
提交者:
GitHub
9月 21, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1090 from Zhengtong/fix_multi_nics_hotplug
nic_hotplug.py: fix serial console conflict
上级
b3e1f774
bc44b6e6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
19 deletion
+22
-19
qemu/tests/nic_hotplug.py
qemu/tests/nic_hotplug.py
+22
-19
未找到文件。
qemu/tests/nic_hotplug.py
浏览文件 @
34e578c4
...
...
@@ -36,11 +36,13 @@ def run(test, params, env):
:param params: Dictionary with the test parameters.
:param env: Dictionary with test environment.
"""
def
renew_ip_address
(
session
,
mac
,
is_linux_guest
=
True
):
def
renew_ip_address
(
mac
,
is_linux_guest
=
True
):
session
=
vm
.
wait_for_serial_login
(
timeout
=
login_timeout
)
if
not
is_linux_guest
:
utils_net
.
restart_windows_guest_network_by_key
(
session
,
"macaddress"
,
mac
)
session
.
close
()
return
None
ifname
=
utils_net
.
get_linux_ifname
(
session
,
mac
)
p_cfg
=
"/etc/sysconfig/network-scripts/ifcfg-%s"
%
ifname
...
...
@@ -52,9 +54,10 @@ def run(test, params, env):
session
.
cmd_output_safe
(
"dhclient -r"
,
timeout
=
240
)
session
.
cmd_output_safe
(
"dhclient %s"
%
ifname
,
timeout
=
240
)
session
.
cmd_output_safe
(
arp_clean
)
session
.
close
()
return
None
def
get_hotplug_nic_ip
(
vm
,
nic
,
session
,
is_linux_guest
=
True
):
def
get_hotplug_nic_ip
(
vm
,
nic
,
is_linux_guest
=
True
):
def
__get_address
():
try
:
index
=
[
...
...
@@ -67,7 +70,7 @@ def run(test, params, env):
(
nic
[
"nic_name"
],
vm
.
name
))
except
(
virt_vm
.
VMIPAddressMissingError
,
virt_vm
.
VMAddressVerificationError
):
renew_ip_address
(
session
,
nic
[
"mac"
],
is_linux_guest
)
renew_ip_address
(
nic
[
"mac"
],
is_linux_guest
)
return
nic_ip
=
utils_misc
.
wait_for
(
__get_address
,
timeout
=
360
)
...
...
@@ -80,11 +83,12 @@ def run(test, params, env):
logging
.
debug
(
"
\t
ARP table: %s"
,
arps
)
return
None
def
ping_hotplug_nic
(
ip
,
mac
,
session
,
is_linux_guest
):
def
ping_hotplug_nic
(
ip
,
mac
,
is_linux_guest
):
status
,
output
=
utils_test
.
ping
(
ip
,
10
,
timeout
=
30
)
if
status
!=
0
:
if
not
is_linux_guest
:
return
status
,
output
session
=
vm
.
wait_for_serial_login
(
timeout
=
login_timeout
)
ifname
=
utils_net
.
get_linux_ifname
(
session
,
mac
)
add_route_cmd
=
"route add %s dev %s"
%
(
ip
,
ifname
)
del_route_cmd
=
"route del %s dev %s"
%
(
ip
,
ifname
)
...
...
@@ -94,6 +98,7 @@ def run(test, params, env):
status
,
output
=
utils_test
.
ping
(
hotnic_ip
,
10
,
timeout
=
30
)
logging
.
info
(
"Del the route."
)
status
,
output
=
session
.
cmd_output_safe
(
del_route_cmd
)
session
.
close
()
return
status
,
output
def
device_add_nic
(
pci_model
,
netdev
,
device_id
):
...
...
@@ -165,11 +170,11 @@ def run(test, params, env):
logging
.
debug
(
"Hotplug %sth '%s' nic named '%s'"
,
nic_index
,
nic_model
,
nic_name
)
hotplug_nic
=
vm
.
hotplug_nic
(
**
nic_params
)
s_session
.
close
()
logging
.
info
(
"Check if new interface gets ip address"
)
hotnic_ip
=
get_hotplug_nic_ip
(
vm
,
hotplug_nic
,
s_session
,
guest_is_linux
)
if
not
hotnic_ip
:
test
.
fail
(
"Hotplug nic can not get ip address"
)
...
...
@@ -177,7 +182,7 @@ def run(test, params, env):
logging
.
info
(
"Ping guest's new ip from host"
)
status
,
output
=
ping_hotplug_nic
(
host_ip_addr
,
hotplug_nic
[
"mac"
],
s_session
,
guest_is_linux
)
guest_is_linux
)
if
status
:
err_msg
=
"New nic failed ping test, error info: '%s'"
test
.
fail
(
err_msg
%
output
)
...
...
@@ -185,12 +190,11 @@ def run(test, params, env):
logging
.
info
(
"Reboot vm after hotplug nic"
)
# reboot vm via serial port since some guest can't auto up
# hotplug nic and next step will check is hotplug nic works.
s
_session
=
vm
.
reboot
(
session
=
s_session
,
serial
=
True
)
vm
.
verify_aliv
e
()
s
ession
=
vm
.
wait_for_serial_login
(
timeout
=
login_timeout
)
vm
.
reboot
(
session
,
serial
=
True
).
clos
e
()
hotnic_ip
=
get_hotplug_nic_ip
(
vm
,
hotplug_nic
,
s_session
,
guest_is_linux
)
if
not
hotnic_ip
:
test
.
fail
(
...
...
@@ -198,7 +202,7 @@ def run(test, params, env):
logging
.
info
(
"Ping guest's new ip from host"
)
status
,
output
=
ping_hotplug_nic
(
host_ip_addr
,
hotplug_nic
[
"mac"
],
s_session
,
guest_is_linux
)
guest_is_linux
)
if
status
:
err_msg
=
"New nic failed ping test, error info: '%s'"
test
.
fail
(
err_msg
%
output
)
...
...
@@ -209,7 +213,7 @@ def run(test, params, env):
vm
.
resume
()
logging
.
info
(
"Ping guest's new ip after resume"
)
status
,
output
=
ping_hotplug_nic
(
host_ip_addr
,
hotplug_nic
[
"mac"
],
s_session
,
guest_is_linux
)
guest_is_linux
)
if
status
:
err_msg
=
"New nic failed ping test after stop/cont, "
err_msg
+=
"error info: '%s'"
%
output
...
...
@@ -222,17 +226,16 @@ def run(test, params, env):
unplug_nic_index
=
random
.
randint
(
0
,
len
(
nic_hotplugged
)
-
1
)
vm
.
hotunplug_nic
(
nic_hotplugged
[
unplug_nic_index
].
nic_name
)
nic_hotplugged
.
pop
(
unplug_nic_index
)
s_session
=
vm
.
reboot
(
session
=
s_session
,
serial
=
True
)
vm
.
verify_alive
()
s_session
.
close
()
finally
:
session
=
vm
.
wait_for_serial_login
(
timeout
=
login_timeout
)
vm
.
reboot
(
session
,
serial
=
True
).
close
()
for
nic
in
nic_hotplugged
:
vm
.
hotunplug_nic
(
nic
.
nic_name
)
logging
.
info
(
"Re-enabling the primary link(s)"
)
for
nic
in
primary_nic
:
vm
.
set_link
(
nic
.
device_id
,
up
=
True
)
logging
.
info
(
"Reboot vm to verify it alive after hotunplug nic(s)"
)
serial
=
len
(
vm
.
virtnet
)
>
0
and
False
or
True
session
=
vm
.
reboot
(
serial
=
serial
)
vm
.
verify_alive
()
session
.
close
()
session
=
vm
.
wait_for_serial_login
(
timeout
=
login_timeout
)
vm
.
reboot
(
session
,
serial
=
True
).
close
()
finally
:
if
s_session
:
s_session
.
close
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录