Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
4336ef6a
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,发现更多精彩内容 >>
提交
4336ef6a
编写于
11月 11, 2013
作者:
L
Lucas Meneghel Rodrigues
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #974 from xutian/add_timedrift_case
qemu.tests: new case to check guest clock offset
上级
9e7addfb
8b91841e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
300 addition
and
7 deletion
+300
-7
qemu/tests/cfg/cpu_add.cfg
qemu/tests/cfg/cpu_add.cfg
+24
-0
qemu/tests/cfg/timedrift_check_clock_offset.cfg
qemu/tests/cfg/timedrift_check_clock_offset.cfg
+36
-0
qemu/tests/cfg/timerdevice.cfg
qemu/tests/cfg/timerdevice.cfg
+10
-0
qemu/tests/cpu_add.py
qemu/tests/cpu_add.py
+51
-7
qemu/tests/timedrift_check_when_crash.py
qemu/tests/timedrift_check_when_crash.py
+96
-0
qemu/tests/timedrift_check_with_syscall.py
qemu/tests/timedrift_check_with_syscall.py
+48
-0
qemu/tests/timerdevice_kvmclock_newer_msrs_support.py
qemu/tests/timerdevice_kvmclock_newer_msrs_support.py
+35
-0
未找到文件。
qemu/tests/cfg/cpu_add.cfg
浏览文件 @
4336ef6a
...
...
@@ -102,3 +102,27 @@
vcpu_need_hotplug = 100
offline = 1-100
online = 1-100
- check_clock:
# check guest clock offset before switch vcpus status
only Linux
requires_root = yes
smp = 1
repeat_time = 1
acceptable_offset = 5
vcpu_need_hotplug = 1
online = 1
offline = 1
vcpu_num_rechek = no
ntp_server = "clock.redhat.com"
pre_command = "ntpdate ${ntp_server}"
ntp_sync_cmd = "ntpdate ${ntp_server}"
ntp_query_cmd = "ntpdate -q ${ntp_server}"
ntp_service_stop_cmd = "service chronyd stop || service ntpdate stop"
variants:
- after_10mins:
# seconds switch vcpus between online and offline
onoff_iterations = 600
- after_20mins:
onoff_iterations = 1200
- after_30mins:
onoff_iterations = 1800
qemu/tests/cfg/timedrift_check_clock_offset.cfg
0 → 100644
浏览文件 @
4336ef6a
- check_clock_offset:
rtc_clock = host
rtc_base = utc
rtc_drift = slew
requires_root = yes
variants:
- with_syscall:
type = timedrift_check_with_syscall
start_vm = yes
only Linux
no JeOS
tmp_dir = "/tmp"
result_file = "clktest.log"
build_cmd = "gcc -lrt ${tmp_dir}/clktest.c -o clktest"
test_cmd = "./clktest"
check_timeout = 300
- when_crash:
type = timedrift_check_when_crash
start_vm = no
ntp_server = "clock.redhat.com"
sleep_time = 1800
variants:
- bsod:
only Windows
nmi_cmd = "monitor:inject-nmi"
ntp_cmd = "sc start w32time && ping -n 6 -w 1000 127.0.0.1>nul && w32tm /config /manualpeerlist:${ntp_server} /syncfromflags:manual /update"
ntp_query_cmd = "w32tm /stripchart /computer:${ntp_server} /samples:1 /dataonly"
- hang:
kill_vm = yes
# Notes:
# please stop kernel crash recovery service like 'kdump' before trigger kernek panic,
# else guest will reboot immedicately that is unexpected in this test;
only Linux
nmi_cmd = "guest: echo '1' > /proc/sys/kernel/sysrq && echo '0' > /proc/sys/kernel/panic && service kdump stop; echo 'c' > /proc/sysrq-trigger"
ntp_cmd = "ntpdate ${ntp_server}"
ntp_query_cmd = "ntpdate -q ${ntp_server}"
qemu/tests/cfg/timerdevice.cfg
浏览文件 @
4336ef6a
...
...
@@ -88,3 +88,13 @@
vcpu_socket = 1
- two_sockets:
vcpu_socket = 2
- newer_msrs_support_check:
only Linux
no Host_RHEL.3,4,5 Host_RHEL.6.0
no RHEL.3,4,5 RHEL.6.0,1,2,3
type = timerdevice_kvmclock_newer_msrs_support
rtc_base = utc
rtc_clock = host
rtc_drift = slew
msrs = "4b564d01 4b564d00"
msrs_catch_re = "kvm-clock: Using msrs (\w+) and (\w+)"
qemu/tests/cpu_add.py
浏览文件 @
4336ef6a
...
...
@@ -10,20 +10,35 @@ def run_cpu_add(test, params, env):
"""
Runs CPU hotplug test:
0) sync host clock via ntp server
1) Boot the vm with -smp X,maxcpus=Y
2) After logged into the vm, check CPUs number
3) Stop the guest if config 'stop_before_hotplug'
4) Do cpu hotplug
5) Resume the guest if config 'stop_before_hotplug'
6) Recheck guest get hot-pluged CPUs
7) Do cpu online/offline in guest if config
8) Run sub test after CPU Hotplug
9) Recheck guest cpus after sub test
4) sync guest clock via ntp server if config ntp_sync_cmd
5) stop ntp service in guest if config ntp_service_stop_cmd
6) Do cpu hotplug
7) Resume the guest if config 'stop_before_hotplug'
8) Recheck guest get hot-pluged CPUs
9) Do cpu online/offline in guest and check clock
offset via ntp server if config online/offline_cpus
10) Run sub test after CPU Hotplug if run_sub_test is 'yes'
11) Recheck guest cpus after sub test if vcpu_num_rechek is 'yes'
:param test: QEMU test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
def
get_clock_offset
(
session
,
ntp_query_cmd
):
"""
Get guest clock offset between ntp service;
"""
output
=
session
.
cmd_output
(
ntp_query_cmd
)
try
:
offset
=
float
(
re
.
findall
(
r
"[+-](\d+\.\d+)"
,
output
)[
-
1
])
except
IndexError
:
offset
=
0.0
return
offset
def
qemu_guest_cpu_match
(
vm
,
vcpu_been_pluged
=
0
,
wait_time
=
60
):
"""
Check Whether the vcpus are matche
...
...
@@ -76,6 +91,10 @@ def run_cpu_add(test, params, env):
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
onoff_iterations
=
int
(
params
.
get
(
"onoff_iterations"
,
2
))
vcpu_need_hotplug
=
int
(
params
.
get
(
"vcpu_need_hotplug"
,
1
))
acceptable_offset
=
float
(
params
.
get
(
"acceptable_offset"
,
5
))
ntp_query_cmd
=
params
.
get
(
"ntp_query_cmd"
,
""
)
ntp_sync_cmd
=
params
.
get
(
"ntp_sync_cmd"
,
""
)
ntp_service_stop_cmd
=
params
.
get
(
"ntp_service_stop_cmd"
)
error
.
context
(
"Boot the vm, with '-smp X,maxcpus=Y' option"
,
logging
.
info
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
...
...
@@ -83,6 +102,13 @@ def run_cpu_add(test, params, env):
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
maxcpus
=
vm
.
cpuinfo
.
maxcpus
if
ntp_sync_cmd
:
error
.
context
(
"sync guest time via ntp server"
,
logging
.
info
)
session
.
cmd
(
ntp_sync_cmd
)
if
ntp_service_stop_cmd
:
logging
.
info
(
"stop ntp service in guest"
)
session
.
cmd
(
ntp_service_stop_cmd
)
error
.
context
(
"Check if cpus in guest matche qemu cmd before hotplug"
,
logging
.
info
)
qemu_guest_cpu_match
(
vm
)
...
...
@@ -147,7 +173,7 @@ def run_cpu_add(test, params, env):
logging
.
debug
(
"The error info is:
\n
'%s'"
%
output
)
raise
error
.
TestFail
(
err_msg
)
if
stop_before_hotplug
:
if
stop_before_hotplug
==
"yes"
:
error
.
context
(
"Resume the guest after cpu hotplug"
,
logging
.
info
)
vm
.
resume
()
...
...
@@ -182,10 +208,28 @@ def run_cpu_add(test, params, env):
for
i
in
range
(
repeat_time
):
for
offline_cpu
in
offline_list
:
cpu_online_offline
(
session
,
offline_cpu
)
logging
.
info
(
"sleep %s seconds"
,
onoff_iterations
)
time
.
sleep
(
onoff_iterations
)
if
ntp_query_cmd
:
error
.
context
(
"Check guest clock after online cpu"
,
logging
.
info
)
current_offset
=
get_clock_offset
(
session
,
ntp_query_cmd
)
if
current_offset
>
acceptable_offset
:
raise
error
.
TestFail
(
"time drift(%ss)"
%
current_offset
+
"after online cpu(%s)"
%
offline_cpu
)
for
online_cpu
in
online_list
:
cpu_online_offline
(
session
,
online_cpu
,
"online"
)
logging
.
info
(
"sleep %s seconds"
,
onoff_iterations
)
time
.
sleep
(
onoff_iterations
)
if
ntp_query_cmd
:
error
.
context
(
"Check guest clock after offline cpu"
,
logging
.
info
)
current_offset
=
get_clock_offset
(
session
,
ntp_query_cmd
)
if
current_offset
>
acceptable_offset
:
raise
error
.
TestFail
(
"time drift(%s)"
%
current_offset
+
"after offline cpu(%s)"
%
online_cpu
)
# do sub test after cpu hotplug
if
(
params
.
get
(
"run_sub_test"
,
"no"
)
==
"yes"
and
...
...
qemu/tests/timedrift_check_when_crash.py
0 → 100644
浏览文件 @
4336ef6a
import
logging
import
time
import
re
from
autotest.client.shared
import
error
from
autotest.client.shared
import
utils
from
virttest.env_process
import
preprocess
from
virttest.virt_vm
import
VMDeadKernelCrashError
@
error
.
context_aware
def
run_timedrift_check_when_crash
(
test
,
params
,
env
):
"""
Time clock offset check when guest crash/bsod test:
1) boot guest with '-rtc base=utc,clock=host,driftfix=slew';
2) sync host system time with "ntpdate clock.redhat.com";
3) inject nmi to guest/ make linux kernel crash;
4) sleep long time, then reset vm via system_reset;
5) query clock offset from ntp server;
:param test: QEMU test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
ntp_server
=
params
.
get
(
"ntp_server"
,
"clock.redhat.com"
)
ntp_cmd
=
params
[
"ntp_cmd"
]
ntp_query_cmd
=
params
[
"ntp_query_cmd"
]
nmi_cmd
=
params
.
get
(
"nmi_cmd"
,
"inject-nmi"
)
sleep_time
=
float
(
params
.
get
(
"sleep_time"
,
1800
))
deviation
=
float
(
params
.
get
(
"deviation"
,
5
))
error
.
context
(
"sync host time with ntp server"
,
logging
.
info
)
utils
.
system
(
"ntpdate %s"
%
ntp_server
)
error
.
context
(
"start guest"
,
logging
.
info
)
params
[
"start_vm"
]
=
"yes"
preprocess
(
test
,
params
,
env
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
error
.
context
(
"sync time in guest"
,
logging
.
info
)
session
.
cmd
(
ntp_cmd
)
error
.
context
(
"inject nmi interupt in vm"
,
logging
.
info
)
target
,
cmd
=
re
.
split
(
"\s*:\s*"
,
nmi_cmd
)
if
target
==
"monitor"
:
vm
.
monitor
.
send_args_cmd
(
cmd
)
else
:
session
.
sendline
(
cmd
)
try
:
session
.
cmd
(
"dir"
)
except
Exception
:
pass
else
:
raise
error
.
TestFail
(
"Guest OS still alive ..."
)
error
.
context
(
"sleep %s seconds"
%
sleep_time
,
logging
.
info
)
time
.
sleep
(
sleep_time
)
# Autotest parses serial output and could raise VMDeadKernelCrash
# we generated using sysrq. Ignore one "BUG:" line
try
:
session
=
vm
.
reboot
(
method
=
"system_reset"
)
except
VMDeadKernelCrashError
,
details
:
details
=
str
(
details
)
if
(
re
.
findall
(
r
"Trigger a crash\s.*BUG:"
,
details
,
re
.
M
)
and
details
.
count
(
"BUG:"
)
!=
1
):
raise
error
.
TestFail
(
"Got multiple kernel crashes. Please "
"note that one of them was "
"intentionally generated by sysrq in "
"this test.
\n
%s"
%
details
)
end_time
=
time
.
time
()
+
timeout
while
time
.
time
()
<
end_time
:
try
:
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
except
VMDeadKernelCrashError
,
details
:
details
=
str
(
details
)
if
(
re
.
findall
(
r
"Trigger a crash\s.*BUG:"
,
details
,
re
.
M
)
and
details
.
count
(
"BUG:"
)
!=
1
):
raise
error
.
TestFail
(
"Got multiple kernel crashes. "
"Please note that one of them was "
"intentionally generated by sysrq "
"in this test.
\n
%s"
%
details
)
else
:
break
error
.
context
(
"check time offset via ntp"
,
logging
.
info
)
output
=
session
.
cmd_output
(
ntp_query_cmd
)
try
:
offset
=
re
.
findall
(
r
"[+-](\d+\.\d+)"
,
output
,
re
.
M
)[
-
1
]
except
IndexError
:
offset
=
0.0
if
float
(
offset
)
>
deviation
:
raise
error
.
TestFail
(
"Unacceptable offset '%s', "
%
offset
+
"deviation '%s'"
%
deviation
)
qemu/tests/timedrift_check_with_syscall.py
0 → 100644
浏览文件 @
4336ef6a
import
os
import
logging
from
autotest.client.shared
import
error
from
virttest
import
aexpect
from
virttest
import
data_dir
@
error
.
context_aware
def
run_timedrift_check_with_syscall
(
test
,
params
,
env
):
"""
Time clock offset check test (only for Linux guest):
1) boot guest with '-rtc base=utc,clock=host,driftfix=slew'
2) build binary 'clktest' in guest
3) check clock offset with ./clktest
:param test: QEMU test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
build_cmd
=
params
.
get
(
"build_cmd"
,
"gcc -lrt clktest.c -o clktest"
)
test_cmd
=
params
.
get
(
"test_cmd"
,
"./clktest"
)
check_timeout
=
int
(
params
.
get
(
"check_timeout"
,
"600"
))
tmp_dir
=
params
.
get
(
"tmp_dir"
,
"/tmp"
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
src_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
data_dir
.
get_data_dir
()),
"deps"
)
src_file
=
os
.
path
.
join
(
src_dir
,
"clktest.c"
)
dst_file
=
os
.
path
.
join
(
tmp_dir
,
"clktest.c"
)
error
.
context
(
"transfer '%s' to guest('%s')"
%
(
src_file
,
dst_file
),
logging
.
info
)
vm
.
copy_files_to
(
src_file
,
tmp_dir
,
timeout
=
120
)
error
.
context
(
"build binary file 'clktest'"
,
logging
.
info
)
session
.
cmd
(
build_cmd
)
error
.
context
(
"check clock offset via `clktest`"
,
logging
.
info
)
logging
.
info
(
"set check timeout to %s seconds"
,
check_timeout
)
try
:
session
.
cmd_output
(
test_cmd
,
timeout
=
check_timeout
)
except
aexpect
.
ShellTimeoutError
,
msg
:
if
'Interval is'
in
msg
.
output
:
raise
error
.
TestFail
(
msg
.
output
)
pass
qemu/tests/timerdevice_kvmclock_newer_msrs_support.py
0 → 100644
浏览文件 @
4336ef6a
import
re
import
logging
from
autotest.client.shared
import
error
@
error
.
context_aware
def
run_timerdevice_kvmclock_newer_msrs_support
(
test
,
params
,
env
):
"""
check kvm-clock using newer msrs test (only for Linux guest):
1) boot guest with '-rtc base=utc,clock=host,driftfix=slew'
2) verify guest using newer msrs set
:param test: QEMU test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
msrs
=
str
(
params
[
"msrs"
]).
split
()
dmesg
=
str
(
session
.
cmd_output
(
"dmesg"
))
msrs_catch_re
=
params
.
get
(
"msrs_catch_re"
,
"kvm-clock: Using msrs (\w+) and (\w+)"
)
current_msrs
=
re
.
search
(
r
"%s"
%
msrs_catch_re
,
dmesg
,
re
.
M
|
re
.
I
)
if
current_msrs
:
current_msrs
=
set
(
current_msrs
.
groups
())
if
current_msrs
!=
set
(
msrs
):
raise
error
.
TestFail
(
"Except msrs (%s), "
%
msrs
+
"got (%s)"
%
current_msrs
)
else
:
logging
.
debug
(
dmesg
)
raise
error
.
TestFail
(
"No newer msr available for kvm-clock"
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录