Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
6cf08f40
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,发现更多精彩内容 >>
未验证
提交
6cf08f40
编写于
12月 12, 2018
作者:
Y
YongxueHong
提交者:
GitHub
12月 12, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1593 from hereischen/6885-unsafe-rebase
added an unsafe rebase snapshot
上级
1d5b060a
caf64dea
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
100 addition
and
0 deletion
+100
-0
qemu/tests/cfg/unsafe_rebase_to_none_existing_backing_file.cfg
...tests/cfg/unsafe_rebase_to_none_existing_backing_file.cfg
+20
-0
qemu/tests/unsafe_rebase_to_none_existing_backing_file.py
qemu/tests/unsafe_rebase_to_none_existing_backing_file.py
+80
-0
未找到文件。
qemu/tests/cfg/unsafe_rebase_to_none_existing_backing_file.cfg
0 → 100644
浏览文件 @
6cf08f40
- unsafe_rebase_to_none_existing_backing_file:
only raw
virt_test_type = qemu
type = unsafe_rebase_to_none_existing_backing_file
kill_vm = yes
start_vm = no
force_create_image = no
image_chain = "image1 sn"
image_format_image1 = "raw"
image_name_sn = "images/sn"
rebase_mode_sn = unsafe
none_existing_image_name = a-none-existing-image.raw
# set size to "", so during snapshot creation
# the cmdline will not have specified size option
image_size_sn = ""
image_format_sn = qcow2
variants:
- compat_0.10:
image_extra_params = "compat=0.10"
- compat_default:
qemu/tests/unsafe_rebase_to_none_existing_backing_file.py
0 → 100644
浏览文件 @
6cf08f40
import
logging
import
json
from
avocado.utils
import
process
from
virttest
import
data_dir
from
virttest.qemu_storage
import
QemuImg
from
qemu.tests.qemu_disk_img
import
QemuImgTest
from
qemu.tests.qemu_disk_img
import
generate_base_snapshot_pair
def
run
(
test
,
params
,
env
):
"""
Unsafe rebase a qcow2 snapshot to a none existing the raw backing file.
1. create a qcow2 snapshot based on a raw image with compat mode 0.10/1.1
2. rebase the snapshot to a none exist the raw backing file
3. check the snapshot
:param test: Qemu test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment
"""
def
_get_img_obj_and_params
(
tag
):
"""Get an QemuImg object and its params based on the tag."""
img_param
=
params
.
object_params
(
tag
)
img
=
QemuImg
(
img_param
,
data_dir
.
get_data_dir
(),
tag
)
return
img
,
img_param
def
_get_compat_version
():
"""Get snapshot compat version."""
if
params
.
get
(
"image_extra_params"
)
is
None
:
# default compat version for now is 1.1
return
"1.1"
return
params
.
get
(
"image_extra_params"
).
split
(
"="
)[
1
]
def
_verify_qemu_img_info
(
output
,
b_fmt
,
b_name
):
"""Verify qemu-img info output for this case."""
logging
.
info
(
"Verify snapshot's backing file information."
)
res
=
json
.
loads
(
output
)
if
(
res
[
"backing-filename-format"
]
!=
b_fmt
or
res
[
"backing-filename"
]
!=
b_name
):
test
.
fail
(
"Backing file information is not correct,"
" got %s."
%
b_name
)
compat
=
res
[
"format-specific"
][
"data"
][
"compat"
]
expected
=
_get_compat_version
()
if
(
compat
!=
expected
):
test
.
fail
(
"Snapshot's compat mode is not correct,"
" got %s, expected %s."
%
(
compat
,
expected
))
def
_verify_unsafe_rebase
(
img
):
"""Verify qemu-img check output for this case."""
logging
.
info
(
"Verify snapshot's unsafe check information."
)
res
=
process
.
run
(
"%s check %s"
%
(
img
.
image_cmd
,
img
.
image_filename
),
ignore_status
=
True
)
expected
=
[
"Could not open backing file"
,
img
.
base_image_filename
,
"No such file or directory"
]
for
msg
in
expected
:
if
msg
not
in
res
.
stderr_text
:
test
.
fail
(
"The %s should not exist."
%
img
.
base_image_filename
)
gen
=
generate_base_snapshot_pair
(
params
[
"image_chain"
])
base
,
snapshot
=
next
(
gen
)
base_img
,
_
=
_get_img_obj_and_params
(
base
)
sn_img
,
sn_img_params
=
_get_img_obj_and_params
(
snapshot
)
logging
.
info
(
"Create a snapshot %s based on %s."
%
(
snapshot
,
base
))
# workaround to assign system disk's image_name to image_name_image1
params
[
"image_name_image1"
]
=
params
[
"image_name"
]
QemuImgTest
(
test
,
params
,
env
,
snapshot
).
create_snapshot
()
_verify_qemu_img_info
(
sn_img
.
info
(
output
=
"json"
),
base_img
.
image_format
,
base_img
.
image_filename
)
sn_img
.
base_image_filename
=
params
[
"none_existing_image_name"
]
sn_img
.
base_format
=
sn_img
.
base_image_filename
.
split
(
'.'
)[
-
1
]
sn_img
.
rebase
(
sn_img_params
)
_verify_qemu_img_info
(
sn_img
.
info
(
output
=
"json"
),
sn_img
.
base_format
,
sn_img
.
base_image_filename
)
_verify_unsafe_rebase
(
sn_img
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录