Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
49f55a02
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
49f55a02
编写于
3月 24, 2020
作者:
L
Longxiang Lyu
提交者:
GitHub
3月 24, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1969 from xiagao/bz97394-hook
qemu_guest_agent: new cast to test fsfreeze hook script
上级
468e4c70
160878cf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
103 addition
and
0 deletion
+103
-0
qemu/tests/cfg/qemu_guest_agent.cfg
qemu/tests/cfg/qemu_guest_agent.cfg
+5
-0
qemu/tests/qemu_guest_agent.py
qemu/tests/qemu_guest_agent.py
+98
-0
未找到文件。
qemu/tests/cfg/qemu_guest_agent.cfg
浏览文件 @
49f55a02
...
...
@@ -247,6 +247,11 @@
gagent_start_cmd = "qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0 -F -d"
isa_serial:
gagent_start_cmd = "pgrep qemu-ga || qemu-ga -d -m isa-serial -p /dev/ttyS1 -F"
- check_fsfreeze_hook_script:
no isa_serial
no Windows
gagent_check_type = fsfreeze_hook_script
image_snapshot = yes
- check_fsinfo:
gagent_check_type = fsinfo
blk_extra_params = "serial=GAGENT_TEST"
...
...
qemu/tests/qemu_guest_agent.py
浏览文件 @
49f55a02
...
...
@@ -2099,6 +2099,104 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
test
.
fail
(
msg
)
session
.
cmd
(
"rm -rf %s"
%
qga_man_file
)
@
error_context
.
context_aware
def
gagent_check_fsfreeze_hook_script
(
self
,
test
,
params
,
env
):
"""
During fsfreeze,verify fsfreeze hook script works.
Steps:
1) Check fsfreeze hook related files.
2) Check fsfreeze hook path set in qemu-ga config file.
3) Fsfreeze hook should be with '-x' permission for all users.
4) Verify agent service is using the fsfreeze hook.
5) Create a simple user script in hook scripts path.
6) Get fsfreeze hook log file.
7) Issue freeze & thaw cmds.
8) Check fsfreeze hook logs.
:param test: kvm test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment
"""
def
log_check
(
action
):
msg
=
"testing %s:%s"
%
(
user_script_path
,
action
)
hook_log
=
session
.
cmd_output
(
"cat %s"
%
log_path
)
if
msg
not
in
hook_log
.
strip
().
splitlines
()[
-
2
]:
test
.
fail
(
"Fsfreeze hook test failed
\n
the fsfreeze"
" hook log is %s."
%
hook_log
)
session
=
self
.
_get_session
(
self
.
params
,
None
)
self
.
_open_session_list
.
append
(
session
)
error_context
.
context
(
"Checking fsfreeze hook related scripts."
,
logging
.
info
)
cmd_get_hook_files
=
"rpm -ql qemu-guest-agent |grep fsfreeze-hook"
hook_files
=
session
.
cmd_output
(
cmd_get_hook_files
)
if
len
(
hook_files
.
strip
().
split
())
!=
4
:
test
.
fail
(
"Fsfreeze hook files are missed, the output is"
" %s"
%
hook_files
)
error_context
.
context
(
"Checking fsfreeze hook path set in config"
" file."
,
logging
.
info
)
config_file
=
"/etc/sysconfig/qemu-ga"
cmd_get_hook_path
=
"cat %s | grep"
\
" ^FSFREEZE_HOOK_PATHNAME"
%
config_file
o_path
=
session
.
cmd_output
(
cmd_get_hook_path
)
hook_path
=
o_path
.
strip
().
split
(
"="
)[
1
]
detail
=
session
.
cmd_output
(
"ll %s"
%
hook_path
)
if
not
re
.
search
(
r
".*x.*x.*x"
,
detail
):
test
.
fail
(
"Not all users have executable permission"
" of fsfreeze hook, the detail is %s."
%
detail
)
error_context
.
context
(
"Checking if agent service is using the"
" fsfreeze hook."
,
logging
.
info
)
cmd_get_hook
=
"ps aux |grep /usr/bin/qemu-ga |grep fsfreeze-hook"
hook_path_info
=
session
.
cmd_output
(
cmd_get_hook
).
strip
()
if
params
[
'os_variant'
]
==
'rhel6'
:
error_context
.
context
(
"For rhel6 guest,need to enable fsfreeze"
" hook and restart agent service."
,
logging
.
info
)
if
not
session
.
cmd_output
(
cmd_get_hook
):
cmd_enable_hook
=
"sed -i 's/FSFREEZE_HOOK_ENABLE=0/"
\
"FSFREEZE_HOOK_ENABLE=1/g' %s"
%
\
config_file
session
.
cmd
(
cmd_enable_hook
)
session
.
cmd
(
params
[
"gagent_restart_cmd"
])
hook_path_info
=
session
.
cmd_output
(
cmd_get_hook
).
strip
()
hook_path_service
=
hook_path_info
.
split
(
"--fsfreeze-hook="
)[
-
1
]
else
:
hook_path_service
=
hook_path_info
.
split
(
"-F"
)[
-
1
]
if
hook_path_service
!=
hook_path
:
test
.
fail
(
"Fsfreeze hook in qemu-guest-agent service is different"
" from config.
\n
it's %s from service
\n
"
"it's %s from config."
%
(
hook_path_service
,
hook_path
))
error_context
.
context
(
"Create a simple script to verify fsfreeze"
" hook."
,
logging
.
info
)
cmd_get_user_path
=
"rpm -ql qemu-guest-agent |grep fsfreeze-hook.d"
\
" |grep -v /usr/share"
output
=
session
.
cmd_output
(
cmd_get_user_path
)
user_script_path
=
output
.
strip
().
split
(
"
\n
"
)[
-
1
]
user_script_path
+=
"/user_script.sh"
cmd_create_script
=
'echo "printf
\'
testing %%s:%%s
\\
n
\'
\\
$0
\\
$@"'
\
' > %s'
%
user_script_path
session
.
cmd
(
cmd_create_script
)
session
.
cmd
(
"chmod +x %s"
%
user_script_path
)
error_context
.
context
(
"Issue fsfreeze and thaw commands and check"
" logs."
,
logging
.
info
)
cmd_get_log_path
=
"cat %s |grep ^LOGFILE"
%
hook_path
log_path
=
session
.
cmd_output
(
cmd_get_log_path
).
strip
().
split
(
"="
)[
-
1
]
self
.
gagent
.
fsfreeze
()
log_check
(
"freeze"
)
self
.
gagent
.
fsthaw
()
log_check
(
"thaw"
)
@
error_context
.
context_aware
def
gagent_check_query_chardev
(
self
,
test
,
params
,
env
):
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录