Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
b916734b
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,发现更多精彩内容 >>
未验证
提交
b916734b
编写于
11月 01, 2018
作者:
Y
YongxueHong
提交者:
GitHub
11月 01, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1504 from aliang123/1550397
optmize block_hotplug_negative to support raw disk's hotplug
上级
fa44d40b
9b1f8bac
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
63 deletion
+29
-63
qemu/tests/block_hotplug_negative.py
qemu/tests/block_hotplug_negative.py
+22
-61
qemu/tests/cfg/block_hotplug_negative.cfg
qemu/tests/cfg/block_hotplug_negative.cfg
+7
-2
未找到文件。
qemu/tests/block_hotplug_negative.py
浏览文件 @
b916734b
import
logging
import
logging
import
time
import
time
from
virttest
import
data_dir
from
virttest
import
storage
from
virttest
import
error_context
from
virttest
import
error_context
from
virttest.qemu_devices
import
qdevices
@
error_context
.
context_aware
@
error_context
.
context_aware
...
@@ -14,26 +11,15 @@ def run(test, params, env):
...
@@ -14,26 +11,15 @@ def run(test, params, env):
1) Boot up guest without block device.
1) Boot up guest without block device.
2) Hotplug a drive
2) Hotplug a drive
2) Ho
plug block device with invalid blk params.
3) Hot
plug block device with invalid blk params.
3
) Unplug the drive
4
) Unplug the drive
4
) Hotplug the drive again
5
) Hotplug the drive again
5
) Check vm is alive after drive unplug/hotplug
6
) Check vm is alive after drive unplug/hotplug
:param test: QEMU test object.
:param test: QEMU test object.
: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.
"""
"""
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
):
def
drive_unplug_plug
(
drive
,
vm
):
"""
"""
Unplug drive then replug it.
Unplug drive then replug it.
...
@@ -47,55 +33,30 @@ def run(test, params, env):
...
@@ -47,55 +33,30 @@ def run(test, params, env):
error_context
.
context
(
"Hotplug the drive"
,
logging
.
info
)
error_context
.
context
(
"Hotplug the drive"
,
logging
.
info
)
drive
.
hotplug
(
vm
.
monitor
)
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
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
vm
.
verify_alive
()
error_context
.
context
(
"Hotplug block device"
,
logging
.
info
)
error_context
.
context
(
"Hotplug block device"
,
logging
.
info
)
for
num
in
range
(
blk_num
):
img_list
=
params
.
get
(
"images"
).
split
()
device
=
qdevices
.
QDevice
(
pci_type
)
image_name
=
img_list
[
-
1
]
drive
=
qdevices
.
QRHDrive
(
"block%d"
%
num
)
image_params
=
params
.
object_params
(
image_name
)
drive
.
set_param
(
"file"
,
find_image
(
img_list
[
num
+
1
]))
devs
=
vm
.
devices
.
images_define_by_params
(
image_name
,
drive
.
set_param
(
"format"
,
img_format_type
)
image_params
,
'disk'
)
drive_id
=
drive
.
get_param
(
"id"
)
drive
=
devs
[
-
2
]
drive
.
hotplug
(
vm
.
monitor
)
for
dev
in
devs
:
#add controller if needed
try
:
if
params
.
get
(
"need_controller"
,
"no"
)
==
"yes"
:
ret
=
vm
.
devices
.
simple_hotplug
(
dev
,
vm
.
monitor
)
controller_model
=
params
.
get
(
"controller_model"
)
except
Exception
as
e
:
controller
=
qdevices
.
QDevice
(
controller_model
)
if
"QMP command 'device_add' failed"
in
str
(
e
):
bus_extra_param
=
params
.
get
(
"bus_extra_params_%s"
%
img_list
[
num
+
1
])
logging
.
info
(
"Failed to hotplug device with invalid params"
)
if
bus_extra_param
:
try
:
key
,
value
=
bus_extra_param
.
split
(
"="
)
qdevice_params
=
{
key
:
value
}
controller
.
params
.
update
(
qdevice_params
)
try
:
controller
.
hotplug
(
vm
.
monitor
)
except
Exception
as
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
as
e
:
if
"QMP command 'device_add' failed"
in
str
(
e
):
logging
.
info
(
"Failed to add block with invalid params"
)
drive_unplug_plug
(
drive
,
vm
)
drive_unplug_plug
(
drive
,
vm
)
except
Exception
as
e
:
test
.
fail
(
"Failed to hotplug/unplug drive with error:"
"%s"
)
%
e
error_context
.
context
(
"Check vm is alive after drive unplug/hotplug test"
,
logging
.
info
)
error_context
.
context
(
"Check vm is alive after drive unplug/hotplug test"
,
logging
.
info
)
session
=
vm
.
wait_for_login
()
session
=
vm
.
wait_for_login
()
if
not
session
.
is_responsive
():
if
not
session
.
is_responsive
():
session
.
close
()
session
.
close
()
...
...
qemu/tests/cfg/block_hotplug_negative.cfg
浏览文件 @
b916734b
...
@@ -14,16 +14,21 @@
...
@@ -14,16 +14,21 @@
remove_image_stg0 = yes
remove_image_stg0 = yes
force_create_image_stg0 = yes
force_create_image_stg0 = yes
kill_vm_on_error = yes
kill_vm_on_error = yes
blk_num = 1
blk_extra_params_stg0 = "invalid_param=on"
blk_extra_params_stg0 = "invalid_param=on"
variants:
variants:
- @default:
- @default:
- data_plane:
- data_plane:
no Host_RHEL.m6
no Host_RHEL.m6
only virtio_blk, virtio_scsi
iothreads = iothread0
iothreads = iothread0
virtio_blk:
virtio_blk:
blk_extra_params_image1 = "iothread=${iothreads}"
blk_extra_params_image1 = "iothread=${iothreads}"
virtio_scsi:
virtio_scsi:
no Host_RHEL.m7.u0, Host_RHEL.m7.u1, Host_RHEL.m7.u2
no Host_RHEL.m7.u0, Host_RHEL.m7.u1, Host_RHEL.m7.u2
bus_extra_params_image1 = "iothread=${iothreads}"
bus_extra_params = "iothread=${iothreads}"
Windows:
i440fx:
cd_format_cd1 = ide
q35:
cd_format_cd1 = ahci
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录