Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
636ebc41
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,发现更多精彩内容 >>
提交
636ebc41
编写于
8月 24, 2016
作者:
S
suqinhuang
提交者:
GitHub
8月 24, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #726 from pingl2016/convert_case
Add cases for subcommand convert of qemu-img
上级
366d160b
467cdba5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
132 addition
and
14 deletion
+132
-14
qemu/tests/cfg/qemu_disk_img.cfg
qemu/tests/cfg/qemu_disk_img.cfg
+41
-12
qemu/tests/cfg/qemu_img.cfg
qemu/tests/cfg/qemu_img.cfg
+11
-0
qemu/tests/qemu_disk_img.py
qemu/tests/qemu_disk_img.py
+34
-0
qemu/tests/qemu_disk_img_convert.py
qemu/tests/qemu_disk_img_convert.py
+1
-0
qemu/tests/qemu_img.py
qemu/tests/qemu_img.py
+45
-2
未找到文件。
qemu/tests/cfg/qemu_disk_img.cfg
浏览文件 @
636ebc41
...
...
@@ -26,8 +26,9 @@
image_convert = "image1"
convert_name_image1 = "images/image1_to_qcow2"
convert_format_image1 = "qcow2"
option_verified = "format"
variants:
- default:
-
@
default:
- compressed:
convert_compressed = yes
- preallocation_mode:
...
...
@@ -51,6 +52,7 @@
no Host_RHEL.m7.u0 Host_RHEL.m7.u1
preallocated = full
- cluster_size:
option_verified += " csize"
variants:
- cluster_size_512:
cluster_size = 512
...
...
@@ -60,26 +62,53 @@
cluster_size = 2M
- compat:
no Host_RHEL.m5, Host_RHEL.m6
option_verified += " compat"
variants:
- compat_0.10:
compat = 0.10
variants:
- default:
- lazy_refcounts_off:
lazy_refcounts = off
- compat_1.1:
compat = 1.1
variants:
- @default:
- lazy_refcounts_on:
only compat_1.1
lazy_refcounts = on
option_verified += " lcounts"
- lazy_refcounts_off:
option_verified += " lcounts"
lazy_refcounts = off
- cluster_size:
option_verified += " csize"
variants:
- default:
- lazy_refcounts_on:
lazy_refcounts = on
- lazy_refcounts_off:
lazy_refcounts = off
- cluster_size_512:
cluster_size = 512
- cluster_size_2k:
cluster_size = 2k
- cluster_size_2M:
cluster_size = 2M
- fully_allocated:
no Host_RHEL.m5, Host_RHEL.m6
option_verified += " sparse_size"
sparse_size = 0
- cache_mode:
variants:
- none:
cache_mode = none
- wirteback:
cache_mode = writeback
- unsafe:
cache_mode = unsafe
- directsync:
cache_mode = directsync
- writethrough:
cache_mode = writethrough
- base_to_raw:
option_verified = "format"
image_convert = "image1"
convert_name_image1 = "images/image1_to_raw"
convert_format_image1 = "raw"
- snapshot_to_qcow2:
option_verified = "format"
image_convert = "sn1"
image_chain += " sn1"
image_name_sn1 = "images/sn1"
...
...
@@ -94,7 +123,7 @@
image_name_sn1 = "images/sn1"
image_format_sn1 = "qcow2"
variants:
- default:
-
@
default:
- cache_mode:
variants:
- none:
...
...
@@ -115,7 +144,7 @@
image_format_sn1 = "qcow2"
guest_file_name_sn1 = "${tmp_dir}/sn1"
variants:
- default:
-
@
default:
- backing_chain:
backing_chain = yes
- snapshot:
...
...
qemu/tests/cfg/qemu_img.cfg
浏览文件 @
636ebc41
...
...
@@ -64,6 +64,17 @@
#cluster_size set cluster size used in qemu-img -o cluster_size=, default is 64k.
cluster_size = 2048
no Host_RHEL.m5
- show_progress:
command_result_pattern = "\(\d+\.\d+/100%\)"
variants:
- show_progress_on:
show_progress = on
check_output = stdout
- show_progress_off:
show_progress = off
qemu_img_options = cluster_size
cluster_size = 512
check_output = stderr
- to_raw:
dest_image_format = raw
- to_qed:
...
...
qemu/tests/qemu_disk_img.py
浏览文件 @
636ebc41
...
...
@@ -9,6 +9,8 @@ from virttest import data_dir
from
virttest
import
env_process
from
virttest
import
storage
from
virttest
import
qemu_storage
from
virttest
import
utils_test
from
virttest
import
utils_misc
class
QemuImgTest
(
qemu_storage
.
QemuImg
):
...
...
@@ -129,6 +131,38 @@ class QemuImgTest(qemu_storage.QemuImg):
error
.
context
(
"get image file ('%s')"
%
self
.
image_filename
)
return
super
(
QemuImgTest
,
self
).
info
()
@
error
.
context_aware
def
verify_info
(
self
,
params
=
None
):
"""
verify option is applied to image file correctly
"""
error
.
context
(
"verify option of converted image"
,
logging
.
info
)
image_filename
=
storage
.
get_image_filename
(
params
,
self
.
data_dir
)
info
=
utils_test
.
get_image_info
(
image_filename
)
avalue
=
evalue
=
""
for
option
in
params
.
objects
(
"option_verified"
):
avalue
=
info
.
get
(
option
)
if
option
==
"format"
:
evalue
=
params
.
get
(
"image_format"
)
elif
option
==
"lcounts"
:
if
params
.
get
(
"lazy_refcounts"
)
==
"on"
:
evalue
=
"true"
elif
params
.
get
(
"lazy_refcounts"
)
==
"off"
:
evalue
=
"false"
elif
option
==
"csize"
:
csize
=
params
.
get
(
"cluster_size"
)
evalue
=
int
(
float
(
utils_misc
.
normalize_data_size
(
csize
,
"B"
)))
elif
option
==
"sparse_size"
:
if
info
.
get
(
"dsize"
)
<
info
.
get
(
"vsize"
):
avalue
=
info
.
get
(
"dsize"
)
evalue
=
info
.
get
(
"vsize"
)
else
:
evalue
=
params
.
get
(
option
)
if
avalue
is
not
None
and
avalue
!=
evalue
:
msg
=
"Get wrong %s from image %s!"
%
(
option
,
image_filename
)
msg
+=
"Expect: %s, actual: %s"
%
(
evalue
,
avalue
)
raise
error
.
TestFail
(
msg
)
@
error
.
context_aware
def
clean
(
self
):
error
.
context
(
"clean up useless images"
)
...
...
qemu/tests/qemu_disk_img_convert.py
浏览文件 @
636ebc41
...
...
@@ -58,6 +58,7 @@ def run(test, params, env):
raise
error
.
TestError
(
"Fail to save tmp file"
)
convert_test
.
destroy_vm
()
n_params
=
convert_test
.
convert
()
convert_test
.
verify_info
(
n_params
)
convert_test
.
start_vm
(
n_params
)
# check md5sum after conversion
...
...
qemu/tests/qemu_img.py
浏览文件 @
636ebc41
import
re
import
os
import
time
import
re
import
logging
import
commands
import
shutil
...
...
@@ -177,6 +178,42 @@ def run(test, params, env):
cluster_size
=
params
.
get
(
"image_cluster_size"
))
remove
(
img
)
def
send_signal
(
timeout
=
360
):
"""
send signal "SIGUSR1" to qemu-img without the option -p
to report progress
"""
logging
.
info
(
"Send signal to qemu-img"
)
end_time
=
time
.
time
()
+
timeout
while
time
.
time
()
<
end_time
:
time
.
sleep
(
1
)
status
=
utils
.
system
(
"kill -SIGUSR1 `pidof qemu-img`"
,
ignore_status
=
True
)
if
status
==
0
:
return
None
logging
.
info
(
"Fail to get pid of qemu-img"
)
def
check_command_output
(
CmdResult
):
"""
Check standard error or standard output of command
: param CmdResult: a list of CmdResult objects
"""
logging
.
info
(
"Check result of command"
)
check_output
=
params
.
get
(
"check_output"
,
"exit_status"
)
if
not
hasattr
(
CmdResult
,
check_output
):
raise
error
.
TestError
(
"Unknown check output '%s'"
%
check_output
)
output
=
getattr
(
CmdResult
,
check_output
)
if
check_output
==
"exit_status"
and
output
==
0
:
return
None
if
check_output
==
"exit_status"
and
output
!=
0
:
err_msg
=
"Get nonzero exit status(%d) '%s'"
raise
error
.
TestFail
(
err_msg
%
(
output
,
CmdResult
.
command
))
pattern
=
params
.
get
(
"command_result_pattern"
)
if
not
re
.
findall
(
pattern
,
output
):
err_msg
=
"Fail to get expected result!"
err_msg
+=
"Output: %s, expected pattern: %s"
%
(
output
,
pattern
)
raise
error
.
TestFail
(
err_msg
)
def
_convert
(
cmd
,
output_fmt
,
img_name
,
output_filename
,
fmt
=
None
,
compressed
=
"no"
,
encrypted
=
"no"
):
"""
...
...
@@ -195,6 +232,9 @@ def run(test, params, env):
cmd
+=
" -c"
if
encrypted
==
"yes"
:
cmd
+=
" -e"
show_progress
=
params
.
get
(
"show_progress"
,
""
)
if
show_progress
==
"on"
:
cmd
+=
" -p"
if
fmt
:
cmd
+=
" -f %s"
%
fmt
cmd
+=
" -O %s"
%
output_fmt
...
...
@@ -210,7 +250,10 @@ def run(test, params, env):
msg
=
"Converting '%s' from format '%s'"
%
(
img_name
,
fmt
)
msg
+=
" to '%s'"
%
output_fmt
error
.
context
(
msg
,
logging
.
info
)
utils
.
system
(
cmd
)
if
show_progress
==
"off"
:
bg
=
utils
.
InterruptedThread
(
send_signal
)
bg
.
start
()
check_command_output
(
utils
.
run
(
cmd
,
ignore_status
=
True
))
def
convert_test
(
cmd
):
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录