Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
009c3de5
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 搜索 >>
提交
009c3de5
编写于
8月 19, 2019
作者:
X
Xiaoling Gao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu_guest_agent: new case of test guest-fstrim for windows vm
Signed-off-by:
N
Xiaoling Gao
<
xiagao@redhat.com
>
上级
2b329ae9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
104 addition
and
1 deletion
+104
-1
qemu/tests/cfg/qemu_guest_agent.cfg
qemu/tests/cfg/qemu_guest_agent.cfg
+13
-1
qemu/tests/qemu_guest_agent.py
qemu/tests/qemu_guest_agent.py
+91
-0
未找到文件。
qemu/tests/cfg/qemu_guest_agent.cfg
浏览文件 @
009c3de5
...
...
@@ -129,7 +129,6 @@
time_service_start_cmd = net start w32time
pause_time = 180
- check_fstrim:
no Windows
gagent_check_type = fstrim
start_vm = no
disk_size = 1024
...
...
@@ -140,6 +139,19 @@
format_disk_cmd = "yes|mkfs.ext4 DISK"
write_disk_cmd = "dd if=/dev/zero of=${mount_point}/file bs=1M count=800 oflag=direct"
delete_file_cmd = "rm ${mount_point}/file -f; sync"
Windows:
# for windows guest, only support win8+
no Win7,Win2008
start_vm = yes
driver_name = vioscsi
images += " stg"
image_name_stg = "images/storage"
image_format_stg = "qcow2"
image_size_stg = 5G
drv_extra_params = "discard=on"
force_create_image_stg = yes
remove_image_stg = yes
delete_file_cmd = "del /f /q"
- check_get_interfaces:
gagent_check_type = get_interfaces
image_snapshot = yes
...
...
qemu/tests/qemu_guest_agent.py
浏览文件 @
009c3de5
...
...
@@ -17,6 +17,8 @@ from virttest import utils_misc
from
virttest
import
utils_disk
from
virttest
import
env_process
from
virttest
import
utils_net
from
virttest
import
data_dir
from
virttest
import
storage
class
BaseVirtTest
(
object
):
...
...
@@ -2140,6 +2142,95 @@ class QemuGuestAgentBasicCheckWin(QemuGuestAgentBasicCheck):
"stamp in guest file."
%
write_timeout
)
result_check
(
"thaw"
,
write_timeout
,
session
)
@
error_context
.
context_aware
def
gagent_check_fstrim
(
self
,
test
,
params
,
env
):
"""
Execute "guest-fstrim" command via guest agent.
Steps:
1) boot up guest with scsi backend device
2) init and format the data disk
3) get the original blocks of data disk
4) create fragment in data disk
5) check the used blocks
6) execute fstrim cmd via guest agent
7) check if the used blocks is decreased
:param test: kvm test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
def
get_blocks
():
"""
Get the used blocks of data disk.
:return: the used blocks
"""
blocks
=
process
.
system_output
(
"stat -t %s"
%
image_filename_stg
)
return
blocks
.
strip
().
split
()[
2
]
session
=
self
.
_get_session
(
params
,
None
)
self
.
_open_session_list
.
append
(
session
)
error_context
.
context
(
"Format data disk."
,
logging
.
info
)
image_size_stg
=
params
[
"image_size_stg"
]
disk_index
=
utils_misc
.
wait_for
(
lambda
:
utils_disk
.
get_windows_disks_index
(
session
,
image_size_stg
),
120
)
if
not
disk_index
:
test
.
error
(
"Didn't get windows disk index."
)
logging
.
info
(
"Clear readonly of disk and online it in windows guest."
)
if
not
utils_disk
.
update_windows_disk_attributes
(
session
,
disk_index
):
test
.
error
(
"Failed to update windows disk attributes."
)
mnt_point
=
utils_disk
.
configure_empty_disk
(
session
,
disk_index
[
0
],
image_size_stg
,
"windows"
,
labeltype
=
"msdos"
)
error_context
.
context
(
"Check the original blocks of data disk."
,
logging
.
info
)
image_params_stg
=
params
.
object_params
(
"stg"
)
image_filename_stg
=
storage
.
get_image_filename
(
image_params_stg
,
data_dir
.
get_data_dir
())
blocks_init
=
get_blocks
()
logging
.
info
(
"The blocks original is %s"
%
blocks_init
)
error_context
.
context
(
"Create fragment in data disk."
,
logging
.
info
)
guest_dir
=
r
"%s:"
%
mnt_point
[
0
]
data_file
=
os
.
path
.
join
(
guest_dir
,
"qga_fstrim%s"
%
utils_misc
.
generate_random_string
(
5
))
for
i
in
range
(
5
):
count
=
1000
*
(
i
+
1
)
logging
.
info
(
"Create %sM file in guest."
%
count
)
cmd
=
"dd if=/dev/random of=%s bs=1M count=%d"
%
(
data_file
,
count
)
session
.
cmd
(
cmd
,
timeout
=
600
)
delete_file_cmd
=
"%s %s"
%
(
params
[
"delete_file_cmd"
],
data_file
.
replace
(
"/"
,
"
\\
"
))
logging
.
info
(
"Delete the guest file created just now."
)
session
.
cmd
(
delete_file_cmd
)
error_context
.
context
(
"Check blocks of data disk before fstrim."
,
logging
.
info
)
blocks_before_fstrim
=
get_blocks
()
if
int
(
blocks_init
)
>=
int
(
blocks_before_fstrim
):
msg
=
"Fragment created failed in data disk
\n
"
msg
+=
"the blocks original is %s
\n
"
%
blocks_init
msg
+=
"the blocks before fstrim is %s."
%
blocks_before_fstrim
test
.
error
(
"msg"
)
error_context
.
context
(
"Execute the guest-fstrim cmd via qga."
,
logging
.
info
)
self
.
gagent
.
fstrim
()
error_context
.
context
(
"Check blocks of data disk after fstrim."
,
logging
.
info
)
blocks_after_fstrim
=
get_blocks
()
if
int
(
blocks_after_fstrim
)
>=
int
(
blocks_before_fstrim
):
msg
=
"Fstrim failed
\n
"
msg
+=
"the blocks before fstrim is %s
\n
"
%
blocks_before_fstrim
msg
+=
"the blocks after fstrim is %s."
%
blocks_after_fstrim
test
.
fail
(
msg
)
def
run
(
test
,
params
,
env
):
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录