Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
864c1fc6
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,发现更多精彩内容 >>
未验证
提交
864c1fc6
编写于
4月 04, 2018
作者:
X
Xu Han
提交者:
GitHub
4月 04, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1293 from luckyh/replace-autotest-qemu-p8
[qemu] Replace autotest modules - n
上级
f070d66e
87281bc2
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
202 addition
and
197 deletion
+202
-197
qemu/tests/netperf_stress.py
qemu/tests/netperf_stress.py
+5
-5
qemu/tests/netperf_udp.py
qemu/tests/netperf_udp.py
+10
-11
qemu/tests/nfs_perf.py
qemu/tests/nfs_perf.py
+23
-21
qemu/tests/nic_bonding.py
qemu/tests/nic_bonding.py
+9
-11
qemu/tests/nic_bonding_host.py
qemu/tests/nic_bonding_host.py
+29
-27
qemu/tests/nic_hotplug.py
qemu/tests/nic_hotplug.py
+2
-2
qemu/tests/nic_teaming.py
qemu/tests/nic_teaming.py
+26
-24
qemu/tests/nmi_bsod_catch.py
qemu/tests/nmi_bsod_catch.py
+18
-16
qemu/tests/nmi_watchdog.py
qemu/tests/nmi_watchdog.py
+11
-10
qemu/tests/nonexist_vcpu_hotplug.py
qemu/tests/nonexist_vcpu_hotplug.py
+14
-14
qemu/tests/numa_consistency.py
qemu/tests/numa_consistency.py
+14
-14
qemu/tests/numa_opts.py
qemu/tests/numa_opts.py
+3
-4
qemu/tests/numa_stress.py
qemu/tests/numa_stress.py
+25
-24
qemu/tests/nx.py
qemu/tests/nx.py
+13
-14
未找到文件。
qemu/tests/netperf_stress.py
浏览文件 @
864c1fc6
...
...
@@ -2,15 +2,14 @@ import os
import
logging
import
time
from
autotest.client.shared
import
error
from
virttest
import
error_context
from
virttest
import
utils_net
from
virttest
import
utils_netperf
from
virttest
import
utils_misc
from
virttest
import
data_dir
@
error
.
context_aware
@
error
_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Run netperf stress on server and client side.
...
...
@@ -227,7 +226,8 @@ def run(test, params, env):
num
=
0
s_len
=
len
(
server_infos
)
for
protocol
in
test_protocols
.
split
():
error
.
context
(
"Testing %s protocol"
%
protocol
,
logging
.
info
)
error_context
.
context
(
"Testing %s protocol"
%
protocol
,
logging
.
info
)
t_option
=
"%s -t %s"
%
(
test_option
,
protocol
)
for
n_client
in
netperf_clients
:
index
=
num
%
s_len
...
...
@@ -239,7 +239,7 @@ def run(test, params, env):
"Wait netperf test start"
):
logging
.
info
(
"Netperf test start successfully."
)
else
:
raise
error
.
TestE
rror
(
"Can not start netperf client."
)
test
.
e
rror
(
"Can not start netperf client."
)
num
+=
1
# here when set a run flag, when other case call this case as a
# subprocess backgroundly, can set this run flag to False to stop
...
...
qemu/tests/netperf_udp.py
浏览文件 @
864c1fc6
...
...
@@ -2,14 +2,13 @@ import logging
import
os
import
re
from
autotest.client.shared
import
error
from
virttest
import
error_context
from
virttest
import
utils_net
from
virttest
import
utils_netperf
from
virttest
import
data_dir
@
error
.
context_aware
@
error
_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Run netperf on server and client side, we need run this case on two
...
...
@@ -39,7 +38,7 @@ def run(test, params, env):
main_vm_ip
=
vm
.
get_address
()
session
.
cmd
(
"iptables -F"
,
ignore_all_errors
=
True
)
error
.
context
(
"Test env prepare"
,
logging
.
info
)
error
_context
.
context
(
"Test env prepare"
,
logging
.
info
)
netperf_link
=
params
.
get
(
"netperf_link"
)
if
netperf_link
:
netperf_link
=
os
.
path
.
join
(
data_dir
.
get_deps_dir
(
"netperf"
),
...
...
@@ -147,7 +146,7 @@ def run(test, params, env):
throughput
=
[]
try
:
error
.
context
(
"Start netperf_server"
,
logging
.
info
)
error
_context
.
context
(
"Start netperf_server"
,
logging
.
info
)
netperf_server
.
start
()
# Run netperf with message size defined in range.
msg
=
"Detail result of netperf test with different packet size.
\n
"
...
...
@@ -155,7 +154,7 @@ def run(test, params, env):
test_protocol
=
params
.
get
(
"test_protocol"
,
"UDP_STREAM"
)
test_option
=
"-t %s -- -m %s"
%
(
test_protocol
,
m_size
)
txt
=
"Run netperf client with protocol: '%s', packet size: '%s'"
error
.
context
(
txt
%
(
test_protocol
,
m_size
),
logging
.
info
)
error
_context
.
context
(
txt
%
(
test_protocol
,
m_size
),
logging
.
info
)
output
=
netperf_client
.
start
(
netserver_ip
,
test_option
)
re_str
=
"[0-9\.]+\s+[0-9\.]+\s+[0-9\.]+\s+[0-9\.]+\s+[0-9\.]+"
re_str
+=
"\s+[0-9\.]+"
...
...
@@ -164,9 +163,9 @@ def run(test, params, env):
except
IndexError
:
txt
=
"Fail to get Throughput for %s."
%
m_size
txt
+=
" netprf client output: %s"
%
output
raise
error
.
TestE
rror
(
txt
)
test
.
e
rror
(
txt
)
if
not
line_tokens
:
raise
error
.
TestE
rror
(
"Output format is not expected"
)
test
.
e
rror
(
"Output format is not expected"
)
throughput
.
append
(
float
(
line_tokens
[
5
]))
msg
+=
output
m_size
+=
step
...
...
@@ -175,17 +174,17 @@ def run(test, params, env):
file
(
os
.
path
.
join
(
test
.
debugdir
,
"udp_results"
),
"w"
).
write
(
msg
)
failratio
=
float
(
params
.
get
(
"failratio"
,
0.3
))
error
.
context
(
"Compare UDP performance."
,
logging
.
info
)
error
_context
.
context
(
"Compare UDP performance."
,
logging
.
info
)
for
i
in
range
(
len
(
throughput
)
-
1
):
if
abs
(
throughput
[
i
]
-
throughput
[
i
+
1
])
>
throughput
[
i
]
*
failratio
:
txt
=
"The gap between adjacent throughput is greater than"
txt
+=
"%f."
%
failratio
txt
+=
"Please refer to log file for details:
\n
%s"
%
msg
raise
error
.
TestF
ail
(
txt
)
test
.
f
ail
(
txt
)
logging
.
info
(
"The UDP performance as measured via netperf is ok."
)
logging
.
info
(
"Throughput of netperf command: %s"
%
throughput
)
logging
.
debug
(
"Output of netperf command:
\n
%s"
%
msg
)
error
.
context
(
"Kill netperf server on server (dsthost)."
)
error
_context
.
context
(
"Kill netperf server on server (dsthost)."
)
try
:
if
session
:
...
...
qemu/tests/nfs_perf.py
浏览文件 @
864c1fc6
...
...
@@ -2,15 +2,15 @@ import logging
import
re
import
os
from
autotest.client.shared
import
error
from
autotest.client
import
utils
from
avocado.utils
import
process
from
virttest
import
error_context
from
virttest
import
utils_misc
STEP_1
,
STEP_2
,
STEP_3
,
STEP_4
,
STEP_5
,
STEP_6
=
range
(
6
)
@
error
.
context_aware
@
error
_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
KVM nfs performance test:
...
...
@@ -41,7 +41,7 @@ def run(test, params, env):
" error message:
\n
%s"
,
func
.
__name__
,
e
)
def
_clean_up
(
step_cnt
):
error
.
context
(
"Clean up"
,
logging
.
info
)
error
_context
.
context
(
"Clean up"
,
logging
.
info
)
if
step_cnt
>=
STEP_5
:
# remove test file.
cmd
=
"rm -f %s"
%
" "
.
join
(
test_file_list
)
...
...
@@ -65,8 +65,8 @@ def run(test, params, env):
# Clean up caches
session
.
cmd
(
"echo 3 >/proc/sys/vm/drop_caches"
)
error
.
context
(
"test %s size block write performance in guest"
" using dd commands"
%
blk_size
,
logging
.
info
)
error
_context
.
context
(
"test %s size block write performance in guest"
" using dd commands"
%
blk_size
,
logging
.
info
)
dd_cmd
=
"dd"
dd_cmd
+=
" if=/dev/zero"
dd_cmd
+=
" of=%s"
%
test_file
...
...
@@ -85,8 +85,8 @@ def run(test, params, env):
# Clean up caches
session
.
cmd
(
"echo 3 >/proc/sys/vm/drop_caches"
)
error
.
context
(
"test %s size block read performance in guest"
" using dd commands"
%
blk_size
,
logging
.
info
)
error
_context
.
context
(
"test %s size block read performance in guest"
" using dd commands"
%
blk_size
,
logging
.
info
)
dd_cmd
=
"dd"
dd_cmd
+=
" if=%s"
%
test_file
dd_cmd
+=
" of=/dev/null"
...
...
@@ -102,10 +102,10 @@ def run(test, params, env):
return
out
if
not
hasattr
(
test
,
"write_perf_keyval"
):
raise
error
.
TestNAError
(
"There is no 'write_perf_keyval' method in"
" test object, skip this test"
)
test
.
cancel
(
"There is no 'write_perf_keyval' method in"
" test object, skip this test"
)
error
.
context
(
"boot guest over virtio driver"
,
logging
.
info
)
error
_context
.
context
(
"boot guest over virtio driver"
,
logging
.
info
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
...
...
@@ -117,13 +117,14 @@ def run(test, params, env):
kvm_userspace_ver_cmd
=
params
.
get
(
"kvm_userspace_ver_cmd"
,
""
)
if
kvm_userspace_ver_cmd
:
try
:
cmd_result
=
util
s
.
run
(
kvm_userspace_ver_cmd
)
cmd_result
=
proces
s
.
run
(
kvm_userspace_ver_cmd
)
qemu_version
=
cmd_result
.
stdout
.
strip
()
except
error
.
CmdError
:
except
process
.
CmdError
:
qemu_version
=
"Unknown"
else
:
qemu_path
=
utils_misc
.
get_qemu_binary
(
params
)
version_line
=
utils
.
system_output
(
"%s -help | head -n 1"
%
qemu_path
)
version_line
=
process
.
system_output
(
"%s -help | head -n 1"
%
qemu_path
)
matches
=
re
.
findall
(
"version .*?,"
,
version_line
,
re
.
I
)
if
matches
:
qemu_version
=
" "
.
join
(
matches
[
0
].
split
()[
1
:]).
strip
(
","
)
...
...
@@ -140,7 +141,8 @@ def run(test, params, env):
raise
# After STEP 2
error
.
context
(
"mount nfs server in guest with tcp protocol"
,
logging
.
info
)
error_context
.
context
(
"mount nfs server in guest with tcp protocol"
,
logging
.
info
)
nfs_server
=
params
.
get
(
"nfs_server"
)
nfs_path
=
params
.
get
(
"nfs_path"
)
mnt_option
=
params
.
get
(
"mnt_option"
)
...
...
@@ -153,8 +155,8 @@ def run(test, params, env):
if
(
not
nfs_server
)
or
(
not
nfs_path
)
or
(
not
mnt_point
):
_clean_up
(
STEP_2
)
raise
error
.
TestE
rror
(
"Missing configuration for nfs partition."
" Check your config files"
)
test
.
e
rror
(
"Missing configuration for nfs partition."
" Check your config files"
)
try
:
session
.
cmd
(
"mkdir -p %s"
%
mnt_point
)
...
...
@@ -201,8 +203,8 @@ def run(test, params, env):
tmp_list
=
re
.
findall
(
speed_pattern
,
out
)
if
not
tmp_list
:
_clean_up
(
STEP_5
)
raise
error
.
TestE
rror
(
"Could not get correct write result."
" dd cmd output:
\n
%s"
%
out
)
test
.
e
rror
(
"Could not get correct write result."
" dd cmd output:
\n
%s"
%
out
)
_
,
_
,
speed
=
tmp_list
[
0
]
speed
=
utils_misc
.
normalize_data_size
(
speed
)
result
+=
"%016s|"
%
speed
...
...
@@ -213,8 +215,8 @@ def run(test, params, env):
tmp_list
=
re
.
findall
(
speed_pattern
,
out
)
if
not
tmp_list
:
_clean_up
(
STEP_6
)
raise
error
.
TestE
rror
(
"Could not get correct read result."
" dd cmd output:
\n
%s"
%
out
)
test
.
e
rror
(
"Could not get correct read result."
" dd cmd output:
\n
%s"
%
out
)
_
,
_
,
speed
=
tmp_list
[
0
]
speed
=
utils_misc
.
normalize_data_size
(
speed
)
result
+=
"%016s"
%
speed
...
...
qemu/tests/nic_bonding.py
浏览文件 @
864c1fc6
...
...
@@ -4,11 +4,9 @@ import random
import
aexpect
from
autotest.client.shared
import
error
from
autotest.client.shared
import
utils
from
virttest
import
utils_test
from
virttest
import
utils_net
from
virttest
import
utils_misc
def
run
(
test
,
params
,
env
):
...
...
@@ -65,16 +63,16 @@ def run(test, params, env):
utils_test
.
run_file_transfer
(
test
,
params
,
env
)
logging
.
info
(
"Failover test with file transfer"
)
transfer_thread
=
utils
.
InterruptedThread
(
utils_test
.
run_file_transfer
,
(
test
,
params
,
env
))
transfer_thread
=
utils
_misc
.
InterruptedThread
(
utils_test
.
run_file_transfer
,
(
test
,
params
,
env
))
transfer_thread
.
start
()
try
:
while
transfer_thread
.
isAlive
():
for
vlan
,
nic
in
enumerate
(
vm
.
virtnet
):
device_id
=
nic
.
device_id
if
not
device_id
:
raise
error
.
TestE
rror
(
"Could not find peer device for"
" nic device %s"
%
nic
)
test
.
e
rror
(
"Could not find peer device for"
" nic device %s"
%
nic
)
vm
.
set_link
(
device_id
,
up
=
False
)
time
.
sleep
(
random
.
randint
(
1
,
30
))
vm
.
set_link
(
device_id
,
up
=
True
)
...
...
@@ -86,8 +84,8 @@ def run(test, params, env):
transfer_thread
.
join
()
logging
.
info
(
"Failover test 2 with file transfer"
)
transfer_thread
=
utils
.
InterruptedThread
(
utils_test
.
run_file_transfer
,
(
test
,
params
,
env
))
transfer_thread
=
utils
_misc
.
InterruptedThread
(
utils_test
.
run_file_transfer
,
(
test
,
params
,
env
))
transfer_thread
.
start
()
try
:
nic_num
=
len
(
vm
.
virtnet
)
...
...
@@ -97,8 +95,8 @@ def run(test, params, env):
for
num
in
xrange
(
nic_num
):
device_id
=
vm
.
virtnet
[
num
].
device_id
if
not
device_id
:
raise
error
.
TestE
rror
(
"Could not find peer device for"
" nic device %s"
%
nic
)
test
.
e
rror
(
"Could not find peer device for"
" nic device %s"
%
nic
)
if
num
==
up_index
:
vm
.
set_link
(
device_id
,
up
=
True
)
else
:
...
...
qemu/tests/nic_bonding_host.py
浏览文件 @
864c1fc6
...
...
@@ -2,16 +2,16 @@ import time
import
logging
import
re
from
autotest.client.shared
import
error
from
autotest.client.shared
import
utils
from
avocado.utils
import
process
from
virttest
import
error_context
from
virttest
import
utils_test
from
virttest
import
utils_misc
from
virttest
import
env_process
from
virttest
import
utils_net
@
error
.
context_aware
@
error
_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Qemu host nic bonding test:
...
...
@@ -40,19 +40,20 @@ def run(test, params, env):
params
[
'netdst'
]
=
bond_br_name
host_bridges
=
utils_net
.
Bridge
()
error
.
context
(
"Load bonding module with mode 802.3ad"
,
logging
.
info
)
if
not
utils
.
system
(
"lsmod|grep bonding"
,
ignore_status
=
True
):
utils
.
system
(
"modprobe -r bonding"
)
error_context
.
context
(
"Load bonding module with mode 802.3ad"
,
logging
.
info
)
if
not
process
.
system
(
"lsmod|grep bonding"
,
ignore_status
=
True
):
process
.
system
(
"modprobe -r bonding"
)
util
s
.
system
(
proces
s
.
system
(
"modprobe bonding mode=%s miimon=%s"
%
(
bonding_mode
,
bonding_miimon
))
error
.
context
(
"Bring up %s"
%
bond_iface
,
logging
.
info
)
error
_context
.
context
(
"Bring up %s"
%
bond_iface
,
logging
.
info
)
host_ifaces
=
utils_net
.
get_host_iface
()
if
bond_iface
not
in
host_ifaces
:
raise
error
.
TestE
rror
(
"Can not find bond0 in host"
)
test
.
e
rror
(
"Can not find bond0 in host"
)
bond_iface
=
utils_net
.
Interface
(
bond_iface
)
bond_iface
.
up
()
...
...
@@ -69,49 +70,50 @@ def run(test, params, env):
if
(
len
(
host_ph_ifaces_un
)
<
2
or
len
(
host_ph_ifaces_un
)
<
host_iface_bonding
):
raise
error
.
TestNAError
(
"Host need %s nics"
" at least."
%
host_iface_bonding
)
test
.
cancel
(
"Host need %s nics at least."
%
host_iface_bonding
)
error
.
context
(
"Add nics to %s"
%
bond_iface
.
name
,
logging
.
info
)
error
_context
.
context
(
"Add nics to %s"
%
bond_iface
.
name
,
logging
.
info
)
host_ifaces_bonding
=
host_ph_ifaces_un
[:
host_iface_bonding
]
ifenslave_cmd
=
"ifenslave %s"
%
bond_iface
.
name
op_ifaces
=
[]
for
host_iface_bonding
in
host_ifaces_bonding
:
op_ifaces
.
append
(
utils_net
.
Interface
(
host_iface_bonding
))
ifenslave_cmd
+=
" %s"
%
host_iface_bonding
util
s
.
system
(
ifenslave_cmd
)
proces
s
.
system
(
ifenslave_cmd
)
error
.
context
(
"Add a new bridge and add %s to it."
%
bond_iface
.
name
,
logging
.
info
)
error
_context
.
context
(
"Add a new bridge and add %s to it."
%
bond_iface
.
name
,
logging
.
info
)
if
bond_br_name
not
in
host_bridges
.
list_br
():
host_bridges
.
add_bridge
(
bond_br_name
)
host_bridges
.
add_port
(
bond_br_name
,
bond_iface
.
name
)
error
.
context
(
"Get ip address for bridge"
,
logging
.
info
)
util
s
.
system
(
"dhclient -r; dhclient %s"
%
bond_br_name
)
error
_context
.
context
(
"Get ip address for bridge"
,
logging
.
info
)
proces
s
.
system
(
"dhclient -r; dhclient %s"
%
bond_br_name
)
error
.
context
(
"Boot up guest with bridge %s"
%
bond_br_name
,
logging
.
info
)
error_context
.
context
(
"Boot up guest with bridge %s"
%
bond_br_name
,
logging
.
info
)
params
[
"start_vm"
]
=
"yes"
vm_name
=
params
.
get
(
"main_vm"
)
env_process
.
preprocess_vm
(
test
,
params
,
env
,
vm_name
)
vm
=
env
.
get_vm
(
vm_name
)
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
error
.
context
(
"Checking guest netowrk via ping."
,
logging
.
info
)
error
_context
.
context
(
"Checking guest netowrk via ping."
,
logging
.
info
)
ping_cmd
=
params
.
get
(
"ping_cmd"
)
ping_cmd
=
re
.
sub
(
"REMOTE_HOST"
,
remote_host
,
ping_cmd
)
session
.
cmd
(
ping_cmd
,
timeout
=
ping_timeout
)
error
.
context
(
"Start file transfer"
,
logging
.
info
)
f_transfer
=
utils
.
InterruptedThread
(
utils_test
.
run_virt_sub_test
,
args
=
(
test
,
params
,
env
,),
kwargs
=
{
"sub_type"
:
"file_transfer"
})
error_context
.
context
(
"Start file transfer"
,
logging
.
info
)
f_transfer
=
utils_misc
.
InterruptedThread
(
utils_test
.
run_virt_sub_test
,
args
=
(
test
,
params
,
env
,),
kwargs
=
{
"sub_type"
:
"file_transfer"
})
f_transfer
.
start
()
utils_misc
.
wait_for
(
lambda
:
utils
.
system_output
(
"pidof scp"
,
ignore_status
=
True
),
30
)
utils_misc
.
wait_for
(
lambda
:
process
.
system_output
(
"pidof scp"
,
ignore_status
=
True
),
30
)
error
.
context
(
"Disable and enable physical "
"interfaces in %s"
%
bond_br_name
,
logging
.
info
)
error
_context
.
context
(
"Disable and enable physical "
"interfaces in %s"
%
bond_br_name
,
logging
.
info
)
while
True
:
for
op_iface
in
op_ifaces
:
logging
.
debug
(
"Turn down %s"
%
op_iface
.
name
)
...
...
qemu/tests/nic_hotplug.py
浏览文件 @
864c1fc6
import
logging
import
random
from
a
utotest.client.shared
import
util
s
from
a
vocado.utils
import
proces
s
from
virttest
import
utils_test
from
virttest
import
utils_net
...
...
@@ -74,7 +74,7 @@ def run(test, params, env):
if
nic_ip
:
return
nic_ip
cached_ip
=
vm
.
address_cache
.
get
(
nic
[
"mac"
])
arps
=
util
s
.
system_output
(
"arp -aen"
)
arps
=
proces
s
.
system_output
(
"arp -aen"
)
logging
.
debug
(
"Can't get IP address:"
)
logging
.
debug
(
"
\t
Cached IP: %s"
,
cached_ip
)
logging
.
debug
(
"
\t
ARP table: %s"
,
arps
)
...
...
qemu/tests/nic_teaming.py
浏览文件 @
864c1fc6
...
...
@@ -3,14 +3,13 @@ import re
import
random
import
logging
from
autotest.client.shared
import
error
from
autotest.client.shared
import
utils
from
virttest
import
error_context
from
virttest
import
utils_test
from
virttest
import
utils_net
from
virttest
import
utils_misc
@
error
.
context_aware
@
error
_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Test failover by team driver
...
...
@@ -35,13 +34,13 @@ def run(test, params, env):
ports
=
re
.
findall
(
r
"%s"
%
params
[
"ptn_teamnl"
],
output_teamnl
)
for
port
in
ifnames
:
if
port
not
in
ports
:
raise
error
.
TestF
ail
(
"Add %s to %s failed."
%
(
port
,
team_if
))
test
.
f
ail
(
"Add %s to %s failed."
%
(
port
,
team_if
))
session_serial
.
cmd_output_safe
(
params
[
"killdhclient_cmd"
])
output
=
session_serial
.
cmd_output_safe
(
params
[
"getip_cmd"
],
timeout
=
300
)
team_ip
=
re
.
search
(
r
"%s"
%
params
[
"ptn_ipv4"
],
output
).
group
()
if
not
team_ip
:
raise
error
.
TestF
ail
(
"Failed to get ip address of %s"
%
team_if
)
test
.
f
ail
(
"Failed to get ip address of %s"
%
team_if
)
return
ports
,
team_ip
def
failover
(
ifnames
,
timeout
):
...
...
@@ -66,15 +65,14 @@ def run(test, params, env):
def
check_ping
(
status
,
output
):
""" ratio <5% is acceptance."""
if
status
!=
0
:
raise
error
.
TestFail
(
"Ping failed, staus:%s, output:%s"
%
(
status
,
output
))
test
.
fail
(
"Ping failed, staus:%s, output:%s"
%
(
status
,
output
))
# if status != 0 the ping process seams hit issue.
ratio
=
utils_test
.
get_loss_ratio
(
output
)
if
ratio
==
-
1
:
raise
error
.
TestFail
(
'''The ratio is %s, and status is %s,
output is %s'''
%
(
ratio
,
status
,
output
))
test
.
fail
(
"The ratio is %s, and status is %s, "
"output is %s"
%
(
ratio
,
status
,
output
))
elif
ratio
>
int
(
params
[
"failed_ratio"
]):
raise
error
.
TestF
ail
(
"The loss raito is %s, test failed"
%
ratio
)
test
.
f
ail
(
"The loss raito is %s, test failed"
%
ratio
)
logging
.
info
(
"ping pass with loss raito:%s, that less than %s"
%
(
ratio
,
params
[
"failed_ratio"
]))
...
...
@@ -94,14 +92,15 @@ def run(test, params, env):
team_if
=
params
.
get
(
"team_if"
)
# initial
error
.
context
(
"Step1: Configure the team environment"
,
logging
.
info
)
error_context
.
context
(
"Step1: Configure the team environment"
,
logging
.
info
)
# steps of building the teaming environment starts
modprobe_cmd
=
"modprobe team"
session_serial
.
cmd_output_safe
(
modprobe_cmd
)
session_serial
.
cmd_output_safe
(
params
[
"createteam_cmd"
])
# this cmd is to create the team0 and correspoding userspace daemon
if
not
team_if_exist
():
raise
error
.
TestF
ail
(
"Interface %s is not created."
%
team_if
)
test
.
f
ail
(
"Interface %s is not created."
%
team_if
)
# check if team0 is created successfully
ports
,
team_ip
=
team_port_add
(
ifnames
,
team_if
)
logging
.
debug
(
"The list of the ports that added to %s : %s"
...
...
@@ -115,45 +114,48 @@ def run(test, params, env):
# steps of building finished
try
:
error
.
context
(
"Login in guest via ssh"
,
logging
.
info
)
error
_context
.
context
(
"Login in guest via ssh"
,
logging
.
info
)
# steps of testing this case starts
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
dest
=
utils_net
.
get_ip_address_by_interface
(
params
[
"netdst"
])
count
=
params
.
get
(
"count"
)
timeout
=
float
(
count
)
*
2
error
.
context
(
"Step2: Check if guest can ping out:"
,
logging
.
info
)
error_context
.
context
(
"Step2: Check if guest can ping out:"
,
logging
.
info
)
status
,
output
=
utils_test
.
ping
(
dest
=
dest
,
count
=
10
,
interface
=
team_if
,
timeout
=
30
,
session
=
session
)
check_ping
(
status
,
output
)
# small ping check if the team0 works w/o failover
error
.
context
(
"Step3: Start failover testing until ping finished"
,
logging
.
info
)
failover_thread
=
utils
.
InterruptedThread
(
failover
,
(
ifnames
,
timeout
))
error_context
.
context
(
"Step3: Start failover testing until "
"ping finished"
,
logging
.
info
)
failover_thread
=
utils_misc
.
InterruptedThread
(
failover
,
(
ifnames
,
timeout
))
failover_thread
.
start
()
# start failover loop until ping finished
error
.
context
(
"Step4: Start ping host for %s counts"
%
count
,
logging
.
info
)
error
_context
.
context
(
"Step4: Start ping host for %s counts"
%
count
,
logging
.
info
)
if
failover_thread
.
is_alive
():
status
,
output
=
utils_test
.
ping
(
dest
=
dest
,
count
=
count
,
interface
=
team_if
,
timeout
=
float
(
count
)
*
1.5
,
session
=
session
)
error
.
context
(
"Step5: Check if ping succeeded"
,
logging
.
info
)
error_context
.
context
(
"Step5: Check if ping succeeded"
,
logging
.
info
)
check_ping
(
status
,
output
)
else
:
raise
error
.
TestWarn
(
"The failover thread is not alive"
)
test
.
error
(
"The failover thread is not alive"
)
time
.
sleep
(
3
)
try
:
timeout
=
timeout
*
1.5
failover_thread
.
join
(
timeout
)
except
Exception
:
raise
error
.
TestWarn
(
"Failed to join the failover thread"
)
test
.
error
(
"Failed to join the failover thread"
)
# finish the main steps and check the result
session_serial
.
cmd_output_safe
(
params
[
"killteam_cmd"
])
if
team_if_exist
():
raise
error
.
TestF
ail
(
"Remove %s failed"
%
team_if
)
test
.
f
ail
(
"Remove %s failed"
%
team_if
)
logging
.
info
(
"%s removed"
%
team_if
)
# remove the team0 and the daemon, check if succeed
finally
:
...
...
qemu/tests/nmi_bsod_catch.py
浏览文件 @
864c1fc6
import
time
import
logging
from
autotest.client.shared
import
error
from
virttest
import
error_context
@
error
.
context_aware
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Generate a dump on NMI, then analyse the dump file:
...
...
@@ -21,7 +22,7 @@ def run(test, params, env):
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
error
.
context
(
"Boot a windows guest"
,
logging
.
info
)
error
_context
.
context
(
"Boot a windows guest"
,
logging
.
info
)
timeout
=
float
(
params
.
get
(
"login_timeout"
,
360
))
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
manual_reboot_cmd
=
params
.
get
(
"manual_reboot_cmd"
)
...
...
@@ -34,7 +35,7 @@ def run(test, params, env):
session
.
sendline
(
del_dump_cmd
)
if
params
.
get
(
"config_cmds"
):
error
.
context
(
"Configure guest for dump"
,
logging
.
info
)
error
_context
.
context
(
"Configure guest for dump"
,
logging
.
info
)
# Wait guest fully boot up, or configure command may fail in windows
time
.
sleep
(
30
)
reg_cmds
=
params
.
get
(
"config_cmds"
).
split
(
","
)
...
...
@@ -42,19 +43,19 @@ def run(test, params, env):
for
reg_cmd
in
reg_cmds
:
cmd
=
params
.
get
(
reg_cmd
.
strip
())
msg
+=
" The command is %s "
%
cmd
error
.
context
(
msg
)
error
_context
.
context
(
msg
)
s
,
o
=
session
.
cmd_status_output
(
cmd
,
360
)
if
s
:
raise
error
.
TestF
ail
(
"Fail command: %s. Output: %s"
%
(
cmd
,
o
))
test
.
f
ail
(
"Fail command: %s. Output: %s"
%
(
cmd
,
o
))
if
params
.
get
(
"reboot_after_config"
)
==
"yes"
:
error
.
context
(
"Reboot guest"
,
logging
.
info
)
error
_context
.
context
(
"Reboot guest"
,
logging
.
info
)
session
=
vm
.
reboot
(
timeout
=
timeout
*
2
)
try
:
if
nmi_cmd
:
error
.
context
(
"Send inject-nmi or nmi from host to guest"
,
logging
.
info
)
error
_context
.
context
(
"Send inject-nmi or nmi from host to guest"
,
logging
.
info
)
vm
.
monitor
.
send_args_cmd
(
nmi_cmd
)
# Wait guest create dump file.
if
manual_reboot_cmd
:
...
...
@@ -62,29 +63,30 @@ def run(test, params, env):
logging
.
info
(
"Waiting guest for creating dump file"
" (%ssec)"
%
bsod_time
)
time
.
sleep
(
bsod_time
)
error
.
context
(
"Send a system_reset monitor command"
,
logging
.
info
)
error_context
.
context
(
"Send a system_reset monitor command"
,
logging
.
info
)
vm
.
monitor
.
send_args_cmd
(
manual_reboot_cmd
)
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
if
check_dump_cmd
:
error
.
context
(
"Verify whether the dump files are generated"
,
logging
.
info
)
error
_context
.
context
(
"Verify whether the dump files are "
"generated"
,
logging
.
info
)
s
,
o
=
session
.
cmd_status_output
(
check_dump_cmd
,
360
)
logging
.
debug
(
"Output for check_dump_cmd command: %s"
%
o
)
if
s
:
err_msg
=
"Could not find dump files in guest. Output: '%s'"
%
o
raise
error
.
TestF
ail
(
err_msg
)
test
.
f
ail
(
err_msg
)
if
analyze_cmd
:
error
.
context
(
"Analyze dump file in guest"
,
logging
.
info
)
error
_context
.
context
(
"Analyze dump file in guest"
,
logging
.
info
)
try
:
vm
.
copy_files_from
(
params
[
"dump_path"
],
"."
,
timeout
=
100
)
except
Exception
:
pass
s
,
o
=
session
.
cmd_status_output
(
analyze_cmd
,
timeout
=
1200
)
if
s
:
raise
error
.
TestF
ail
(
"Analysis Failed. Command: '%s'.
\n\n
"
" Output: %s"
%
(
analyze_cmd
,
o
))
test
.
f
ail
(
"Analysis Failed. Command: '%s'.
\n\n
"
" Output: %s"
%
(
analyze_cmd
,
o
))
finally
:
if
session
is
not
None
and
del_dump_cmd
:
try
:
...
...
qemu/tests/nmi_watchdog.py
浏览文件 @
864c1fc6
import
time
import
logging
from
autotest.client.shared
import
error
from
virttest
import
error_context
@
error
.
context_aware
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Test the function of nmi injection and verify the response of guest
...
...
@@ -27,16 +28,16 @@ def run(test, params, env):
"--args='nmi_watchdog=%d'"
%
(
kernel_version
,
nmi_watchdog_type
))
error
.
context
(
"Add 'nmi_watchdog=%d' to guest kernel cmdline and reboot
"
%
nmi_watchdog_type
)
error
_context
.
context
(
"Add 'nmi_watchdog=%d' to guest kernel
"
"cmdline and reboot"
%
nmi_watchdog_type
)
session
.
cmd
(
update_kernel_cmd
)
time
.
sleep
(
int
(
params
.
get
(
"sleep_before_reset"
,
10
)))
session
=
vm
.
reboot
(
session
,
method
=
'shell'
,
timeout
=
timeout
)
try
:
error
.
context
(
"Getting guest's number of vcpus"
)
error
_context
.
context
(
"Getting guest's number of vcpus"
)
guest_cpu_num
=
session
.
cmd
(
params
[
"cpu_chk_cmd"
])
error
.
context
(
"Getting guest's NMI counter"
)
error
_context
.
context
(
"Getting guest's NMI counter"
)
output
=
session
.
cmd
(
get_nmi_cmd
)
logging
.
debug
(
output
.
strip
())
nmi_counter1
=
output
.
split
()[
1
:]
...
...
@@ -45,17 +46,17 @@ def run(test, params, env):
"increases"
)
time
.
sleep
(
60
)
error
.
context
(
"Getting guest's NMI counter 2nd time"
)
error
_context
.
context
(
"Getting guest's NMI counter 2nd time"
)
output
=
session
.
cmd
(
get_nmi_cmd
)
logging
.
debug
(
output
.
strip
())
nmi_counter2
=
output
.
split
()[
1
:]
error
.
context
(
""
)
error
_context
.
context
(
""
)
for
i
in
range
(
int
(
guest_cpu_num
)):
logging
.
info
(
"vcpu: %s, nmi_counter1: %s, nmi_counter2: %s"
%
(
i
,
nmi_counter1
[
i
],
nmi_counter2
[
i
]))
if
int
(
nmi_counter2
[
i
])
<=
int
(
nmi_counter1
[
i
]):
raise
error
.
TestF
ail
(
"Guest's NMI counter did not increase "
"after 60 seconds"
)
test
.
f
ail
(
"Guest's NMI counter did not increase "
"after 60 seconds"
)
finally
:
session
.
close
()
qemu/tests/nonexist_vcpu_hotplug.py
浏览文件 @
864c1fc6
import
logging
from
autotest.client.shared
import
error
from
virttest
import
error_context
from
virttest
import
utils_misc
@
error
.
context_aware
@
error
_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
NOTE: hotplug_vcpu is added since RHEL.6.3,
...
...
@@ -23,29 +22,30 @@ def run(test, params, env):
hotplug_cmd
=
"cpu_set %s online"
error
.
context
(
"boot the vm, with '-smp X,maxcpus=Y' option,"
"thus allow hotplug vcpu"
,
logging
.
info
)
error
_context
.
context
(
"boot the vm, with '-smp X,maxcpus=Y' option,"
"thus allow hotplug vcpu"
,
logging
.
info
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
error
.
context
(
"check if CPUs in guest matches qemu cmd "
"before hot-plug"
,
logging
.
info
)
error
_context
.
context
(
"check if CPUs in guest matches qemu cmd "
"before hot-plug"
,
logging
.
info
)
smp_by_cmd
=
int
(
params
.
get
(
"smp"
))
if
not
utils_misc
.
check_if_vm_vcpu_match
(
smp_by_cmd
,
vm
):
raise
error
.
TestE
rror
(
"CPU quantity mismatch cmd before hotplug !"
)
test
.
e
rror
(
"CPU quantity mismatch cmd before hotplug !"
)
# Start vCPU hotplug
error
.
context
(
"hotplugging non-existed vCPU..."
,
logging
.
info
)
error
_context
.
context
(
"hotplugging non-existed vCPU..."
,
logging
.
info
)
vcpus_need_hotplug
=
params
.
get
(
"nonexist_vcpu"
,
"-1 161"
).
split
(
" "
)
for
vcpu
in
vcpus_need_hotplug
:
try
:
error
.
context
(
"hot-pluging vCPU %s"
%
vcpu
,
logging
.
info
)
error
_context
.
context
(
"hot-pluging vCPU %s"
%
vcpu
,
logging
.
info
)
output
=
vm
.
monitor
.
send_args_cmd
(
hotplug_cmd
%
vcpu
)
finally
:
error
.
context
(
"output from monitor is: %s"
%
output
,
logging
.
info
)
error_context
.
context
(
"output from monitor is: %s"
%
output
,
logging
.
info
)
# Windows is a little bit lazy that needs more secs to recognize.
error
.
context
(
"hotplugging finished, let's wait a few sec and"
" check cpus quantity in guest."
,
logging
.
info
)
error
_context
.
context
(
"hotplugging finished, let's wait a few sec and"
" check cpus quantity in guest."
,
logging
.
info
)
if
not
utils_misc
.
wait_for
(
lambda
:
utils_misc
.
check_if_vm_vcpu_match
(
smp_by_cmd
,
vm
),
60
,
first
=
10
,
step
=
5.0
,
text
=
"retry later"
):
raise
error
.
TestF
ail
(
"CPU quantity mismatch cmd after hotplug !"
)
test
.
f
ail
(
"CPU quantity mismatch cmd after hotplug !"
)
qemu/tests/numa_consistency.py
浏览文件 @
864c1fc6
import
logging
import
resource
from
autotest.client.shared
import
error
from
autotest.client.shared
import
utils
from
avocado.utils
import
process
from
virttest
import
env_process
from
virttest
import
error_context
from
virttest
import
utils_misc
from
virttest
import
utils_test
from
virttest.staging
import
utils_memory
@
error
.
context_aware
@
error
_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Qemu numa consistency test:
...
...
@@ -33,13 +33,12 @@ def run(test, params, env):
in
numa_node_info
.
nodes
[
_
].
cpus
][
0
])
return
node_used_host
error
.
context
(
"Get host numa topological structure"
,
logging
.
info
)
error
_context
.
context
(
"Get host numa topological structure"
,
logging
.
info
)
timeout
=
float
(
params
.
get
(
"login_timeout"
,
240
))
host_numa_node
=
utils_misc
.
NumaInfo
()
node_list
=
host_numa_node
.
online_nodes
if
len
(
node_list
)
<
2
:
raise
error
.
TestNAError
(
"This host only has one NUMA node, "
"skipping test..."
)
test
.
cancel
(
"This host only has one NUMA node, skipping test..."
)
node_list
.
sort
()
params
[
'smp'
]
=
len
(
node_list
)
params
[
'vcpu_cores'
]
=
1
...
...
@@ -69,20 +68,22 @@ def run(test, params, env):
qemu_pid
=
vm
.
get_pid
()
drop
=
0
for
cpuid
in
range
(
len
(
vcpu_threads
)):
error
.
context
(
"Get vcpu %s used numa node."
%
cpuid
,
logging
.
info
)
error_context
.
context
(
"Get vcpu %s used numa node."
%
cpuid
,
logging
.
info
)
memory_status
,
_
=
utils_test
.
qemu
.
get_numa_status
(
host_numa_node
,
qemu_pid
)
node_used_host
=
get_vcpu_used_node
(
host_numa_node
,
vcpu_threads
[
cpuid
])
node_used_host_index
=
node_list
.
index
(
node_used_host
)
memory_used_before
=
memory_status
[
node_used_host_index
]
error
.
context
(
"Allocate memory in guest"
,
logging
.
info
)
error
_context
.
context
(
"Allocate memory in guest"
,
logging
.
info
)
session
.
cmd
(
mount_cmd
)
binded_dd_cmd
=
"taskset %s"
%
str
(
2
**
int
(
cpuid
))
binded_dd_cmd
+=
" dd if=/dev/urandom of=/tmp/%s"
%
cpuid
binded_dd_cmd
+=
" bs=1M count=%s"
%
dd_size
session
.
cmd
(
binded_dd_cmd
)
error
.
context
(
"Check qemu process memory use status"
,
logging
.
info
)
error_context
.
context
(
"Check qemu process memory use status"
,
logging
.
info
)
node_after
=
get_vcpu_used_node
(
host_numa_node
,
vcpu_threads
[
cpuid
])
if
node_after
!=
node_used_host
:
logging
.
warn
(
"Node used by vcpu thread changed. So drop the"
...
...
@@ -98,15 +99,14 @@ def run(test, params, env):
if
1
-
float
(
memory_allocated
)
/
float
(
dd_size
)
>
0.05
:
numa_hardware_cmd
=
params
.
get
(
"numa_hardware_cmd"
)
if
numa_hardware_cmd
:
numa_info
=
util
s
.
system_output
(
numa_hardware_cmd
,
ignore_status
=
True
)
numa_info
=
proces
s
.
system_output
(
numa_hardware_cmd
,
ignore_status
=
True
)
msg
=
"Expect malloc %sM memory in node %s,"
%
(
dd_size
,
node_used_host
)
msg
+=
"but only malloc %sM
\n
"
%
memory_allocated
msg
+=
"Please check more details of the numa node: %s"
%
numa_info
raise
error
.
TestF
ail
(
msg
)
test
.
f
ail
(
msg
)
session
.
close
()
if
drop
==
len
(
vcpu_threads
):
raise
error
.
TestError
(
"All test rounds are dropped."
" Please test it again."
)
test
.
error
(
"All test rounds are dropped. Please test it again."
)
qemu/tests/numa_opts.py
浏览文件 @
864c1fc6
import
logging
from
autotest.client.shared
import
error
logger
=
logging
.
getLogger
(
__name__
)
dbg
=
logger
.
debug
...
...
@@ -37,7 +36,7 @@ def run(test, params, env):
if
numa_nodes
:
numa_nodes
=
int
(
params
.
get
(
"numa_nodes"
))
if
len
(
numa
)
!=
numa_nodes
:
raise
error
.
TestF
ail
(
test
.
f
ail
(
"Wrong number of numa nodes: %d. Expected: %d"
%
(
len
(
numa
),
numa_nodes
))
...
...
@@ -46,7 +45,7 @@ def run(test, params, env):
if
size
is
not
None
:
size
=
int
(
size
)
if
size
!=
numa
[
nodenr
][
0
]:
raise
error
.
TestF
ail
(
test
.
f
ail
(
"Wrong size of numa node %d: %d. Expected: %d"
%
(
nodenr
,
numa
[
nodenr
][
0
],
size
))
...
...
@@ -54,6 +53,6 @@ def run(test, params, env):
if
cpus
is
not
None
:
cpus
=
set
([
int
(
v
)
for
v
in
cpus
.
split
()])
if
cpus
!=
numa
[
nodenr
][
1
]:
raise
error
.
TestF
ail
(
test
.
f
ail
(
"Wrong CPU set on numa node %d: %s. Expected: %s"
%
(
nodenr
,
numa
[
nodenr
][
1
],
cpus
))
qemu/tests/numa_stress.py
浏览文件 @
864c1fc6
...
...
@@ -2,9 +2,9 @@ import os
import
re
import
logging
from
autotest.client.shared
import
error
from
autotest.client
import
utils
from
avocado.utils
import
process
from
virttest
import
error_context
from
virttest
import
utils_misc
from
virttest
import
funcatexit
from
virttest
import
utils_test
...
...
@@ -41,19 +41,21 @@ def get_tmpfs_write_speed():
Get the tmpfs write speed of the host
return: The write speed of tmpfs, the unit is kb/s.
"""
utils
.
run
(
"mkdir -p /tmp/test_speed && mount -t tmpfs none /tmp/test_speed"
)
output
=
utils
.
run
(
"dd if=/dev/urandom of=/tmp/test_speed/test bs=1k count=1024"
)
process
.
run
(
"mkdir -p /tmp/test_speed && "
"mount -t tmpfs none /tmp/test_speed"
)
output
=
process
.
run
(
"dd if=/dev/urandom of=/tmp/test_speed/test "
"bs=1k count=1024"
)
try
:
speed
=
re
.
search
(
"\s([\w\s\.]+)/s"
,
output
.
stderr
,
re
.
I
).
group
(
1
)
return
float
(
utils_misc
.
normalize_data_size
(
speed
,
'K'
,
1024
))
except
Exception
:
return
3072
finally
:
util
s
.
run
(
"umount /tmp/test_speed"
)
proces
s
.
run
(
"umount /tmp/test_speed"
)
os
.
removedirs
(
"/tmp/test_speed"
)
@
error
.
context_aware
@
error
_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Qemu numa stress test:
...
...
@@ -70,8 +72,7 @@ def run(test, params, env):
"""
host_numa_node
=
utils_misc
.
NumaInfo
()
if
len
(
host_numa_node
.
online_nodes
)
<
2
:
raise
error
.
TestNAError
(
"Host only has one NUMA node, "
"skipping test..."
)
test
.
cancel
(
"Host only has one NUMA node, skipping test..."
)
timeout
=
float
(
params
.
get
(
"login_timeout"
,
240
))
test_count
=
int
(
params
.
get
(
"test_count"
,
4
))
...
...
@@ -100,8 +101,8 @@ def run(test, params, env):
utils_memory
.
drop_caches
()
if
utils_memory
.
freememtotal
()
<
tmpfs_size
:
raise
error
.
TestNAError
(
"Host does not have enough free memory to run the test, "
"skipping test..."
)
test
.
cancel
(
"Host does not have enough free memory to run the test, "
"skipping test..."
)
if
not
os
.
path
.
isdir
(
tmpfs_path
):
os
.
mkdir
(
tmpfs_path
)
...
...
@@ -114,33 +115,33 @@ def run(test, params, env):
os
.
remove
(
memory_file
)
utils_memory
.
drop_caches
()
if
utils_memory
.
freememtotal
()
<
tmpfs_size
:
raise
error
.
TestE
rror
(
"Don't have enough memory to execute this "
"test after %s round"
%
test_round
)
error
.
context
(
"Executing stress test round: %s"
%
test_round
,
logging
.
info
)
test
.
e
rror
(
"Don't have enough memory to execute this "
"test after %s round"
%
test_round
)
error
_context
.
context
(
"Executing stress test round: %s"
%
test_round
,
logging
.
info
)
numa_node_malloc
=
most_used_node
numa_dd_cmd
=
"numactl -m %s %s"
%
(
numa_node_malloc
,
dd_cmd
)
error
.
context
(
"Try to allocate memory in node %s"
%
numa_node_malloc
,
logging
.
info
)
error
_context
.
context
(
"Try to allocate memory in node %s"
%
numa_node_malloc
,
logging
.
info
)
try
:
utils_misc
.
mount
(
"none"
,
tmpfs_path
,
"tmpfs"
,
perm
=
mount_fs_size
)
funcatexit
.
register
(
env
,
params
.
get
(
"type"
),
utils_misc
.
umount
,
"none"
,
tmpfs_path
,
"tmpfs"
)
util
s
.
system
(
numa_dd_cmd
,
timeout
=
dd_timeout
)
proces
s
.
system
(
numa_dd_cmd
,
timeout
=
dd_timeout
)
except
Exception
,
error_msg
:
if
"No space"
in
str
(
error_msg
):
pass
else
:
raise
error
.
TestF
ail
(
"Can not allocate memory in node %s."
" Error message:%s"
%
(
numa_node_malloc
,
str
(
error_msg
)))
error
.
context
(
"Run memory heavy stress in guest"
,
logging
.
info
)
test
.
f
ail
(
"Can not allocate memory in node %s."
" Error message:%s"
%
(
numa_node_malloc
,
str
(
error_msg
)))
error
_context
.
context
(
"Run memory heavy stress in guest"
,
logging
.
info
)
autotest_control
.
run
(
test
,
params
,
env
)
error
.
context
(
"Get the qemu process memory use status"
,
logging
.
info
)
error_context
.
context
(
"Get the qemu process memory use status"
,
logging
.
info
)
node_after
,
memory_after
=
max_mem_map_node
(
host_numa_node
,
qemu_pid
)
if
node_after
==
most_used_node
and
memory_after
>=
memory_used
:
raise
error
.
TestFail
(
"Memory still stick in "
"node %s"
%
numa_node_malloc
)
test
.
fail
(
"Memory still stick in node %s"
%
numa_node_malloc
)
else
:
most_used_node
=
node_after
memory_used
=
memory_after
...
...
qemu/tests/nx.py
浏览文件 @
864c1fc6
import
os
import
logging
from
autotest.client.shared
import
error
from
virttest
import
data_dir
from
virttest
import
error_context
@
error
.
context_aware
@
error
_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
try to exploit the guest to test whether nx(cpu) bit takes effect.
...
...
@@ -29,17 +28,17 @@ def run(test, params, env):
exploit_file
=
os
.
path
.
join
(
data_dir
.
get_deps_dir
(),
'nx'
,
'x64_sc_rdo.c'
)
dst_dir
=
'/tmp'
error
.
context
(
"Copy the Exploit file to guest."
,
logging
.
info
)
error
_context
.
context
(
"Copy the Exploit file to guest."
,
logging
.
info
)
vm
.
copy_files_to
(
exploit_file
,
dst_dir
)
error
.
context
(
"Build exploit program in guest."
,
logging
.
info
)
error
_context
.
context
(
"Build exploit program in guest."
,
logging
.
info
)
build_exploit
=
"gcc -o /tmp/nx_exploit /tmp/x64_sc_rdo.c"
if
session
.
cmd_status
(
build_exploit
):
raise
error
.
TestE
rror
(
"Failed to build the exploit program"
)
test
.
e
rror
(
"Failed to build the exploit program"
)
exploit_cmd
=
"/tmp/nx_exploit"
error
.
context
(
"Run exploit program in guest."
,
logging
.
info
)
error
_context
.
context
(
"Run exploit program in guest."
,
logging
.
info
)
# if nx is enabled (by default), the program failed.
# segmentation error. return value of shell is not zero.
exec_res
=
session
.
cmd_status
(
exploit_cmd
)
...
...
@@ -47,25 +46,25 @@ def run(test, params, env):
if
nx_on
==
'yes'
:
if
exec_res
:
logging
.
info
(
'NX works good.'
)
error
.
context
(
"Using execstack to remove the protection."
,
logging
.
info
)
error
_context
.
context
(
"Using execstack to remove the protection."
,
logging
.
info
)
enable_exec
=
'execstack -s %s'
%
exploit_cmd
if
session
.
cmd_status
(
enable_exec
):
if
session
.
cmd_status
(
"execstack --help"
):
msg
=
"Please make sure guest have execstack command."
raise
error
.
TestE
rror
(
msg
)
raise
error
.
TestE
rror
(
'Failed to enable the execstack'
)
test
.
e
rror
(
msg
)
test
.
e
rror
(
'Failed to enable the execstack'
)
if
session
.
cmd_status
(
exploit_cmd
):
raise
error
.
TestF
ail
(
'NX is still protecting. Error.'
)
test
.
f
ail
(
'NX is still protecting. Error.'
)
else
:
logging
.
info
(
'NX is disabled as desired. good'
)
else
:
raise
error
.
TestF
ail
(
'Fatal Error: NX does not protect anything!'
)
test
.
f
ail
(
'Fatal Error: NX does not protect anything!'
)
else
:
if
exec_res
:
msg
=
"qemu fail to disable 'nx' flag or the exploit is corrupted."
raise
error
.
TestE
rror
(
msg
)
test
.
e
rror
(
msg
)
else
:
logging
.
info
(
'NX is disabled, and this Test Case passed.'
)
if
session
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录