Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
f60e70f5
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,发现更多精彩内容 >>
未验证
提交
f60e70f5
编写于
11月 13, 2017
作者:
X
Xu Han
提交者:
GitHub
11月 13, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1084 from aliang123/1467486
New case: block_hotplug_negative
上级
c93cd863
cc76473d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
132 addition
and
0 deletion
+132
-0
qemu/tests/block_hotplug_negative.py
qemu/tests/block_hotplug_negative.py
+103
-0
qemu/tests/cfg/block_hotplug_negative.cfg
qemu/tests/cfg/block_hotplug_negative.cfg
+29
-0
未找到文件。
qemu/tests/block_hotplug_negative.py
0 → 100644
浏览文件 @
f60e70f5
import
logging
import
time
from
virttest
import
data_dir
from
virttest
import
storage
from
virttest
import
error_context
from
virttest.qemu_devices
import
qdevices
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Test hotplug of block devices.
1) Boot up guest without block device.
2) Hotplug a drive
2) Hoplug block device with invalid blk params.
3) Unplug the drive
4) Hotplug the drive again
5) Check vm is alive after drive unplug/hotplug
:param test: QEMU test object.
:param params: Dictionary with the test parameters.
:param env: Dictionary with test environment.
"""
def
find_image
(
image_name
):
"""
Find the path of the iamge.
:param image_name: name of image.
:return mage_filename: filename of image.
"""
image_params
=
params
.
object_params
(
image_name
)
image_filename
=
storage
.
get_image_filename
(
image_params
,
data_dir
.
get_data_dir
())
return
image_filename
def
drive_unplug_plug
(
drive
,
vm
):
"""
Unplug drive then replug it.
:param drive: instance of QRHDrive
:param vm: Vitual Machine object
"""
error_context
.
context
(
"unplug the drive"
,
logging
.
info
)
drive
.
unplug
(
vm
.
monitor
)
time
.
sleep
(
5
)
error_context
.
context
(
"Hotplug the drive"
,
logging
.
info
)
drive
.
hotplug
(
vm
.
monitor
)
img_list
=
params
.
get
(
"images"
).
split
()
img_format_type
=
params
.
get
(
"img_format_type"
,
"qcow2"
)
pci_type
=
params
.
get
(
"pci_type"
,
"virtio-blk-pci"
)
blk_num
=
int
(
params
.
get
(
"blk_num"
,
1
))
add_block_device
=
True
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
error_context
.
context
(
"Hotplug block device"
,
logging
.
info
)
for
num
in
xrange
(
blk_num
):
device
=
qdevices
.
QDevice
(
pci_type
)
drive
=
qdevices
.
QRHDrive
(
"block%d"
%
num
)
drive
.
set_param
(
"file"
,
find_image
(
img_list
[
num
+
1
]))
drive
.
set_param
(
"format"
,
img_format_type
)
drive_id
=
drive
.
get_param
(
"id"
)
drive
.
hotplug
(
vm
.
monitor
)
#add controller if needed
if
params
.
get
(
"need_controller"
,
"no"
)
==
"yes"
:
controller_model
=
params
.
get
(
"controller_model"
)
controller
=
qdevices
.
QDevice
(
controller_model
)
bus_extra_param
=
params
.
get
(
"bus_extra_params_%s"
%
img_list
[
num
+
1
])
if
bus_extra_param
:
key
,
value
=
bus_extra_param
.
split
(
"="
)
qdevice_params
=
{
key
:
value
}
controller
.
params
.
update
(
qdevice_params
)
try
:
controller
.
hotplug
(
vm
.
monitor
)
except
Exception
,
e
:
if
"QMP command 'device_add' failed"
in
str
(
e
):
logging
.
info
(
"Failed to add controller with invalid params"
)
drive_unplug_plug
(
drive
,
vm
)
add_block_device
=
False
if
add_block_device
:
device
.
set_param
(
"drive"
,
drive_id
)
device
.
set_param
(
"id"
,
"block%d"
%
num
)
blk_extra_param
=
params
.
get
(
"blk_extra_params_%s"
%
img_list
[
num
+
1
])
if
blk_extra_param
:
key
,
value
=
blk_extra_param
.
split
(
"="
)
device
.
set_param
(
key
,
value
)
try
:
device
.
hotplug
(
vm
.
monitor
)
except
Exception
,
e
:
if
"QMP command 'device_add' failed"
in
str
(
e
):
logging
.
info
(
"Failed to add block with invalid params"
)
drive_unplug_plug
(
drive
,
vm
)
error_context
.
context
(
"Check vm is alive after drive unplug/hotplug test"
,
logging
.
info
)
session
=
vm
.
wait_for_login
()
if
not
session
.
is_responsive
():
session
.
close
()
test
.
fail
(
"VM can't work normally after drive unplug->hotplug"
)
session
.
close
()
qemu/tests/cfg/block_hotplug_negative.cfg
0 → 100644
浏览文件 @
f60e70f5
# 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_hotplug_negative:
no RHEL.3.9
no ide
virt_test_type = qemu
type = block_hotplug_negative
bootindex_image1 = 0
images += " stg0"
boot_drive_stg0 = no
image_name_stg0 = images/storage0
image_size_stg0 = 1G
remove_image_stg0 = yes
force_create_image_stg0 = yes
kill_vm_on_error = yes
blk_num = 1
blk_extra_params_stg0 = "invalid_param=on"
variants:
- @default:
- data_plane:
no Host_RHEL.m6
iothreads = iothread0
virtio_blk:
blk_extra_params_image1 = "iothread=${iothreads}"
virtio_scsi:
no Host_RHEL.m7.u0, Host_RHEL.m7.u1, Host_RHEL.m7.u2
bus_extra_params_image1 = "iothread=${iothreads}"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录