Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
a8b73bca
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,发现更多精彩内容 >>
未验证
提交
a8b73bca
编写于
10月 12, 2018
作者:
Q
Qianqian Zhu
提交者:
GitHub
10月 12, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1391 from xiywang/multi_nics_verify
multi_nics_verify: Boot 27 NICs and all the NICs can get IPs
上级
9cd9f70c
4ac167c1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
38 deletion
+63
-38
qemu/tests/cfg/multi_nics_verify.cfg
qemu/tests/cfg/multi_nics_verify.cfg
+2
-10
qemu/tests/multi_nics_verify.py
qemu/tests/multi_nics_verify.py
+61
-28
未找到文件。
qemu/tests/cfg/multi_nics_verify.cfg
浏览文件 @
a8b73bca
- multi_nics_verify: guest_test.arp_set
- multi_nics_verify: guest_test.arp_set
virt_test_type = qemu
virt_test_type = qemu
type = multi_nics_verify
type = multi_nics_verify
only Linux
no RHEL.3.9
no RHEL.3.9
nics += ' nic2 nic3 nic4 nic5 nic6 nic7 nic8'
nics_num = 27
start_vm = no
kill_vm = no
kill_vm = no
flexible_nic_index = yes
mac_filter = "HWaddr (.\w+:\w+:\w+:\w+:\w+:\w+)"
ip_filter = "inet addr:(.\d+.\d+.\d+.\d+)"
net_check_cmd = "ifconfig"
strick_check = ""
flood_minutes = 1
transfer_timeout = 1000
reboot = yes
qemu/tests/multi_nics_verify.py
浏览文件 @
a8b73bca
...
@@ -3,6 +3,7 @@ import logging
...
@@ -3,6 +3,7 @@ import logging
from
virttest
import
error_context
from
virttest
import
error_context
from
virttest
import
utils_net
from
virttest
import
utils_net
from
virttest
import
env_process
@
error_context
.
context_aware
@
error_context
.
context_aware
...
@@ -23,6 +24,12 @@ def run(test, params, env):
...
@@ -23,6 +24,12 @@ def run(test, params, env):
:param env: Dictionary with test environment.
:param env: Dictionary with test environment.
"""
"""
def
check_nics_num
(
expect_c
,
session
):
def
check_nics_num
(
expect_c
,
session
):
"""
Check whether guest NICs number match with params set in cfg file
:param expect_c: expected nics no.
:param session: in which session the guest runs in
"""
txt
=
"Check whether guest NICs info match with params setting."
txt
=
"Check whether guest NICs info match with params setting."
error_context
.
context
(
txt
,
logging
.
info
)
error_context
.
context
(
txt
,
logging
.
info
)
nics_list
=
utils_net
.
get_linux_ifname
(
session
)
nics_list
=
utils_net
.
get_linux_ifname
(
session
)
...
@@ -35,39 +42,65 @@ def run(test, params, env):
...
@@ -35,39 +42,65 @@ def run(test, params, env):
return
(
False
,
msg
)
return
(
False
,
msg
)
return
(
True
,
msg
+
'Nics count match'
)
return
(
True
,
msg
+
'Nics count match'
)
# Get the ethernet cards number from params
nics_num
=
int
(
params
.
get
(
"nics_num"
,
8
))
for
i
in
range
(
nics_num
):
nics
=
"nic%s"
%
i
params
[
"nics"
]
=
' '
.
join
([
params
[
"nics"
],
nics
])
params
[
"start_vm"
]
=
"yes"
env_process
.
preprocess_vm
(
test
,
params
,
env
,
params
[
"main_vm"
])
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
vm
.
verify_alive
()
session
=
vm
.
wait_for_login
(
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
)))
session
=
vm
.
wait_for_login
(
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
)))
# Redirect ifconfig output from guest to log file
log_file
=
os
.
path
.
join
(
test
.
debugdir
,
"ifconfig"
)
ifconfig_output
=
session
.
cmd
(
"ifconfig"
)
log_file_object
=
open
(
log_file
,
"w"
)
log_file_object
.
write
(
ifconfig_output
)
# Get the ethernet cards number from params
nics_num
=
len
(
params
.
objects
(
"nics"
))
logging
.
info
(
"[ %s ] NICs card specified in config file"
%
nics_num
)
logging
.
info
(
"[ %s ] NICs card specified in config file"
%
nics_num
)
# Pre-judgement for the ethernet interface
os_type
=
params
.
get
(
"os_type"
,
"linux"
)
logging
.
debug
(
check_nics_num
(
nics_num
,
session
)[
1
])
if
os_type
==
"linux"
:
txt
=
"Create configure file for every NIC interface in guest."
# Redirect ifconfig output from guest to log file
error_context
.
context
(
txt
,
logging
.
info
)
log_file
=
os
.
path
.
join
(
test
.
debugdir
,
"ifconfig"
)
ifname_list
=
utils_net
.
get_linux_ifname
(
session
)
ifconfig_output
=
session
.
cmd
(
"ifconfig"
)
ifcfg_path
=
"/etc/sysconfig/network-scripts/ifcfg-%s"
log_file_object
=
open
(
log_file
,
"w"
)
for
ifname
in
ifname_list
:
log_file_object
.
write
(
ifconfig_output
)
eth_config_path
=
ifcfg_path
%
ifname
log_file_object
.
close
()
eth_config
=
"DEVICE=%s
\\
nBOOTPROTO=dhcp
\\
nONBOOT=yes"
%
ifname
cmd
=
"echo -e '%s' > %s"
%
(
eth_config
,
eth_config_path
)
# Pre-judgement for the ethernet interface
s
,
o
=
session
.
cmd_status_output
(
cmd
)
logging
.
debug
(
check_nics_num
(
nics_num
,
session
)[
1
])
if
s
!=
0
:
txt
=
"Create configure file for every NIC interface in guest."
err_msg
=
"Failed to create ether config file: %s
\n
Reason is: %s"
error_context
.
context
(
txt
,
logging
.
info
)
test
.
error
(
err_msg
%
(
eth_config_path
,
o
))
ifname_list
=
utils_net
.
get_linux_ifname
(
session
)
ifcfg_path
=
"/etc/sysconfig/network-scripts/ifcfg-%s"
for
ifname
in
ifname_list
:
eth_config_path
=
ifcfg_path
%
ifname
eth_config
=
"DEVICE=%s
\\
nBOOTPROTO=dhcp
\\
nONBOOT=yes"
%
ifname
cmd
=
"echo -e '%s' > %s"
%
(
eth_config
,
eth_config_path
)
s
,
o
=
session
.
cmd_status_output
(
cmd
)
if
s
!=
0
:
err_msg
=
"Failed to create ether config file: %s
\n
Reason is: %s"
test
.
error
(
err_msg
%
(
eth_config_path
,
o
))
session
.
close
()
# Reboot and check the configurations.
new_session
=
vm
.
reboot
(
session
)
s
,
msg
=
check_nics_num
(
nics_num
,
new_session
)
if
not
s
:
test
.
fail
(
msg
)
new_session
.
close
()
# Reboot and check the configurations.
# NICs matched.
new_session
=
vm
.
reboot
(
session
)
logging
.
info
(
msg
)
s
,
msg
=
check_nics_num
(
nics_num
,
new_session
)
if
not
s
:
test
.
fail
(
msg
)
# NICs matched.
# Check all the interfaces in guest get ips
logging
.
info
(
msg
)
nic_interface
=
[]
session_srl
=
vm
.
wait_for_serial_login
(
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
)))
for
index
,
nic
in
enumerate
(
vm
.
virtnet
):
logging
.
info
(
"index %s nic"
%
index
)
guest_ip
=
utils_net
.
get_guest_ip_addr
(
session_srl
,
nic
.
mac
,
os_type
,
ip_version
=
"ipv4"
)
if
not
guest_ip
:
err_log
=
"vm get interface %s's ip failed."
%
index
test
.
fail
(
err_log
)
nic_interface
.
append
(
guest_ip
)
session_srl
.
close
()
logging
.
info
(
"All the [ %s ] NICs get IPs."
%
nics_num
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录