Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-libvirt
提交
ac9a49ef
T
tp-libvirt
项目概览
openeuler
/
tp-libvirt
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tp-libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
ac9a49ef
编写于
8月 13, 2020
作者:
C
chunfu wen
提交者:
GitHub
8月 13, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2928 from smitterl/s390_bootmenu
Add test case for s390 boot menu
上级
1190a692
b91d32b2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
104 addition
and
35 deletion
+104
-35
libvirt/tests/cfg/bios/boot_integration.cfg
libvirt/tests/cfg/bios/boot_integration.cfg
+19
-0
libvirt/tests/src/bios/boot_integration.py
libvirt/tests/src/bios/boot_integration.py
+85
-35
未找到文件。
libvirt/tests/cfg/bios/boot_integration.cfg
浏览文件 @
ac9a49ef
...
...
@@ -8,6 +8,16 @@
status_error = "no"
variants:
- define_start_destroy_save_restore_undefine:
no s390-virtio
- check_menu:
only by_qemu_on_s390
expected_text = "s390-ccw Enumerated Boot Menu.*\[2\].*Please choose.*default will boot in 3 seconds.*"
bootmenu_timeout = "3000"
- boot_non_default:
only by_qemu_on_s390
expected_text = "Booting entry #2"
boot_entry = 2
bootmenu_timeout = "60000"
variants:
- boot_dev:
boot_ref = "dev"
...
...
@@ -24,6 +34,7 @@
disk_target_dev = 'sda'
disk_target_bus = 'sata'
- by_seabios:
no s390-virtio
boot_type = "seabios"
loader = "/usr/share/seabios/bios.bin"
loader_type = "rom"
...
...
@@ -31,3 +42,11 @@
bios_reboot_timeout = "1000"
disk_target_dev = 'hda'
disk_target_bus = 'scsi'
- by_qemu_on_s390:
only s390-virtio
only boot_dev
boot_type = "s390_qemu"
smbios_mode = ""
disk_target_dev = 'vda'
disk_target_bus = 'virtio'
loader = ""
libvirt/tests/src/bios/boot_integration.py
浏览文件 @
ac9a49ef
import
time
import
logging
import
os
import
re
from
virttest
import
virsh
from
virttest
import
utils_package
from
virttest.libvirt_xml
import
vm_xml
from
virttest.utils_test
import
libvirt
as
utlv
from
virttest.utils_misc
import
wait_for
from
virttest
import
data_dir
from
virttest
import
libvirt_version
...
...
@@ -29,12 +32,14 @@ def prepare_boot_xml(vmxml, params):
dict_os_attrs
=
{}
logging
.
debug
(
"Set boot loader common attributes"
)
dict_os_attrs
.
update
({
"loader"
:
loader
})
dict_os_attrs
.
update
({
"loader_type"
:
loader_type
})
dict_os_attrs
.
update
({
"loader_readonly"
:
readonly
})
dict_os_attrs
.
update
({
"bootmenu_enable"
:
bootmenu_enable
})
dict_os_attrs
.
update
({
"bootmenu_timeout"
:
bootmenu_timeout
})
dict_os_attrs
.
update
({
"smbios_mode"
:
smbios_mode
})
if
loader
:
dict_os_attrs
.
update
({
"loader"
:
loader
})
dict_os_attrs
.
update
({
"loader_type"
:
loader_type
})
dict_os_attrs
.
update
({
"loader_readonly"
:
readonly
})
if
smbios_mode
:
dict_os_attrs
.
update
({
"smbios_mode"
:
smbios_mode
})
# Set Uefi special attributes
if
boot_type
==
"ovmf"
:
...
...
@@ -56,13 +61,34 @@ def prepare_boot_xml(vmxml, params):
return
vmxml
def
console_check
(
vm
,
pattern
,
debug_log
=
False
):
"""
Return function for use with wait_for.
:param vm: vm to check serial console for
:param pattern: line or pattern to match
:param debug_log: if to log all output for debugging
:return: function returning true if console output matches pattern
"""
def
_matches
():
output
=
vm
.
serial_console
.
get_stripped_output
()
matches
=
re
.
search
(
pattern
,
output
,
re
.
S
)
if
debug_log
:
logging
.
debug
(
"Checked for '%s' in '%s'"
,
pattern
,
output
)
if
matches
:
logging
.
debug
(
"Found '%s' in '%s'"
,
pattern
,
output
)
return
True
return
False
return
_matches
def
run
(
test
,
params
,
env
):
"""
Test Define/undefine/start/destroy/save/restore a OVMF/Seabios domain
with 'boot dev' element or 'boot order' element
Steps:
1) Prepare a typical VM XML for OVMF or Seabios Guest boot
1) Prepare a typical VM XML
, e.g.
for OVMF or Seabios Guest boot
2) Setup boot sequence by element 'boot dev' or 'boot order'
2) Define/undefine/start/destroy/save/restore VM and check result
"""
...
...
@@ -75,6 +101,8 @@ def run(test, params, env):
disk_target_bus
=
params
.
get
(
"disk_target_bus"
,
""
)
save_file
=
os
.
path
.
join
(
data_dir
.
get_tmp_dir
(),
vm_name
+
".save"
)
nvram_file
=
params
.
get
(
"nvram"
,
""
)
expected_text
=
params
.
get
(
"expected_text"
,
None
)
boot_entry
=
params
.
get
(
"boot_entry"
,
None
)
# Back VM XML
vmxml
=
vm_xml
.
VMXML
.
new_from_dumpxml
(
vm_name
)
...
...
@@ -114,38 +142,60 @@ def run(test, params, env):
vmxml
.
undefine
()
virsh_dargs
=
{
"debug"
:
True
,
"ignore_status"
:
True
}
# Start test and check result
ret
=
virsh
.
define
(
vmxml
.
xml
,
**
virsh_dargs
)
stdout_patt
=
"Domain %s defined from %s"
%
(
vm_name
,
vmxml
.
xml
)
utlv
.
check_result
(
ret
,
expected_match
=
[
stdout_patt
])
ret
=
virsh
.
start
(
vm_name
,
**
virsh_dargs
)
stdout_patt
=
"Domain %s started"
%
vm_name
utlv
.
check_result
(
ret
,
expected_match
=
[
stdout_patt
])
vm
.
wait_for_login
()
ret
=
virsh
.
destroy
(
vm_name
,
**
virsh_dargs
)
stdout_patt
=
"Domain %s destroyed"
%
vm_name
utlv
.
check_result
(
ret
,
expected_match
=
[
stdout_patt
])
vm
.
start
()
ret
=
virsh
.
save
(
vm_name
,
save_file
,
**
virsh_dargs
)
stdout_patt
=
"Domain %s saved to %s"
%
(
vm_name
,
save_file
)
utlv
.
check_result
(
ret
,
expected_match
=
[
stdout_patt
])
ret
=
virsh
.
restore
(
save_file
,
**
virsh_dargs
)
stdout_patt
=
"Domain restored from %s"
%
save_file
utlv
.
check_result
(
ret
,
expected_match
=
[
stdout_patt
])
ret
=
virsh
.
undefine
(
vm_name
,
options
=
"--nvram"
,
**
virsh_dargs
)
stdout_patt
=
"Domain %s has been undefined"
%
vm_name
utlv
.
check_result
(
ret
,
expected_match
=
[
stdout_patt
])
if
boot_type
==
"ovmf"
:
if
os
.
path
.
exists
(
nvram_file
):
test
.
fail
(
"nvram file still exists after vm undefine"
)
if
boot_type
==
"s390_qemu"
:
# Start test and check result
ret
=
virsh
.
define
(
vmxml
.
xml
,
**
virsh_dargs
)
ret
=
virsh
.
start
(
vm_name
,
"--paused"
,
**
virsh_dargs
)
time
.
sleep
(
1
)
vm
.
create_serial_console
()
time
.
sleep
(
1
)
vm
.
resume
()
if
not
boot_entry
:
check_boot
=
console_check
(
vm
,
expected_text
)
if
not
wait_for
(
check_boot
,
60
,
1
):
test
.
fail
(
"No boot menu found. Please check log."
)
else
:
vm
.
serial_console
.
send
(
boot_entry
)
time
.
sleep
(
0.5
)
vm
.
serial_console
.
sendcontrol
(
'm'
)
check_boot
=
console_check
(
vm
,
expected_text
)
if
not
wait_for
(
check_boot
,
60
,
1
):
test
.
fail
(
"Boot entry not selected. Please check log."
)
vm
.
wait_for_login
()
else
:
# Start test and check result
ret
=
virsh
.
define
(
vmxml
.
xml
,
**
virsh_dargs
)
stdout_patt
=
"Domain %s defined from %s"
%
(
vm_name
,
vmxml
.
xml
)
utlv
.
check_result
(
ret
,
expected_match
=
[
stdout_patt
])
ret
=
virsh
.
start
(
vm_name
,
**
virsh_dargs
)
stdout_patt
=
"Domain %s started"
%
vm_name
utlv
.
check_result
(
ret
,
expected_match
=
[
stdout_patt
])
vm
.
wait_for_login
()
ret
=
virsh
.
destroy
(
vm_name
,
**
virsh_dargs
)
stdout_patt
=
"Domain %s destroyed"
%
vm_name
utlv
.
check_result
(
ret
,
expected_match
=
[
stdout_patt
])
vm
.
start
()
ret
=
virsh
.
save
(
vm_name
,
save_file
,
**
virsh_dargs
)
stdout_patt
=
"Domain %s saved to %s"
%
(
vm_name
,
save_file
)
utlv
.
check_result
(
ret
,
expected_match
=
[
stdout_patt
])
ret
=
virsh
.
restore
(
save_file
,
**
virsh_dargs
)
stdout_patt
=
"Domain restored from %s"
%
save_file
utlv
.
check_result
(
ret
,
expected_match
=
[
stdout_patt
])
ret
=
virsh
.
undefine
(
vm_name
,
options
=
"--nvram"
,
**
virsh_dargs
)
stdout_patt
=
"Domain %s has been undefined"
%
vm_name
utlv
.
check_result
(
ret
,
expected_match
=
[
stdout_patt
])
if
boot_type
==
"ovmf"
:
if
os
.
path
.
exists
(
nvram_file
):
test
.
fail
(
"nvram file still exists after vm undefine"
)
finally
:
logging
.
debug
(
"Start to cleanup"
)
if
vm
.
is_alive
:
vm
.
destroy
()
logging
.
debug
(
"Restore the VM XML"
)
vmxml_backup
.
define
()
vmxml_backup
.
sync
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录