Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
691b34de
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,发现更多精彩内容 >>
提交
691b34de
编写于
7月 04, 2013
作者:
L
Lukáš Doktor
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #588 from xutian/fix_block_stream
qemu.test: make block_stream test work with qmp monitor
上级
8d32654c
020afdf0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
45 deletion
+36
-45
qemu/tests/blk_stream.py
qemu/tests/blk_stream.py
+2
-1
qemu/tests/block_stream.py
qemu/tests/block_stream.py
+29
-43
qemu/tests/cfg/block_stream.cfg
qemu/tests/cfg/block_stream.cfg
+5
-1
未找到文件。
qemu/tests/blk_stream.py
浏览文件 @
691b34de
import
logging
,
time
from
virttest
import
utils_misc
from
virttest
import
utils_misc
,
data_dir
from
autotest.client.shared
import
error
from
qemu.tests
import
block_copy
...
...
@@ -52,6 +52,7 @@ class BlockStream(block_copy.BlockCopy):
format
=
params
.
get
(
"snapshot_format"
,
"qcow2"
)
error
.
context
(
"create live snapshots"
,
logging
.
info
)
for
sn
in
snapshots
:
sn
=
utils_misc
.
get_path
(
data_dir
.
get_data_dir
(),
sn
)
image_file
=
self
.
get_block_file
()
device
=
self
.
vm
.
live_snapshot
(
image_file
,
sn
,
format
)
if
device
!=
self
.
device
:
...
...
qemu/tests/block_stream.py
浏览文件 @
691b34de
import
re
,
os
,
logging
,
time
from
autotest.client.shared
import
utils
,
error
from
virttest
import
qemu_monitor
,
env_process
,
data_dir
from
virttest
import
qemu_monitor
,
env_process
,
data_dir
,
storage
@
error
.
context_aware
...
...
@@ -17,53 +17,48 @@ def run_block_stream(test, params, env):
7) TODO(extra): Block job completion can be check in QMP
"""
image_format
=
params
[
"image_format"
]
image_name
=
params
.
get
(
"image_name"
,
"image"
)
if
not
os
.
path
.
isabs
(
image_name
):
image_name
=
os
.
path
.
join
(
data_dir
.
get_data_dir
(),
image_name
)
drive_format
=
params
[
"drive_format"
]
backing_file_name
=
"%s_bak"
%
(
image_name
)
image_name
=
storage
.
get_image_filename
(
params
,
data_dir
.
get_data_dir
())
backing_file_name
=
"%s_bak"
%
image_name
snapshot_format
=
params
.
get
(
"snapshot_format"
,
"qcow2"
)
qemu_img
=
params
[
"qemu_img_binary"
]
block_stream_cmd
=
"block-stream"
def
check_block_jobs_info
():
def
check_block_jobs_info
(
device_id
):
"""
Verify the status of block-jobs reported by monitor command info block-jobs.
@return: parsed output of info block-jobs
"""
fail
=
0
status
=
{}
try
:
output
=
vm
.
monitor
.
info
(
"block-jobs"
)
status
=
vm
.
get_job_status
(
device_id
)
except
qemu_monitor
.
MonitorError
,
e
:
logging
.
error
(
e
)
fail
+=
1
return
None
,
None
return
(
re
.
match
(
"\w+"
,
str
(
output
)),
re
.
findall
(
"\d+"
,
str
(
output
)))
return
status
return
status
try
:
# Remove the existing backing file
backing_file
=
"%s.%s"
%
(
backing_file_name
,
image_format
)
# Remove the existing backing file
if
os
.
path
.
isfile
(
backing_file
):
os
.
remove
(
backing_file
)
# Create the new backing file
create_cmd
=
"%s create -b %s.%s -f %s %s.%s"
%
(
qemu_img
,
image_name
,
image_format
,
image_format
,
backing_file_name
,
image_format
)
create_cmd
=
"%s create -b %s -f %s %s"
%
(
qemu_img
,
image_name
,
snapshot_format
,
backing_file
)
error
.
context
(
"Creating backing file"
)
utils
.
system
(
create_cmd
)
info_cmd
=
"%s info %s
.%s"
%
(
qemu_img
,
image_name
,
image_format
)
info_cmd
=
"%s info %s
"
%
(
qemu_img
,
image_name
)
error
.
context
(
"Image file can not be find"
)
results
=
utils
.
system_output
(
info_cmd
)
logging
.
info
(
"Infocmd output of basefile: %s"
,
results
)
# Set the qemu harddisk to the backing file
logging
.
info
(
"Original image
_name is: %s"
,
params
[
'image_name'
]
)
logging
.
info
(
"Original image
file is: %s"
,
image_name
)
params
[
'image_name'
]
=
backing_file_name
logging
.
info
(
"Param image_name changed to: %s"
,
params
[
'image_name'
])
...
...
@@ -71,11 +66,11 @@ def run_block_stream(test, params, env):
vm_name
=
params
[
'main_vm'
]
env_process
.
preprocess_vm
(
test
,
params
,
env
,
vm_name
)
vm
=
env
.
get_vm
(
vm_name
)
vm
.
creat
e
()
vm
.
verify_aliv
e
()
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
info_cmd
=
"%s info %s
.%s"
%
(
qemu_img
,
backing_file_name
,
image_format
)
info_cmd
=
"%s info %s
"
%
(
qemu_img
,
backing_file
)
error
.
context
(
"Image file can not be find"
)
results
=
utils
.
system_output
(
info_cmd
)
logging
.
info
(
"Infocmd output of backing file before block streaming: "
...
...
@@ -85,32 +80,22 @@ def run_block_stream(test, params, env):
raise
error
.
TestFail
(
"Backing file is not available in the "
"backdrive image"
)
if
vm
.
monitor
.
protocol
==
"human"
:
block_stream_cmd
=
"block_stream"
# Start streaming in qemu-cmd line
if
'ide'
in
drive_format
:
error
.
context
(
"Block streaming on qemu monitor (ide drive)"
)
vm
.
monitor
.
cmd
(
"%s ide0-hd0"
%
block_stream_cmd
)
elif
'virtio'
in
drive_format
:
error
.
context
(
"Block streaming on qemu monitor (virtio drive)"
)
vm
.
monitor
.
cmd
(
"%s virtio0"
%
block_stream_cmd
)
else
:
raise
error
.
TestError
(
"The drive format is not supported"
)
device_id
=
vm
.
get_block
({
"file"
:
backing_file
})
vm
.
block_stream
(
device_id
,
speed
=
0
)
while
True
:
blkjobout
,
blkjobstatus
=
check_block_jobs_info
(
)
if
'Streaming'
in
blkjobout
.
group
(
0
)
:
info
=
check_block_jobs_info
(
device_id
)
if
info
.
get
(
"type"
,
""
)
==
"stream"
:
logging
.
info
(
"[(Completed bytes): %s (Total bytes): %s "
"(Speed in bytes/s): %s]"
,
blkjobstatus
[
-
3
],
blkjobstatus
[
-
2
],
blkjobstatus
[
-
1
])
"(Speed in bytes/s): %s]"
,
info
[
"len"
],
info
[
"offset"
],
info
[
"speed"
])
time
.
sleep
(
10
)
continue
if
'No'
in
blkjobout
.
group
(
0
)
:
if
not
info
:
logging
.
info
(
"Block job completed"
)
break
info_cmd
=
"%s info %s
.%s"
%
(
qemu_img
,
backing_file_name
,
image_format
)
info_cmd
=
"%s info %s
"
%
(
qemu_img
,
backing_file
)
error
.
context
(
"Image file can not be find"
)
results
=
utils
.
system_output
(
info_cmd
)
logging
.
info
(
"Infocmd output of backing file after block streaming: %s"
,
...
...
@@ -124,9 +109,10 @@ def run_block_stream(test, params, env):
# Shutdown the virtual machine
vm
.
destroy
()
# Relogin with the backup-harddrive
vm
.
create
()
env_process
.
preprocess_vm
(
test
,
params
,
env
,
vm_name
)
vm
=
env
.
get_vm
(
vm_name
)
vm
.
verify_alive
()
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
logging
.
info
(
"Checking whether the guest with backup-harddrive boot "
...
...
qemu/tests/cfg/block_stream.cfg
浏览文件 @
691b34de
# Below case works stablly on QMP monitor, but have no more test with Human
# monitor, so suggest to use QMP monitor as default qemu monitor run below test
#
- block_stream:
backup_image_before_testing = yes
restore_image_after_testing = yes
wait_finished = yes
source_image = image1
default_speed_image1 = 0
snapshot_chain = "
/tmp/sn1 /tmp
/sn2"
snapshot_chain = "
images/sn1 images
/sn2"
wait_timeout = 1800
snapshot_format = qcow2
kill_vm = yes
alive_check_cmd = dir
variants:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录