Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
1e2f73d9
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,发现更多精彩内容 >>
未验证
提交
1e2f73d9
编写于
2月 14, 2020
作者:
X
Xu Tian
提交者:
GitHub
2月 14, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2091 from aliang123/1802028
Snapshot on multi_disks under transaction mode
上级
fcb3b0f7
75f2f1c7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
201 addition
and
0 deletion
+201
-0
provider/backup_utils.py
provider/backup_utils.py
+32
-0
qemu/tests/blockdev_snapshot_multi_disks.py
qemu/tests/blockdev_snapshot_multi_disks.py
+140
-0
qemu/tests/cfg/blockdev_snapshot_multi_disks.cfg
qemu/tests/cfg/blockdev_snapshot_multi_disks.cfg
+29
-0
未找到文件。
provider/backup_utils.py
浏览文件 @
1e2f73d9
...
...
@@ -94,6 +94,16 @@ def verify_file_md5(vm, root_dir, filename, timeout=720):
session
.
close
()
def
blockdev_snapshot_qmp_cmd
(
source
,
target
,
**
extra_options
):
options
=
[
"node"
,
"overlay"
]
arguments
=
copy_out_dict_if_exists
(
extra_options
,
options
)
arguments
[
"node"
]
=
source
arguments
[
"overlay"
]
=
target
return
"blockdev-snapshot"
,
arguments
def
blockdev_mirror_qmp_cmd
(
source
,
target
,
**
extra_options
):
random_id
=
utils_misc
.
generate_random_string
(
4
)
job_id
=
"%s_%s"
%
(
source
,
random_id
)
...
...
@@ -184,6 +194,14 @@ def blockdev_create(vm, **options):
job_utils
.
job_dismiss
(
vm
,
options
[
"job-id"
],
timeout
)
@
fail_on
def
blockdev_snapshot
(
vm
,
source
,
target
,
**
extra_options
):
cmd
,
arguments
=
blockdev_snapshot_qmp_cmd
(
source
,
target
,
**
extra_options
)
timeout
=
int
(
extra_options
.
pop
(
"timeout"
,
600
))
vm
.
monitor
.
cmd
(
cmd
,
arguments
)
job_utils
.
wait_until_block_job_completed
(
vm
,
timeout
)
@
fail_on
def
blockdev_mirror
(
vm
,
source
,
target
,
**
extra_options
):
cmd
,
arguments
=
blockdev_mirror_qmp_cmd
(
source
,
target
,
**
extra_options
)
...
...
@@ -228,6 +246,20 @@ def blockdev_backup(vm, source, target, **extra_options):
job_utils
.
wait_until_block_job_completed
(
vm
,
job_id
,
timeout
)
@
fail_on
def
blockdev_batch_snapshot
(
vm
,
source_lst
,
target_lst
,
**
extra_options
):
actions
=
[]
timeout
=
int
(
extra_options
.
pop
(
"timeout"
,
600
))
jobs_id
=
[]
for
idx
,
src
in
enumerate
(
source_lst
):
snapshot_cmd
,
arguments
=
blockdev_snapshot_qmp_cmd
(
src
,
target_lst
[
idx
],
**
extra_options
)
actions
.
append
({
"type"
:
snapshot_cmd
,
"data"
:
arguments
})
arguments
=
{
"actions"
:
actions
}
vm
.
monitor
.
cmd
(
"transaction"
,
arguments
)
list
(
map
(
lambda
x
:
job_utils
.
wait_until_block_job_completed
(
vm
,
x
,
timeout
),
jobs_id
))
@
fail_on
def
blockdev_batch_backup
(
vm
,
source_lst
,
target_lst
,
bitmap_lst
,
**
extra_options
):
...
...
qemu/tests/blockdev_snapshot_multi_disks.py
0 → 100644
浏览文件 @
1e2f73d9
import
logging
from
virttest
import
data_dir
from
virttest
import
utils_disk
from
virttest
import
error_context
from
provider
import
backup_utils
from
provider.virt_storage.storage_admin
import
sp_admin
from
provider.blockdev_snapshot_base
import
BlockDevSnapshotTest
class
BlockdevSnapshotMultiDisksTest
(
BlockDevSnapshotTest
):
def
__init__
(
self
,
test
,
params
,
env
):
self
.
source_disks
=
params
[
"source_disks"
].
split
()
self
.
target_disks
=
params
[
"target_disks"
].
split
()
self
.
snapshot_tag_list
=
params
[
"snapshot_tag"
].
split
()
self
.
base_tag_list
=
params
[
"base_tag"
].
split
()
super
(
BlockdevSnapshotMultiDisksTest
,
self
).
__init__
(
test
,
params
,
env
)
def
prepare_clone_vm
(
self
):
vm_params
=
self
.
main_vm
.
params
.
copy
()
for
snapshot_tag
,
base_tag
in
zip
(
self
.
snapshot_tag_list
,
self
.
base_tag_list
):
images
=
self
.
main_vm
.
params
[
"images"
].
replace
(
self
.
base_tag
,
self
.
snapshot_tag
)
vm_params
[
"images"
]
=
images
return
self
.
main_vm
.
clone
(
params
=
vm_params
)
def
configure_data_disk
(
self
):
os_type
=
self
.
params
[
"os_type"
]
for
snapshot_tag
in
self
.
snapshot_tag_list
:
disk_params
=
self
.
params
.
object_params
(
snapshot_tag
)
disk_size
=
disk_params
[
"image_size"
]
session
=
self
.
main_vm
.
wait_for_login
()
try
:
if
os_type
!=
"windows"
:
disk_id
=
self
.
get_linux_disk_path
(
session
,
disk_size
)
assert
disk_id
,
"Disk not found in guest!"
mount_point
=
utils_disk
.
configure_empty_linux_disk
(
session
,
disk_id
,
disk_size
)[
0
]
self
.
disks_info
.
append
([
r
"/dev/%s1"
%
disk_id
,
mount_point
])
else
:
disk_id
=
utils_disk
.
get_windows_disks_index
(
session
,
disk_size
)
driver_letter
=
utils_disk
.
configure_empty_windows_disk
(
session
,
disk_id
,
disk_size
)[
0
]
mount_point
=
r
"%s:\\"
%
driver_letter
self
.
disks_info
.
append
([
disk_id
,
mount_point
])
finally
:
session
.
close
()
def
prepare_snapshot_file
(
self
):
for
snapshot_tag
in
self
.
snapshot_tag_list
:
if
self
.
is_blockdev_mode
():
params
=
self
.
params
.
copy
()
params
.
setdefault
(
"target_path"
,
data_dir
.
get_data_dir
())
image
=
sp_admin
.
volume_define_by_params
(
snapshot_tag
,
params
)
image
.
hotplug
(
self
.
main_vm
)
else
:
if
self
.
params
.
get
(
"mode"
)
==
"existing"
:
snapshot_image
=
self
.
get_image_by_tag
(
snapshot_tag
)
snapshot_image
.
create
()
@
error_context
.
context_aware
def
create_snapshot
(
self
):
error_context
.
context
(
"do snaoshot on multi_disks"
,
logging
.
info
)
assert
len
(
self
.
target_disks
)
==
len
(
self
.
source_disks
),
"No enough target disks define in cfg!"
source_lst
=
list
(
map
(
lambda
x
:
"drive_%s"
%
x
,
self
.
source_disks
))
target_lst
=
list
(
map
(
lambda
x
:
"drive_%s"
%
x
,
self
.
target_disks
))
arguments
=
{}
if
len
(
source_lst
)
>
1
:
error_context
.
context
(
"snapshot %s to %s "
%
(
source_lst
,
target_lst
))
backup_utils
.
blockdev_batch_snapshot
(
self
.
main_vm
,
source_lst
,
target_lst
,
**
arguments
)
else
:
error_context
.
context
(
"snapshot %s to %s"
%
(
source_lst
[
0
],
target_lst
[
0
]))
backup_utils
.
blockdev_snapshot
(
self
.
main_vm
,
source_lst
[
0
],
target_lst
[
0
])
def
verify_snapshot
(
self
):
if
self
.
main_vm
.
is_alive
():
self
.
main_vm
.
destroy
()
for
snapshot_tag
,
base_tag
in
zip
(
self
.
snapshot_tag_list
,
self
.
base_tag_list
):
if
self
.
is_blockdev_mode
():
snapshot_image
=
self
.
get_image_by_tag
(
snapshot_tag
)
base_image
=
self
.
get_image_by_tag
(
base_tag
)
snapshot_image
.
base_tag
=
base_tag
snapshot_image
.
base_format
=
base_image
.
get_format
()
base_image_filename
=
base_image
.
image_filename
snapshot_image
.
base_image_filename
=
base_image_filename
snapshot_image
.
rebase
(
snapshot_image
.
params
)
self
.
clone_vm
.
create
()
self
.
clone_vm
.
verify_alive
()
if
self
.
base_tag
!=
"image1"
:
self
.
mount_data_disks
()
self
.
verify_data_file
()
def
post_test
(
self
):
try
:
self
.
clone_vm
.
destroy
()
for
snapshot_tag
in
self
.
snapshot_tag_list
:
snapshot_image
=
self
.
get_image_by_tag
(
snapshot_tag
)
snapshot_image
.
remove
()
except
Exception
as
error
:
logging
.
error
(
str
(
error
))
def
run
(
test
,
params
,
env
):
"""
Backup VM disk test when VM reboot
1) start VM with two data disks
2) create target disks with qmp command
3) format data disks in guest
4) do snapshot to target disks in transaction mode
5) dd file on data disks
6) shutdown VM
7) boot VM with target disks
:param test: test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
base_image
=
params
.
get
(
"images"
,
"image1"
).
split
()[
0
]
params
.
update
(
{
"image_name_%s"
%
base_image
:
params
[
"image_name"
],
"image_format_%s"
%
base_image
:
params
[
"image_format"
]})
snapshot_multi_disks
=
BlockdevSnapshotMultiDisksTest
(
test
,
params
,
env
)
snapshot_multi_disks
.
run_test
()
qemu/tests/cfg/blockdev_snapshot_multi_disks.cfg
0 → 100644
浏览文件 @
1e2f73d9
- blockdev_snapshot_multi_disks:
type = blockdev_snapshot_multi_disks
virt_test_type = qemu
start_vm = yes
storage_type_default = "directory"
storage_pool = default
images += " data1 data2"
image_size_data1 = 500M
image_name_data1 = "images/data1"
image_size_sn1 = 500M
image_name_sn1 = "sn1"
image_format_sn1 = qcow2
force_create_image = yes
force_remove_image = yes
image_size_data2 = 400M
image_name_data2 = "images/data2"
image_size_sn2 = 400M
image_name_sn2 = "sn2"
image_format_sn2 = qcow2
force_remove_image_image1 = no
force_create_image_image1 = no
source_disks = data1 data2
target_disks = sn1 sn2
rebase_mode = unsafe
snapshot_tag = sn1 sn2
base_tag = data1 data2
image_format_sn1 = qcow2
image_name_sn1 = images/sn1
image_name_sn2 = images/sn2
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录