Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
1cd2794b
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,发现更多精彩内容 >>
未验证
提交
1cd2794b
编写于
1月 06, 2020
作者:
L
Longxiang Lyu
提交者:
GitHub
1月 06, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1947 from YongxueHong/bug-1731471
Add cases to test virtio_blk with discard and write_zeroes
上级
b72b53c1
71c5f1d8
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
110 addition
and
0 deletion
+110
-0
qemu/tests/cfg/virtio_blk_with_discard_write_zeroes.cfg
qemu/tests/cfg/virtio_blk_with_discard_write_zeroes.cfg
+30
-0
qemu/tests/virtio_blk_with_discard_write_zeroes.py
qemu/tests/virtio_blk_with_discard_write_zeroes.py
+80
-0
未找到文件。
qemu/tests/cfg/virtio_blk_with_discard_write_zeroes.cfg
0 → 100644
浏览文件 @
1cd2794b
- virtio_blk_with_discard_write_zeroes:
only virtio_blk
only Linux
required_qemu = [4.0.0,)
type = virtio_blk_with_discard_write_zeroes
images += " stg0"
boot_drive_stg0 = yes
image_name_stg0 = images/storage0
image_size_stg0 = 1G
remove_image_stg0 = yes
force_create_image_stg0 = yes
blk_extra_params_stg0 = "serial=TARGET_DISK0"
cmd_dd = "dd if=/dev/zero of={0} bs=1M count=900 oflag=direct && "
cmd_dd += "dd if={0} of=/dev/null bs=1M count=900 iflag=direct"
variants:
- all_enabled:
blk_extra_params_stg0 += ",discard=on,write-zeroes=on"
attributes_checked = "{'discard': 'true', 'write-zeroes': 'true'}"
check_cmd_discard = "blkdiscard {0} && echo "PASS" || echo "FAIL""
check_cmd_zeroes = "blkdiscard -z {0} && dd if={0} bs=64k count=10000 | "
check_cmd_zeroes += "tr -d '\0' | read -n 1 && echo "FAIL" || echo "PASS (All zeroes)""
status_checked = "{'check_cmd_discard': 'PASS', 'check_cmd_zeroes': 'PASS (All zeroes)'}"
- all_disabled:
blk_extra_params_stg0 += ",discard=off,write-zeroes=off"
attributes_checked = "{'discard': 'false', 'write-zeroes': 'false'}"
check_cmd_discard = "blkdiscard {0} && echo "PASS" || echo "FAIL""
check_cmd_zeroes = "dd if=/dev/urandom of={0} bs=64k count=10000 conv=fsync && "
check_cmd_zeroes += "dd if={0} bs=64k count=10000 | tr -d '\0' | read -n 1 && "
check_cmd_zeroes += "echo "PASS (not all zeroes)" || echo "FAIL""
status_checked = "{'check_cmd_discard': 'FAIL', 'check_cmd_zeroes': 'PASS (not all zeroes)'}"
qemu/tests/virtio_blk_with_discard_write_zeroes.py
0 → 100644
浏览文件 @
1cd2794b
import
ast
import
re
import
logging
from
virttest
import
error_context
from
virttest
import
qemu_qtree
from
virttest
import
utils_misc
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Test virtio_blk with options "discard" and "write_zeroes".
Steps:
1. Boot up a virtio-blk guest with options 'discard' and
'write_zeroes' enabled or disabled.
2. Check if discard and write-zeroes attribute works.
3. In guest, check if discard enabled or disabled.
4. In guest, check if write_zeroes enabled or disabled.
5. Do some IO tests on the disk.
:param test: KVM test object.
:param params: Dictionary with the test parameters.
:param env: Dictionary with test environment.
"""
def
check_attribute_in_qtree
(
dev_id
,
name
,
excepted_val
):
"""Check if discard and write-zeroes attribute work."""
error_context
.
context
(
'Check if %s attribute works.'
%
name
,
logging
.
info
)
qtree
=
qemu_qtree
.
QtreeContainer
()
qtree
.
parse_info_qtree
(
vm
.
monitor
.
info
(
'qtree'
))
for
node
in
qtree
.
get_nodes
():
if
(
isinstance
(
node
,
qemu_qtree
.
QtreeDev
)
and
node
.
qtree
.
get
(
'id'
)
==
dev_id
):
_node
=
node
.
children
[
0
].
children
[
0
]
if
_node
.
qtree
.
get
(
'drive'
).
endswith
(
'_%s"'
%
dev_id
):
if
_node
.
qtree
.
get
(
name
)
is
None
:
test
.
fail
(
'The qtree device %s has no property %s.'
%
(
dev_id
,
name
))
elif
_node
.
qtree
.
get
(
name
)
==
excepted_val
:
logging
.
info
(
'The "%s" matches with qtree device "%s"'
'(%s).'
%
(
name
,
dev_id
,
excepted_val
))
break
else
:
test
.
fail
(
'The "%s" mismatches with qtree device "%s"'
'(%s).'
%
(
name
,
dev_id
,
excepted_val
))
else
:
test
.
error
(
'No such "%s" qtree device.'
%
dev_id
)
def
check_status_inside_guest
(
session
,
cmd
,
excepted_val
):
"""Check if the discard or write-zeroes is enabled or disabled."""
if
excepted_val
not
in
session
.
cmd
(
cmd
,
600
):
test
.
fail
(
'The output should be "%s"'
%
excepted_val
)
def
get_data_disk_by_serial
(
session
,
image_tag
):
"""Get the data disks by serial options."""
match
=
re
.
search
(
r
"serial=(\w+)"
,
params
[
"blk_extra_params_%s"
%
image_tag
],
re
.
M
)
drive_path
=
utils_misc
.
get_linux_drive_path
(
session
,
match
.
group
(
1
))
if
not
drive_path
:
test
.
error
(
"Failed to get '%s' drive path"
%
image_tag
)
return
drive_path
def
dd_test
(
session
,
target
):
"""Do dd test on the data disk."""
error_context
.
context
(
'Do dd test on the data disk.'
,
logging
.
info
)
session
.
cmd
(
params
[
'cmd_dd'
].
format
(
target
),
600
)
data_tag
=
params
[
"images"
].
split
()[
1
]
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
session
=
vm
.
wait_for_login
()
data_disk
=
get_data_disk_by_serial
(
session
,
data_tag
)
for
attr_name
,
val
in
ast
.
literal_eval
(
params
[
'attributes_checked'
]).
items
():
check_attribute_in_qtree
(
data_tag
,
attr_name
,
val
)
for
cmd
,
val
in
ast
.
literal_eval
(
params
[
'status_checked'
]).
items
():
check_status_inside_guest
(
session
,
params
[
cmd
].
format
(
data_disk
),
val
)
dd_test
(
session
,
data_disk
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录