Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
2a13ce9c
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,发现更多精彩内容 >>
未验证
提交
2a13ce9c
编写于
11月 30, 2017
作者:
X
Xu Han
提交者:
GitHub
11月 30, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1166 from pingl2016/1517728
enospc: Use force shared option to check the stopped image
上级
eae0be9b
4ea14d9d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
42 deletion
+42
-42
qemu/tests/enospc.py
qemu/tests/enospc.py
+42
-42
未找到文件。
qemu/tests/enospc.py
浏览文件 @
2a13ce9c
...
@@ -3,13 +3,13 @@ import time
...
@@ -3,13 +3,13 @@ import time
import
re
import
re
import
os
import
os
from
autotest.client.shared
import
error
from
autotest.client
import
utils
from
virttest
import
virt_vm
from
virttest
import
virt_vm
from
virttest
import
utils_misc
from
virttest
import
utils_misc
from
virttest
import
qemu_storage
from
virttest
import
qemu_storage
from
virttest
import
data_dir
from
virttest
import
data_dir
from
virttest
import
error_context
from
avocado.utils
import
process
class
EnospcConfig
(
object
):
class
EnospcConfig
(
object
):
...
@@ -41,32 +41,32 @@ class EnospcConfig(object):
...
@@ -41,32 +41,32 @@ class EnospcConfig(object):
except
AttributeError
:
except
AttributeError
:
self
.
loopback
=
''
self
.
loopback
=
''
@
error
.
context_aware
@
error
_context
.
context_aware
def
setup
(
self
):
def
setup
(
self
):
logging
.
debug
(
"Starting enospc setup"
)
logging
.
debug
(
"Starting enospc setup"
)
error
.
context
(
"performing enospc setup"
)
error
_context
.
context
(
"performing enospc setup"
,
logging
.
info
)
utils_misc
.
display_attributes
(
self
)
utils_misc
.
display_attributes
(
self
)
# Double check if there aren't any leftovers
# Double check if there aren't any leftovers
self
.
cleanup
()
self
.
cleanup
()
try
:
try
:
util
s
.
run
(
"%s create -f raw %s 10G"
%
proces
s
.
run
(
"%s create -f raw %s 10G"
%
(
self
.
qemu_img_binary
,
self
.
raw_file_path
))
(
self
.
qemu_img_binary
,
self
.
raw_file_path
))
# Associate a loopback device with the raw file.
# Associate a loopback device with the raw file.
# Subject to race conditions, that's why try here to associate
# Subject to race conditions, that's why try here to associate
# it with the raw file as quickly as possible
# it with the raw file as quickly as possible
l_result
=
util
s
.
run
(
"losetup -f"
)
l_result
=
proces
s
.
run
(
"losetup -f"
)
util
s
.
run
(
"losetup -f %s"
%
self
.
raw_file_path
)
proces
s
.
run
(
"losetup -f %s"
%
self
.
raw_file_path
)
self
.
loopback
=
l_result
.
stdout
.
strip
()
self
.
loopback
=
l_result
.
stdout
.
strip
()
# Add the loopback device configured to the list of pvs
# Add the loopback device configured to the list of pvs
# recognized by LVM
# recognized by LVM
util
s
.
run
(
"pvcreate %s"
%
self
.
loopback
)
proces
s
.
run
(
"pvcreate %s"
%
self
.
loopback
)
util
s
.
run
(
"vgcreate %s %s"
%
(
self
.
vgtest_name
,
self
.
loopback
))
proces
s
.
run
(
"vgcreate %s %s"
%
(
self
.
vgtest_name
,
self
.
loopback
))
# Create an lv inside the vg with starting size of 200M
# Create an lv inside the vg with starting size of 200M
util
s
.
run
(
"lvcreate -L 200M -n %s %s"
%
proces
s
.
run
(
"lvcreate -L 200M -n %s %s"
%
(
self
.
lvtest_name
,
self
.
vgtest_name
))
(
self
.
lvtest_name
,
self
.
vgtest_name
))
# Create a 10GB qcow2 image in the logical volume
# Create a 10GB qcow2 image in the logical volume
util
s
.
run
(
"%s create -f qcow2 %s 10G"
%
proces
s
.
run
(
"%s create -f qcow2 %s 10G"
%
(
self
.
qemu_img_binary
,
self
.
lvtest_device
))
(
self
.
qemu_img_binary
,
self
.
lvtest_device
))
# Let's symlink the logical volume with the image name that autotest
# Let's symlink the logical volume with the image name that autotest
# expects this device to have
# expects this device to have
os
.
symlink
(
self
.
lvtest_device
,
self
.
qcow_file_path
)
os
.
symlink
(
self
.
lvtest_device
,
self
.
qcow_file_path
)
...
@@ -77,30 +77,30 @@ class EnospcConfig(object):
...
@@ -77,30 +77,30 @@ class EnospcConfig(object):
logging
.
warn
(
e
)
logging
.
warn
(
e
)
raise
raise
@
error
.
context_aware
@
error
_context
.
context_aware
def
cleanup
(
self
):
def
cleanup
(
self
):
error
.
context
(
"performing enospc cleanup"
)
error
_context
.
context
(
"performing enospc cleanup"
,
logging
.
info
)
if
os
.
path
.
islink
(
self
.
lvtest_device
):
if
os
.
path
.
islink
(
self
.
lvtest_device
):
util
s
.
run
(
"fuser -k %s"
%
self
.
lvtest_device
,
ignore_status
=
True
)
proces
s
.
run
(
"fuser -k %s"
%
self
.
lvtest_device
,
ignore_status
=
True
)
time
.
sleep
(
2
)
time
.
sleep
(
2
)
l_result
=
util
s
.
run
(
"lvdisplay"
)
l_result
=
proces
s
.
run
(
"lvdisplay"
)
# Let's remove all volumes inside the volume group created
# Let's remove all volumes inside the volume group created
if
self
.
lvtest_name
in
l_result
.
stdout
:
if
self
.
lvtest_name
in
l_result
.
stdout
:
util
s
.
run
(
"lvremove -f %s"
%
self
.
lvtest_device
)
proces
s
.
run
(
"lvremove -f %s"
%
self
.
lvtest_device
)
# Now, removing the volume group itself
# Now, removing the volume group itself
v_result
=
util
s
.
run
(
"vgdisplay"
)
v_result
=
proces
s
.
run
(
"vgdisplay"
)
if
self
.
vgtest_name
in
v_result
.
stdout
:
if
self
.
vgtest_name
in
v_result
.
stdout
:
util
s
.
run
(
"vgremove -f %s"
%
self
.
vgtest_name
)
proces
s
.
run
(
"vgremove -f %s"
%
self
.
vgtest_name
)
# Now, if we can, let's remove the physical volume from lvm list
# Now, if we can, let's remove the physical volume from lvm list
if
self
.
loopback
:
if
self
.
loopback
:
p_result
=
util
s
.
run
(
"pvdisplay"
)
p_result
=
proces
s
.
run
(
"pvdisplay"
)
if
self
.
loopback
in
p_result
.
stdout
:
if
self
.
loopback
in
p_result
.
stdout
:
util
s
.
run
(
"pvremove -f %s"
%
self
.
loopback
)
proces
s
.
run
(
"pvremove -f %s"
%
self
.
loopback
)
l_result
=
util
s
.
run
(
'losetup -a'
)
l_result
=
proces
s
.
run
(
'losetup -a'
)
if
self
.
loopback
and
(
self
.
loopback
in
l_result
.
stdout
):
if
self
.
loopback
and
(
self
.
loopback
in
l_result
.
stdout
):
try
:
try
:
util
s
.
run
(
"losetup -d %s"
%
self
.
loopback
)
proces
s
.
run
(
"losetup -d %s"
%
self
.
loopback
)
except
error
.
CmdError
:
except
process
.
CmdError
:
logging
.
error
(
"Failed to liberate loopback %s"
,
self
.
loopback
)
logging
.
error
(
"Failed to liberate loopback %s"
,
self
.
loopback
)
if
os
.
path
.
islink
(
self
.
qcow_file_path
):
if
os
.
path
.
islink
(
self
.
qcow_file_path
):
os
.
remove
(
self
.
qcow_file_path
)
os
.
remove
(
self
.
qcow_file_path
)
...
@@ -108,7 +108,7 @@ class EnospcConfig(object):
...
@@ -108,7 +108,7 @@ class EnospcConfig(object):
os
.
remove
(
self
.
raw_file_path
)
os
.
remove
(
self
.
raw_file_path
)
@
error
.
context_aware
@
error
_context
.
context_aware
def
run
(
test
,
params
,
env
):
def
run
(
test
,
params
,
env
):
"""
"""
ENOSPC test
ENOSPC test
...
@@ -124,11 +124,11 @@ def run(test, params, env):
...
@@ -124,11 +124,11 @@ def run(test, params, env):
:param params: Dictionary with the test parameters.
:param params: Dictionary with the test parameters.
:param env: Dictionary with test environment.
:param env: Dictionary with test environment.
"""
"""
error
.
context
(
"Create a virtual disk on lvm"
)
error
_context
.
context
(
"Create a virtual disk on lvm"
,
logging
.
info
)
enospc_config
=
EnospcConfig
(
test
,
params
)
enospc_config
=
EnospcConfig
(
test
,
params
)
enospc_config
.
setup
()
enospc_config
.
setup
()
error
.
context
(
"Boot up guest with two disks"
)
error
_context
.
context
(
"Boot up guest with two disks"
,
logging
.
info
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
create
()
vm
.
create
()
login_timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
login_timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
...
@@ -144,7 +144,7 @@ def run(test, params, env):
...
@@ -144,7 +144,7 @@ def run(test, params, env):
cmd
=
params
[
"background_cmd"
]
cmd
=
params
[
"background_cmd"
]
cmd
%=
devname
cmd
%=
devname
error
.
context
(
"Continually write data to second disk"
)
error
_context
.
context
(
"Continually write data to second disk"
,
logging
.
info
)
logging
.
info
(
"Sending background cmd '%s'"
,
cmd
)
logging
.
info
(
"Sending background cmd '%s'"
,
cmd
)
session_serial
.
sendline
(
cmd
)
session_serial
.
sendline
(
cmd
)
...
@@ -154,27 +154,27 @@ def run(test, params, env):
...
@@ -154,27 +154,27 @@ def run(test, params, env):
while
i
<
iterations
:
while
i
<
iterations
:
if
vm
.
monitor
.
verify_status
(
"paused"
):
if
vm
.
monitor
.
verify_status
(
"paused"
):
pause_n
+=
1
pause_n
+=
1
error
.
context
(
"Checking all images in use by %s"
%
vm
.
name
,
error
_context
.
context
(
"Checking all images in use by %s"
%
vm
.
name
,
logging
.
info
)
logging
.
info
)
for
image_name
in
vm
.
params
.
objects
(
"images"
):
for
image_name
in
vm
.
params
.
objects
(
"images"
):
image_params
=
vm
.
params
.
object_params
(
image_name
)
image_params
=
vm
.
params
.
object_params
(
image_name
)
try
:
try
:
image
=
qemu_storage
.
QemuImg
(
image_params
,
image
=
qemu_storage
.
QemuImg
(
image_params
,
data_dir
.
get_data_dir
(),
image_name
)
data_dir
.
get_data_dir
(),
image_name
)
image
.
check_image
(
image_params
,
data_dir
.
get_data_dir
())
image
.
check_image
(
image_params
,
data_dir
.
get_data_dir
()
,
force_share
=
True
)
except
(
virt_vm
.
VMError
,
error
.
TestWarn
)
,
e
:
except
virt_vm
.
VMError
,
e
:
logging
.
error
(
e
)
logging
.
error
(
e
)
error
.
context
(
"Guest paused, extending Logical Volume size"
,
error
_context
.
context
(
"Guest paused, extending Logical Volume size"
,
logging
.
info
)
logging
.
info
)
try
:
try
:
util
s
.
run
(
"lvextend -L +200M %s"
%
logical_volume
)
proces
s
.
run
(
"lvextend -L +200M %s"
%
logical_volume
)
except
error
.
CmdError
,
e
:
except
process
.
CmdError
,
e
:
logging
.
debug
(
e
.
result_obj
.
stdout
)
logging
.
debug
(
e
.
result_obj
.
stdout
)
error
.
context
(
"Continue paused guest"
,
logging
.
info
)
error
_context
.
context
(
"Continue paused guest"
,
logging
.
info
)
vm
.
resume
()
vm
.
resume
()
elif
not
vm
.
monitor
.
verify_status
(
"running"
):
elif
not
vm
.
monitor
.
verify_status
(
"running"
):
status
=
str
(
vm
.
monitor
.
info
(
"status"
))
status
=
str
(
vm
.
monitor
.
info
(
"status"
))
raise
error
.
TestE
rror
(
"Unexpected guest status: %s"
%
status
)
test
.
e
rror
(
"Unexpected guest status: %s"
%
status
)
time
.
sleep
(
10
)
time
.
sleep
(
10
)
i
+=
1
i
+=
1
...
@@ -187,7 +187,7 @@ def run(test, params, env):
...
@@ -187,7 +187,7 @@ def run(test, params, env):
logging
.
warn
(
e
)
logging
.
warn
(
e
)
if
pause_n
==
0
:
if
pause_n
==
0
:
raise
error
.
TestF
ail
(
"Guest didn't pause during loop"
)
test
.
f
ail
(
"Guest didn't pause during loop"
)
else
:
else
:
logging
.
info
(
"Guest paused %s times from %s iterations"
,
logging
.
info
(
"Guest paused %s times from %s iterations"
,
pause_n
,
iterations
)
pause_n
,
iterations
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录