Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
43cacc61
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,发现更多精彩内容 >>
未验证
提交
43cacc61
编写于
12月 03, 2018
作者:
Q
Qianqian Zhu
提交者:
GitHub
12月 03, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1240 from sitoliu/timerdevice_feat
timerdevice: add cases
上级
2934f8df
fff5260a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
339 addition
and
1 deletion
+339
-1
qemu/tests/cfg/timedrift_check_clock_offset.cfg
qemu/tests/cfg/timedrift_check_clock_offset.cfg
+28
-0
qemu/tests/cfg/timerdevice.cfg
qemu/tests/cfg/timerdevice.cfg
+29
-1
qemu/tests/timedrift_check_non_event.py
qemu/tests/timedrift_check_non_event.py
+86
-0
qemu/tests/timedrift_check_when_hotplug_vcpu.py
qemu/tests/timedrift_check_when_hotplug_vcpu.py
+61
-0
qemu/tests/timerdevice_host_time_back.py
qemu/tests/timerdevice_host_time_back.py
+72
-0
qemu/tests/timerdevice_time_jump_check.py
qemu/tests/timerdevice_time_jump_check.py
+63
-0
未找到文件。
qemu/tests/cfg/timedrift_check_clock_offset.cfg
浏览文件 @
43cacc61
...
@@ -37,3 +37,31 @@
...
@@ -37,3 +37,31 @@
ntp_cmd = "(systemctl stop chronyd || service ntpdate stop)"
ntp_cmd = "(systemctl stop chronyd || service ntpdate stop)"
ntp_cmd += " && chronyd -q 'server clock.redhat.com iburst'"
ntp_cmd += " && chronyd -q 'server clock.redhat.com iburst'"
ntp_query_cmd = "chronyd -Q 'server clock.redhat.com iburst'"
ntp_query_cmd = "chronyd -Q 'server clock.redhat.com iburst'"
- hotplug_vcpu:
type = timedrift_check_when_hotplug_vcpu
start_vm = yes
vcpu_sockets = 2
smp = 4
vcpus_maxcpus = 6
ntp_query_cmd = "chronyd -Q 'server clock.redhat.com iburst'"
clock_sync_command = "(systemctl stop chronyd || service ntpdate stop)"
clock_sync_command += " && chronyd -q 'server clock.redhat.com iburst'"
query_internal = 600
query_times = 4
drift_threshold = 3
- non_event:
only RHEL
type = timedrift_check_non_event
start_vm = yes
monitor_type = qmp
hwclock_time_command = "LC_TIME=C hwclock -u"
hwclock_time_filter_re = "(\d+-\d+-\d+ \d+:\d+:\d+).*"
hwclock_time_format = "%Y-%m-%d %H:%M:%S"
RHEL.7:
hwclock_time_filter_re = "(\S+ \S+\s+\d+ \d+:\d+:\d+ \d+).*"
hwclock_time_format = "%a %b %d %H:%M:%S %Y"
time_forward = 3600
hwclock_forward_cmd = 'hwclock --set --date "${time_forward} seconds"'
clock_sync_command = "(systemctl stop chronyd || service ntpdate stop)"
clock_sync_command += " && chronyd -q 'server clock.redhat.com iburst'"
drift_threshold = 3
qemu/tests/cfg/timerdevice.cfg
浏览文件 @
43cacc61
...
@@ -107,7 +107,7 @@
...
@@ -107,7 +107,7 @@
vcpu_socket = 2
vcpu_socket = 2
- newer_msrs_support_check:
- newer_msrs_support_check:
only Linux
only Linux
no Host_RHEL.m
5 Host_RHEL.m
6.u0
no Host_RHEL.m6.u0
no RHEL.6.0 RHEL.6.1 RHEL.6.2 RHEL.6.3
no RHEL.6.0 RHEL.6.1 RHEL.6.2 RHEL.6.3
type = timerdevice_kvmclock_newer_msrs_support
type = timerdevice_kvmclock_newer_msrs_support
rtc_base = utc
rtc_base = utc
...
@@ -116,3 +116,31 @@
...
@@ -116,3 +116,31 @@
rtc_drift = slew
rtc_drift = slew
msrs = "4b564d01 4b564d00"
msrs = "4b564d01 4b564d00"
msrs_catch_re = "kvm-clock: Using msrs (\w+) and (\w+)"
msrs_catch_re = "kvm-clock: Using msrs (\w+) and (\w+)"
- measure_time_jump:
only Linux
type = timerdevice_time_jump_check
rtc_base = utc
rtc_clock = host
i386, x86_64:
rtc_drift = slew
check_cmd = "for i in `seq 20`; do date +'%y-%m-%d %H:%M:%S';done"
host_cpu_cnt_cmd = "cat /proc/cpuinfo | grep "physical id" | wc -l"
- set_time_back:
only Linux
type = timerdevice_host_time_back
ntp_server = clock.redhat.com
clock_sync_command = "(systemctl stop chronyd || service ntpdate stop)"
clock_sync_command += " && chronyd -q 'server clock.redhat.com iburst'"
rtc_base = utc
rtc_clock = host
i386, x86_64:
rtc_drift = slew
extra_param = '-global kvm-pit.lost_tick_policy=discard'
seconds_to_back = 1800
set_host_time_back_cmd = 'date -s "-${seconds_to_back} seconds"'
epoch_time_cmd = 'epoch=$(date +%s); datetime=$(date);'
epoch_time_cmd += 'echo "datetime: $datetime epoch: $epoch"'
tolerance = 3.0
# when host time set back, guest time should start from continue
# after rebooting, not same with host system time
time_difference = ${seconds_to_back}
qemu/tests/timedrift_check_non_event.py
0 → 100644
浏览文件 @
43cacc61
import
logging
import
re
import
time
from
avocado.utils
import
process
from
virttest
import
error_context
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Check guest offset in non-event way.
1) sync host system time with ntp server
2) boot guest with '-rtc base=utc,clock=host,driftfix=slew'
3) get output of "qom-get" command
4) read RTC time inside guest
5) adjust RTC time forward 1 hour in guest
6) verify output of "qom-get"
:param test: QEMU test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
def
get_hwtime
(
session
):
"""
Get guest's hardware clock in epoch.
:param session: VM session.
"""
hwclock_time_command
=
params
.
get
(
"hwclock_time_command"
,
"hwclock -u"
)
hwclock_time_filter_re
=
params
.
get
(
"hwclock_time_filter_re"
,
r
"(\d+-\d+-\d+ \d+:\d+:\d+).*"
)
hwclock_time_format
=
params
.
get
(
"hwclock_time_format"
,
"%Y-%m-%d %H:%M:%S"
)
output
=
session
.
cmd_output_safe
(
hwclock_time_command
)
try
:
str_time
=
re
.
findall
(
hwclock_time_filter_re
,
output
)[
0
]
guest_time
=
time
.
mktime
(
time
.
strptime
(
str_time
,
hwclock_time_format
))
except
Exception
as
err
:
logging
.
debug
(
"(time_format, output): (%s, %s)"
,
hwclock_time_format
,
output
)
raise
err
return
guest_time
clock_sync_command
=
params
[
"clock_sync_command"
]
error_context
.
context
(
"Sync host system time with ntpserver"
,
logging
.
info
)
process
.
system
(
clock_sync_command
,
shell
=
True
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
session
=
vm
.
wait_for_login
()
hwclock_forward_cmd
=
params
[
"hwclock_forward_cmd"
]
time_forward
=
params
[
"time_forward"
]
drift_threshold
=
params
[
"drift_threshold"
]
error_context
.
context
(
"Get output of qom_get"
,
logging
.
info
)
qom_st1
=
vm
.
monitor
.
qom_get
(
"/machine"
,
"rtc-time"
)
error_context
.
context
(
"Get hardware time of guest"
,
logging
.
info
)
hwclock_st1
=
get_hwtime
(
session
)
logging
.
debug
(
"hwclock: guest time=%ss"
,
hwclock_st1
)
error_context
.
context
(
"Adjust guest hardware time forward 1 hour"
,
logging
.
info
)
session
.
cmd
(
hwclock_forward_cmd
,
timeout
=
120
)
error_context
.
context
(
"Verify output of qom-get"
,
logging
.
info
)
qom_st2
=
vm
.
monitor
.
qom_get
(
"/machine"
,
"rtc-time"
)
qom_gap
=
int
(
qom_st2
[
"tm_hour"
])
-
int
(
qom_st1
[
"tm_hour"
])
if
(
qom_gap
<
1
)
or
(
qom_gap
>
2
):
test
.
fail
(
"Unexpected offset in qom-get, "
"qom-get result before change guest's RTC time: %s, "
"qom-get result after change guest's RTC time: %s"
%
(
qom_st1
,
qom_st2
))
error_context
.
context
(
"Verify guest hardware time"
,
logging
.
info
)
hwclock_st2
=
get_hwtime
(
session
)
logging
.
debug
(
"hwclock: guest time=%ss"
,
hwclock_st2
)
session
.
close
()
if
(
hwclock_st1
-
hwclock_st2
-
float
(
time_forward
))
>
float
(
drift_threshold
):
test
.
fail
(
"Unexpected hwclock drift, "
"hwclock: current guest time=%ss"
%
hwclock_st2
)
qemu/tests/timedrift_check_when_hotplug_vcpu.py
0 → 100644
浏览文件 @
43cacc61
import
re
import
time
import
logging
from
avocado.utils
import
process
from
virttest
import
error_context
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Check time offset after hotplug a vcpu.
1) sync host time with ntpserver
2) boot guest with '-rtc base=utc,clock=host,driftfix=slew'
3) stop auto sync service in guest (rhel7 only)
4) sync guest system time with ntpserver
5) hotplug a vcpu by qmp command
6) query guest time offset with ntpserver for several times
:param test: QEMU test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
clock_sync_command
=
params
[
"clock_sync_command"
]
error_context
.
context
(
"Sync host system time with ntpserver"
,
logging
.
info
)
process
.
system
(
clock_sync_command
,
shell
=
True
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
session
=
vm
.
wait_for_login
()
ntp_query_cmd
=
params
.
get
(
"ntp_query_cmd"
,
""
)
query_times
=
int
(
params
.
get
(
"query_times"
,
"4"
))
query_internal
=
float
(
params
.
get
(
"query_internal"
,
"600"
))
drift_threshold
=
float
(
params
.
get
(
"drift_threshold"
,
"3"
))
error_context
.
context
(
"Sync time from guest to ntpserver"
,
logging
.
info
)
session
.
cmd
(
clock_sync_command
)
error_context
.
context
(
"Hotplug a vcpu to guest"
,
logging
.
info
)
if
int
(
params
[
"smp"
])
<
int
(
params
[
"vcpus_maxcpus"
]):
vm
.
hotplug_vcpu
()
time
.
sleep
(
1
)
else
:
test
.
error
(
"Invalid operation, valid index range 0:%d, used range 0:%d"
%
(
int
(
params
[
"vcpus_maxcpus"
])
-
1
,
int
(
params
[
"smp"
])
-
1
))
error_context
.
context
(
"Check time offset via ntp server"
,
logging
.
info
)
for
query
in
range
(
query_times
):
output
=
session
.
cmd_output
(
ntp_query_cmd
)
try
:
offset
=
re
.
findall
(
r
"([+-]*\d+\.\d+) seconds"
,
output
,
re
.
M
)[
0
]
except
IndexError
:
test
.
error
(
"Failed to get time offset"
)
if
float
(
offset
)
>=
drift_threshold
:
test
.
fail
(
"Uacceptable offset '%s', "
%
offset
+
"threshold '%s'"
%
drift_threshold
)
time
.
sleep
(
query_internal
)
session
.
close
()
qemu/tests/timerdevice_host_time_back.py
0 → 100644
浏览文件 @
43cacc61
import
re
import
time
import
logging
from
avocado.utils
import
process
from
virttest
import
error_context
from
virttest.compat_52lts
import
decode_to_text
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Check if guest hang/stall if host clock is set back
1) sync host system time with ntp server
2) boot guest with "-rtc base=utc, clock=host, driftfix=slew"
3) set host system time back
4) reboot guest and do some operation.
:param test: QEMU test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
clock_sync_command
=
params
[
"clock_sync_command"
]
error_context
.
context
(
"Sync host system time with ntpserver"
,
logging
.
info
)
process
.
system
(
clock_sync_command
,
shell
=
True
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
session
=
vm
.
wait_for_login
()
seconds_to_back
=
params
[
"seconds_to_back"
]
set_host_time_back_cmd
=
params
[
"set_host_time_back_cmd"
]
time_difference
=
int
(
params
[
"time_difference"
])
epoch_time_cmd
=
params
[
"epoch_time_cmd"
]
tolerance
=
float
(
params
[
"tolerance"
])
error_context
.
context
(
"Check time difference between host and guest"
,
logging
.
info
)
guest_timestr_
=
session
.
cmd_output
(
epoch_time_cmd
,
timeout
=
120
)
host_timestr_
=
decode_to_text
(
process
.
system_output
(
epoch_time_cmd
,
shell
=
True
))
host_epoch_time_
,
guest_epoch_time_
=
map
(
lambda
x
:
re
.
findall
(
r
"epoch:\s+(\d+)"
,
x
)[
0
],
[
host_timestr_
,
guest_timestr_
])
real_difference_
=
abs
(
int
(
host_epoch_time_
)
-
int
(
guest_epoch_time_
))
if
real_difference_
>
tolerance
:
test
.
error
(
"Unexpected timedrift between host and guest, host time: %s,"
"guest time: %s"
%
(
host_epoch_time_
,
guest_epoch_time_
))
error_context
.
context
(
"Set host system time back %s s"
%
seconds_to_back
)
process
.
system_output
(
set_host_time_back_cmd
)
time
.
sleep
(
10
)
try
:
vm
.
reboot
()
session
=
vm
.
wait_for_login
()
error_context
.
context
(
"Check time difference between host and guest"
,
logging
.
info
)
try
:
guest_timestr
=
session
.
cmd_output
(
epoch_time_cmd
,
timeout
=
120
)
session
.
close
()
except
Exception
:
test
.
error
(
"Guest error after set host system time back"
)
host_timestr
=
decode_to_text
(
process
.
system_output
(
epoch_time_cmd
,
shell
=
True
))
host_epoch_time
,
guest_epoch_time
=
map
(
lambda
x
:
re
.
findall
(
r
"epoch:\s+(\d+)"
,
x
)[
0
],
[
host_timestr
,
guest_timestr
])
real_difference
=
abs
(
int
(
host_epoch_time
)
-
int
(
guest_epoch_time
))
if
abs
(
real_difference
-
time_difference
)
>=
tolerance
:
test
.
fail
(
"Unexpected timedrift between host and guest, host time: %s,"
"guest time: %s"
%
(
host_epoch_time
,
guest_epoch_time
))
finally
:
time
.
sleep
(
10
)
error_context
.
context
(
"Sync host system time with ntpserver finally"
,
logging
.
info
)
process
.
system
(
clock_sync_command
,
shell
=
True
)
qemu/tests/timerdevice_time_jump_check.py
0 → 100644
浏览文件 @
43cacc61
import
logging
import
time
from
virttest
import
error_context
from
virttest.compat_52lts
import
decode_to_text
from
avocado.utils
import
process
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
check time jumps in guest (only for Linux guest):
1) boot guest with '-rtc base=utc,clock=host,driftfix=slew'
2) check current clocksource in guest
3) pin all vcpus to specfic host CPUs
4) verify time jump
: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"
])
session
=
vm
.
wait_for_login
()
error_context
.
context
(
"Check the clock source currently used on guest"
,
logging
.
info
)
cmd
=
"cat /sys/devices/system/clocksource/"
cmd
+=
"clocksource0/current_clocksource"
logging
.
info
(
"%s is current clocksource."
%
session
.
cmd_output
(
cmd
))
error_context
.
context
(
"Pin every vcpu to physical cpu"
,
logging
.
info
)
host_cpu_cnt_cmd
=
params
[
"host_cpu_cnt_cmd"
]
host_cpu_num
=
decode_to_text
(
process
.
system_output
(
host_cpu_cnt_cmd
,
shell
=
True
)).
strip
()
host_cpu_list
=
(
_
for
_
in
range
(
int
(
host_cpu_num
)))
if
len
(
vm
.
vcpu_threads
)
>
int
(
host_cpu_num
):
host_cpu_list
=
[]
for
_
in
range
(
len
(
vm
.
vcpu_threads
)):
host_cpu_list
.
append
(
_
%
int
(
host_cpu_num
))
cpu_pin_list
=
list
(
zip
(
vm
.
vcpu_threads
,
host_cpu_list
))
for
vcpu
,
pcpu
in
cpu_pin_list
:
process
.
system
(
"taskset -p -c %s %s"
%
(
pcpu
,
vcpu
))
check_cmd
=
params
[
"check_cmd"
]
output
=
str
(
session
.
cmd_output
(
check_cmd
)).
splitlines
()
session
.
close
()
time_pattern
=
"%y-%m-%d %H:%M:%S"
time_list
=
[]
for
str_time
in
output
:
time_struct
=
time
.
strptime
(
str_time
,
time_pattern
)
etime
=
time
.
mktime
(
time_struct
)
time_list
.
append
(
etime
)
for
idx
,
_
in
enumerate
(
time_list
):
if
idx
<
len
(
time_list
)
-
1
:
if
_
==
time_list
[
idx
+
1
]
or
(
_
+
1
)
==
time_list
[
idx
+
1
]:
continue
else
:
test
.
fail
(
"Test fail, time jumps backward or forward on guest"
)
else
:
break
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录