Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
e11f1609
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,发现更多精彩内容 >>
提交
e11f1609
编写于
7月 17, 2016
作者:
C
Cong Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
live_snapshot: Using existing class "BlockCopy" as parent class.
Signed-off-by:
N
Cong Li
<
coli@redhat.com
>
上级
9568e469
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
65 addition
and
73 deletion
+65
-73
qemu/tests/cfg/live_snapshot.cfg
qemu/tests/cfg/live_snapshot.cfg
+16
-1
qemu/tests/cfg/live_snapshot_basic.cfg
qemu/tests/cfg/live_snapshot_basic.cfg
+0
-19
qemu/tests/live_snapshot.py
qemu/tests/live_snapshot.py
+1
-1
qemu/tests/live_snapshot_basic.py
qemu/tests/live_snapshot_basic.py
+26
-52
qemu/tests/live_snapshot_simple.py
qemu/tests/live_snapshot_simple.py
+22
-0
未找到文件。
qemu/tests/cfg/live_snapshot.cfg
浏览文件 @
e11f1609
...
...
@@ -3,11 +3,26 @@
type = live_snapshot
no raw vmdk qed
kill_vm = yes
monitor_type = qmp
monitors = qmp1
source_image = image1
snapshot_file = live_snapshot_img
snapshot_mode = "absolute-paths"
create_cmd = "dd if=/dev/urandom of=%s bs=1M count=1024"
file_create = /var/tmp/file
clean_cmd = rm -f
snapshot_name = live_snapshot_img
variants:
- simple_test:
type = live_snapshot_simple
variants:
- @default:
- existing_mode:
snapshot_mode = "existing"
image_cluster_size = 4096
after_finished = "reboot verify_alive"
- node_name:
node_name = node1
snapshot_node_name = node2
- with_reboot:
subcommand = reboot
sleep_time = 10
...
...
qemu/tests/cfg/live_snapshot_basic.cfg
已删除
100644 → 0
浏览文件 @
9568e469
- live_snapshot_basic:
virt_test_type = qemu
type = live_snapshot_basic
monitor_type = qmp
monitors = qmp1
kill_vm = yes
snapshot_file = live_snapshot_img
snapshot_mode = "absolute-paths"
variants:
- @default:
- existing_mode:
snapshot_mode = "existing"
image_cluster_size = 4096
sub_type_after_snapshot = boot
reboot_method = shell
reboot = yes
- node_name:
node_name = node1
snapshot_node_name = node2
qemu/tests/live_snapshot.py
浏览文件 @
e11f1609
...
...
@@ -33,7 +33,7 @@ def run(test, params, env):
device
=
block_info
[
0
][
"device"
]
else
:
device
=
""
.
join
(
block_info
).
split
(
":"
)[
0
]
snapshot_name
=
params
.
get
(
"snapshot_
nam
e"
)
snapshot_name
=
params
.
get
(
"snapshot_
fil
e"
)
format
=
params
.
get
(
"snapshot_format"
,
"qcow2"
)
vm
.
monitor
.
live_snapshot
(
device
,
snapshot_name
,
format
=
format
)
...
...
qemu/tests/live_snapshot_basic.py
浏览文件 @
e11f1609
import
logging
from
virttest
import
utils_test
from
virttest
import
utils_misc
from
virttest
import
storage
from
virttest
import
error_context
from
virttest
import
data_dir
from
virttest.qemu_storage
import
QemuImg
from
avocado.core
import
exceptions
from
qemu.tests
import
block_copy
class
LiveSnapshot
Base
(
object
):
class
LiveSnapshot
(
block_copy
.
BlockCopy
):
"""
Provide basic functions for live snapshot test cases.
"""
def
__init__
(
self
,
params
,
env
):
def
__init__
(
self
,
test
,
params
,
env
,
tag
):
"""
Init the default values for live snapshot object.
:param params: A dict containing VM preprocessing parameters.
:param env: The environment (a dict-like object).
"""
s
elf
.
params
=
params
self
.
env
=
env
self
.
vm
=
env
.
get_vm
(
params
[
"main_vm"
]
)
self
.
snapshot_file
=
params
.
get
(
"snapshot_fil
e"
)
self
.
snapshot_
format
=
params
.
get
(
"snapshot_format"
,
"qcow2
"
)
s
uper
(
LiveSnapshot
,
self
).
__init__
(
test
,
params
,
env
,
tag
)
self
.
default_params
=
{
"login_timeout"
:
360
}
self
.
snapshot_file
=
self
.
params
.
get
(
"snapshot_file"
)
self
.
node_name
=
self
.
params
.
get
(
"node_nam
e"
)
self
.
snapshot_
node_name
=
self
.
params
.
get
(
"snapshot_node_name
"
)
self
.
snapshot_mode
=
params
.
get
(
"snapshot_mode"
,
"absolute-paths"
)
self
.
node_name
=
params
.
get
(
"node_name"
)
self
.
snapshot_node_name
=
params
.
get
(
"snapshot_node_name"
)
self
.
snapshot_format
=
params
.
get
(
"snapshot_format"
,
"qcow2"
)
self
.
snapshot_args
=
{
"mode"
:
self
.
snapshot_mode
,
"format"
:
self
.
snapshot_format
}
if
self
.
node_name
:
self
.
snapshot_args
.
update
({
"node-name"
:
self
.
node_name
})
if
self
.
snapshot_node_name
:
self
.
snapshot_args
.
update
({
"snapshot-node-name"
:
self
.
snapshot_node_name
})
def
create_image
(
self
):
"""
...
...
@@ -44,14 +47,6 @@ class LiveSnapshotBase(object):
image_name
,
_
=
image_io
.
create
(
snapshot_params
)
return
image_name
def
get_base_image
(
self
):
"""
Get base image.
"""
base_file
=
storage
.
get_image_filename
(
self
.
params
,
data_dir
.
get_data_dir
())
return
self
.
vm
.
get_block
({
"file"
:
base_file
})
def
get_snapshot_file
(
self
):
"""
Get path of snapshot file.
...
...
@@ -64,19 +59,15 @@ class LiveSnapshotBase(object):
Create a live disk snapshot.
"""
if
self
.
snapshot_mode
==
"existing"
:
error_context
.
context
(
"Creating an image ..."
,
logging
.
info
)
logging
.
info
(
"Creating an image ..."
)
self
.
snapshot_file
=
self
.
create_image
()
else
:
self
.
snapshot_file
=
self
.
get_snapshot_file
()
device
=
self
.
get_base_image
()
snapshot_args
=
{
"format"
:
self
.
snapshot_format
,
"mode"
:
self
.
snapshot_mode
}
if
self
.
node_name
:
snapshot_args
.
update
({
"node-name"
:
self
.
node_name
})
if
self
.
snapshot_node_name
:
snapshot_args
.
update
({
"snapshot-node-name"
:
self
.
snapshot_node_name
})
self
.
vm
.
monitor
.
live_snapshot
(
device
,
self
.
snapshot_file
,
**
snapshot_args
)
logging
.
info
(
"Creating snapshot"
)
self
.
vm
.
monitor
.
live_snapshot
(
self
.
device
,
self
.
snapshot_file
,
**
self
.
snapshot_args
)
logging
.
info
(
"Checking snapshot created successfully"
)
self
.
check_snapshot
()
def
check_snapshot
(
self
):
"""
...
...
@@ -95,25 +86,8 @@ class LiveSnapshotBase(object):
%
(
self
.
snapshot_node_name
,
snapshot_info
))
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
image_tag
=
params
.
get
(
"image_name"
,
"image1"
)
image_params
=
params
.
object_params
(
image_tag
)
snapshot_test
=
LiveSnapshotBase
(
image_params
,
env
)
error_context
.
context
(
"Creating snapshot"
,
logging
.
info
)
snapshot_test
.
create_snapshot
()
error_context
.
context
(
"Checking snapshot created successfully"
,
logging
.
info
)
snapshot_test
.
check_snapshot
()
sub_type
=
params
.
get
(
"sub_type_after_snapshot"
)
if
sub_type
:
error_context
.
context
(
"%s after snapshot"
%
sub_type
,
logging
.
info
)
utils_test
.
run_virt_sub_test
(
test
,
params
,
env
,
sub_type
)
if
vm
.
is_alive
():
vm
.
destroy
()
def
action_after_finished
(
self
):
"""
Run steps after live snapshot done.
"""
return
self
.
do_steps
(
"after_finished"
)
qemu/tests/live_snapshot_simple.py
0 → 100644
浏览文件 @
e11f1609
from
virttest
import
error_context
from
qemu.tests
import
live_snapshot_basic
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
live_snapshot_simple test:
1). Create snapshot with different configurations.
2). Verify guest is fine when snapshot finished(optional)
:param test: Kvm test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
tag
=
params
.
get
(
"source_image"
,
"image1"
)
simple_test
=
live_snapshot_basic
.
LiveSnapshot
(
test
,
params
,
env
,
tag
)
try
:
simple_test
.
create_snapshot
()
simple_test
.
action_after_finished
()
finally
:
simple_test
.
clean
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录