Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
8592a19d
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,发现更多精彩内容 >>
提交
8592a19d
编写于
11月 16, 2016
作者:
X
Xu Tian
提交者:
GitHub
11月 16, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #810 from xutian/fix_rh_kernel_update
qemu.tests: use snapshot to avoid backup and retore steps
上级
69a844e7
f40cedc8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
150 addition
and
208 deletion
+150
-208
qemu/tests/cfg/rh_kernel_update.cfg
qemu/tests/cfg/rh_kernel_update.cfg
+3
-0
qemu/tests/rh_kernel_update.py
qemu/tests/rh_kernel_update.py
+147
-208
未找到文件。
qemu/tests/cfg/rh_kernel_update.cfg
浏览文件 @
8592a19d
...
...
@@ -13,6 +13,9 @@
only i386 x86_64 PAE ppc64 ppc64le
no RHEL.3.9
type = rh_kernel_update
start_vm = yes
kill_vm = yes
image_snapshot = yes
rpm_timeout = 1200
# Please update your file share web server url before test
download_root_url = "http://download.xxx.com"
...
...
qemu/tests/rh_kernel_update.py
浏览文件 @
8592a19d
...
...
@@ -6,6 +6,8 @@ import logging
from
autotest.client.shared
import
error
from
autotest.client.shared
import
utils
from
virttest
import
storage
from
virttest
import
data_dir
from
virttest
import
utils_misc
...
...
@@ -20,19 +22,15 @@ def run(test, params, env):
2) Get latest kernel package link from brew
3) Verify the version of guest kernel
4) Compare guest kernel version and brew latest kernel version
5) Backup boot cfg file
6) Install guest kernel firmware (Optional)
7) Install guest kernel
8) Install guest kernel debuginfo (Optional)
9) Backup boot cfg file after installing new kernel
10) Installing virtio driver (Optional)
11) Backup initrd file
12) Update initrd file
13) Make the new installed kernel as default
14) Backup boot cfg file after setting new kernel as default
15) Update the guest kernel cmdline (Optional)
16) Reboot guest after updating kernel
17) Verifying the virtio drivers (Optional)
5) Install guest kernel firmware (Optional)
6) Install guest kernel
7) Install guest kernel debuginfo (Optional)
8) Installing virtio driver (Optional)
9) Update initrd file
10) Make the new installed kernel as default
11) Update the guest kernel cmdline (Optional)
12) Reboot guest after updating kernel
13) Verifying the virtio drivers (Optional)
@param test: QEMU test object
@param params: Dictionary with the test parameters
...
...
@@ -297,204 +295,145 @@ def run(test, params, env):
logging
.
info
(
"Kernel rpm : %s"
%
kernel_rpm
)
logging
.
info
(
"Firmware rpm : %s"
%
firmware_rpm
)
boot_cfg_path
=
params
.
get
(
"boot_cfg_path"
,
"/boot/grub/grub.conf"
)
bootcfg_backup_cmd
=
"\cp -af {0} {0}-bk"
.
format
(
boot_cfg_path
)
bootcfg_restore_cmd
=
"\cp -af {0}-bk {0}"
.
format
(
boot_cfg_path
)
count
=
0
try
:
error
.
context
(
"Backup '%s'"
%
boot_cfg_path
)
s
,
o
=
session
.
cmd_status_output
(
bootcfg_backup_cmd
)
# judge if need to install a new kernel
ifupdatekernel
=
True
guest_version
=
get_guest_kernel_version
()
if
compare_kernel_version
(
kernel_version
,
guest_version
):
ifupdatekernel
=
False
# set kernel_version to current version for later step to use
kernel_version
=
guest_version
if
is_kernel_debuginfo_installed
():
install_knl_debuginfo
=
"no"
if
is_virtio_driver_installed
():
install_virtio
=
"no"
else
:
logging
.
info
(
"The guest kerenl is %s but expected is %s"
%
(
guest_version
,
kernel_version
))
rpm_install_func
=
install_rpm
if
params
.
get
(
"install_rpm_from_local"
)
==
"yes"
:
rpm_install_func
=
copy_and_install_rpm
kernel_deps_pkgs
=
params
.
get
(
"kernel_deps_pkgs"
,
"dracut"
).
split
()
if
kernel_deps_pkgs
:
for
pkg
in
kernel_deps_pkgs
:
arch
=
params
.
get
(
"arch_%s"
%
pkg
,
params
.
get
(
"vm_arch_name"
))
upgrade_guest_pkgs
(
session
,
pkg
,
arch
)
if
firmware_rpm
:
error
.
context
(
"Install guest kernel firmware"
,
logging
.
info
)
rpm_install_func
(
session
,
firmware_rpm
,
upgrade
=
True
)
error
.
context
(
"Install guest kernel"
,
logging
.
info
)
rpm_install_func
(
session
,
kernel_rpm
)
kernel_path
=
"/boot/vmlinuz-%s"
%
kernel_version
if
install_knl_debuginfo
==
"yes"
:
error
.
context
(
"Installing kernel-debuginfo packages"
,
logging
.
info
)
links
=
""
for
r
in
knl_dbginfo_rpm
:
links
+=
" %s"
%
r
install_rpm
(
session
,
links
)
if
install_virtio
==
"yes"
:
error
.
context
(
"Installing virtio driver"
,
logging
.
info
)
initrd_prob_cmd
=
"grubby --info=%s"
%
kernel_path
s
,
o
=
session
.
cmd_status_output
(
initrd_prob_cmd
)
if
s
!=
0
:
raise
error
.
TestError
(
"Failed to backup '%s', guest output: '%s'"
%
(
boot_cfg_path
,
o
))
count
=
1
# judge if need to install a new kernel
ifupdatekernel
=
True
guest_version
=
get_guest_kernel_version
()
if
compare_kernel_version
(
kernel_version
,
guest_version
):
ifupdatekernel
=
False
# set kernel_version to current version for later step to use
kernel_version
=
guest_version
if
is_kernel_debuginfo_installed
():
install_knl_debuginfo
=
"no"
if
is_virtio_driver_installed
():
install_virtio
=
"no"
else
:
logging
.
info
(
"The guest kerenl is %s but expected is %s"
%
(
guest_version
,
kernel_version
))
rpm_install_func
=
install_rpm
if
params
.
get
(
"install_rpm_from_local"
)
==
"yes"
:
rpm_install_func
=
copy_and_install_rpm
kernel_deps_pkgs
=
params
.
get
(
"kernel_deps_pkgs"
,
"dracut"
).
split
()
if
kernel_deps_pkgs
:
for
pkg
in
kernel_deps_pkgs
:
arch
=
params
.
get
(
"arch_%s"
%
pkg
,
params
.
get
(
"vm_arch_name"
))
upgrade_guest_pkgs
(
session
,
pkg
,
arch
)
if
firmware_rpm
:
error
.
context
(
"Install guest kernel firmware"
,
logging
.
info
)
rpm_install_func
(
session
,
firmware_rpm
,
upgrade
=
True
)
error
.
context
(
"Install guest kernel"
,
logging
.
info
)
status
=
rpm_install_func
(
session
,
kernel_rpm
)
if
status
:
count
=
2
error
.
context
(
"Backup '%s' after installing new kernel"
%
boot_cfg_path
,
logging
.
info
)
s
,
o
=
session
.
cmd_status_output
(
bootcfg_backup_cmd
)
if
s
!=
0
:
msg
=
(
"Fail to backup '%s' after updating kernel,"
" guest output: '%s'"
%
(
boot_cfg_path
,
o
))
logging
.
error
(
msg
)
raise
error
.
TestError
(
msg
)
kernel_path
=
"/boot/vmlinuz-%s"
%
kernel_version
if
install_knl_debuginfo
==
"yes"
:
error
.
context
(
"Installing kernel-debuginfo packages"
,
logging
.
info
)
links
=
""
for
r
in
knl_dbginfo_rpm
:
links
+=
" %s"
%
r
install_rpm
(
session
,
links
)
if
install_virtio
==
"yes"
:
error
.
context
(
"Installing virtio driver"
,
logging
.
info
)
initrd_prob_cmd
=
"grubby --info=%s"
%
kernel_path
s
,
o
=
session
.
cmd_status_output
(
initrd_prob_cmd
)
if
s
!=
0
:
msg
=
(
"Could not get guest kernel information,"
" guest output: '%s'"
%
o
)
logging
.
error
(
msg
)
raise
error
.
TestError
(
msg
)
msg
=
(
"Could not get guest kernel information,"
" guest output: '%s'"
%
o
)
logging
.
error
(
msg
)
raise
error
.
TestError
(
msg
)
try
:
initrd_path
=
re
.
findall
(
"initrd=(.*)"
,
o
)[
0
]
except
IndexError
:
raise
error
.
TestError
(
"Could not get initrd path from guest,"
" guest output: '%s'"
%
o
)
driver_list
=
[
"--with=%s "
%
drv
for
drv
in
virtio_drivers
]
mkinitrd_cmd
=
"mkinitrd -f %s "
%
initrd_path
mkinitrd_cmd
+=
""
.
join
(
driver_list
)
mkinitrd_cmd
+=
" %s"
%
kernel_version
cp_initrd_cmd
=
"\cp -af %s %s-bk"
%
(
initrd_path
,
initrd_path
)
restore_initrd_cmd
=
"\cp -af %s-bk %s"
%
(
initrd_path
,
initrd_path
)
error
.
context
(
"Backup initrd file"
)
s
,
o
=
session
.
cmd_status_output
(
cp_initrd_cmd
,
timeout
=
200
)
if
s
!=
0
:
logging
.
error
(
"Failed to backup guest initrd,"
" guest output: '%s'"
,
o
)
error
.
context
(
"Update initrd file"
,
logging
.
info
)
s
,
o
=
session
.
cmd_status_output
(
mkinitrd_cmd
,
timeout
=
360
)
if
s
!=
0
:
msg
=
"Failed to install virtio driver, guest output '%s'"
%
o
logging
.
error
(
msg
)
raise
error
.
TestFail
(
msg
)
count
=
3
# make sure the newly installed kernel as default
if
ifupdatekernel
:
error
.
context
(
"Make the new installed kernel as default"
,
logging
.
info
)
make_def_cmd
=
"grubby --set-default=%s "
%
kernel_path
s
,
o
=
session
.
cmd_status_output
(
make_def_cmd
)
if
s
!=
0
:
msg
=
(
"Fail to set %s as default kernel,"
" guest output: '%s'"
%
(
kernel_path
,
o
))
logging
.
error
(
msg
)
raise
error
.
TestError
(
msg
)
count
=
4
error
.
context
(
"Backup '%s' after setting new kernel as default"
%
boot_cfg_path
)
s
,
o
=
session
.
cmd_status_output
(
bootcfg_backup_cmd
)
if
s
!=
0
:
msg
=
(
"Fail to backup '%s', guest output: '%s'"
%
(
boot_cfg_path
,
o
))
logging
.
error
(
msg
)
raise
error
.
TestError
(
msg
)
# remove or add the required arguments
error
.
context
(
"Update the guest kernel cmdline"
,
logging
.
info
)
remove_args_list
=
[
"--remove-args=%s "
%
arg
for
arg
in
args_removed
]
update_kernel_cmd
=
"grubby --update-kernel=%s "
%
kernel_path
update_kernel_cmd
+=
""
.
join
(
remove_args_list
)
update_kernel_cmd
+=
'--args="%s"'
%
" "
.
join
(
args_added
)
s
,
o
=
session
.
cmd_status_output
(
update_kernel_cmd
)
try
:
initrd_path
=
re
.
findall
(
"initrd=(.*)"
,
o
)[
0
]
except
IndexError
:
raise
error
.
TestError
(
"Could not get initrd path from guest,"
" guest output: '%s'"
%
o
)
driver_list
=
[
"--with=%s "
%
drv
for
drv
in
virtio_drivers
]
mkinitrd_cmd
=
"mkinitrd -f %s "
%
initrd_path
mkinitrd_cmd
+=
""
.
join
(
driver_list
)
mkinitrd_cmd
+=
" %s"
%
kernel_version
error
.
context
(
"Update initrd file"
,
logging
.
info
)
s
,
o
=
session
.
cmd_status_output
(
mkinitrd_cmd
,
timeout
=
360
)
if
s
!=
0
:
msg
=
"Fail to modify the kernel cmdline, guest output: '%s'"
%
o
msg
=
"Failed to install virtio driver, guest output '%s'"
%
o
logging
.
error
(
msg
)
raise
error
.
TestFail
(
msg
)
# make sure the newly installed kernel as default
if
ifupdatekernel
:
error
.
context
(
"Make the new installed kernel as default"
,
logging
.
info
)
make_def_cmd
=
"grubby --set-default=%s "
%
kernel_path
s
,
o
=
session
.
cmd_status_output
(
make_def_cmd
)
if
s
!=
0
:
msg
=
(
"Fail to set %s as default kernel,"
" guest output: '%s'"
%
(
kernel_path
,
o
))
logging
.
error
(
msg
)
raise
error
.
TestError
(
msg
)
count
=
5
# upgrade listed packages to latest version.
for
pkg
in
params
.
get
(
"upgrade_pkgs"
,
""
).
split
():
_
=
params
.
object_params
(
pkg
)
arch
=
_
.
get
(
"vm_arch_name"
,
"x86_64"
)
nodeps
=
_
.
get
(
"ignore_deps"
)
==
"yes"
install_debuginfo
=
_
.
get
(
"install_debuginfo"
)
==
"yes"
timeout
=
int
(
_
.
get
(
"install_pkg_timeout"
,
"600"
))
ver_before
=
session
.
cmd_output
(
"rpm -q %s"
%
pkg
)
upgrade_guest_pkgs
(
session
,
pkg
,
arch
,
install_debuginfo
,
nodeps
,
timeout
)
ver_after
=
session
.
cmd_output
(
"rpm -q %s"
%
pkg
)
if
"not installed"
in
ver_before
:
mesg
=
"Install '%s' in guest"
%
ver_after
else
:
mesg
=
"Upgrade '%s' from '%s' to '%s'"
%
(
pkg
,
ver_before
,
ver_after
)
logging
.
info
(
mesg
)
# reboot guest
error
.
context
(
"Reboot guest after updating kernel"
,
logging
.
info
)
time
.
sleep
(
int
(
params
.
get
(
"sleep_before_reset"
,
10
)))
session
=
vm
.
reboot
(
session
,
'shell'
,
timeout
=
login_timeout
)
# check if the guest can bootup normally after kernel update
guest_version
=
get_guest_kernel_version
()
if
guest_version
!=
kernel_version
:
raise
error
.
TestFail
(
"Fail to verify the guest kernel,
\n
"
"Expceted version %s
\n
"
"In fact version %s
\n
"
%
(
kernel_version
,
guest_version
))
if
verify_virtio
==
"yes"
:
error
.
context
(
"Verifying the virtio drivers"
,
logging
.
info
)
if
not
is_virtio_driver_installed
():
raise
error
.
TestFail
(
"Fail to verify the installation of"
" virtio drivers"
)
except
Exception
:
if
count
in
[
4
,
3
,
1
]:
# restore boot cfg
s
,
o
=
session
.
cmd_status_output
(
bootcfg_restore_cmd
,
timeout
=
100
)
if
s
!=
0
:
logging
.
error
(
"Failed to execute cmd '%s' in guest,"
" guest output: '%s'"
,
bootcfg_restore_cmd
,
o
)
elif
count
==
2
and
restore_initrd_cmd
:
# restore initrd file
s
,
o
=
session
.
cmd_status_output
(
restore_initrd_cmd
,
timeout
=
200
)
if
s
!=
0
:
logging
.
error
(
"Failed to execute cmd '%s' in guest,"
" guest output: '%s'"
,
restore_initrd_cmd
,
o
)
raise
# remove or add the required arguments
error
.
context
(
"Update the guest kernel cmdline"
,
logging
.
info
)
remove_args_list
=
[
"--remove-args=%s "
%
arg
for
arg
in
args_removed
]
update_kernel_cmd
=
"grubby --update-kernel=%s "
%
kernel_path
update_kernel_cmd
+=
""
.
join
(
remove_args_list
)
update_kernel_cmd
+=
'--args="%s"'
%
" "
.
join
(
args_added
)
s
,
o
=
session
.
cmd_status_output
(
update_kernel_cmd
)
if
s
!=
0
:
msg
=
"Fail to modify the kernel cmdline, guest output: '%s'"
%
o
logging
.
error
(
msg
)
raise
error
.
TestError
(
msg
)
# upgrade listed packages to latest version.
for
pkg
in
params
.
get
(
"upgrade_pkgs"
,
""
).
split
():
_
=
params
.
object_params
(
pkg
)
arch
=
_
.
get
(
"vm_arch_name"
,
"x86_64"
)
nodeps
=
_
.
get
(
"ignore_deps"
)
==
"yes"
install_debuginfo
=
_
.
get
(
"install_debuginfo"
)
==
"yes"
timeout
=
int
(
_
.
get
(
"install_pkg_timeout"
,
"600"
))
ver_before
=
session
.
cmd_output
(
"rpm -q %s"
%
pkg
)
upgrade_guest_pkgs
(
session
,
pkg
,
arch
,
install_debuginfo
,
nodeps
,
timeout
)
ver_after
=
session
.
cmd_output
(
"rpm -q %s"
%
pkg
)
if
"not installed"
in
ver_before
:
mesg
=
"Install '%s' in guest"
%
ver_after
else
:
mesg
=
"Upgrade '%s' from '%s' to '%s'"
%
(
pkg
,
ver_before
,
ver_after
)
logging
.
info
(
mesg
)
# reboot guest
error
.
context
(
"Reboot guest after updating kernel"
,
logging
.
info
)
time
.
sleep
(
int
(
params
.
get
(
"sleep_before_reset"
,
10
)))
session
=
vm
.
reboot
(
session
,
'shell'
,
timeout
=
login_timeout
)
# check if the guest can bootup normally after kernel update
guest_version
=
get_guest_kernel_version
()
if
guest_version
!=
kernel_version
:
raise
error
.
TestFail
(
"Fail to verify the guest kernel,
\n
"
"Expceted version %s
\n
"
"In fact version %s
\n
"
%
(
kernel_version
,
guest_version
))
if
verify_virtio
==
"yes"
:
error
.
context
(
"Verifying the virtio drivers"
,
logging
.
info
)
if
not
is_virtio_driver_installed
():
raise
error
.
TestFail
(
"Fail to verify the installation of"
" virtio drivers"
)
error
.
context
(
"OS updated, commit changes to disk"
,
logging
.
info
)
base_dir
=
params
.
get
(
"images_base_dir"
,
data_dir
.
get_data_dir
())
image_filename
=
storage
.
get_image_filename
(
params
,
base_dir
)
logging
.
info
(
"image file name: %s"
%
image_filename
)
block
=
vm
.
get_block
({
"backing_file"
:
image_filename
})
vm
.
monitor
.
send_args_cmd
(
"commit %s"
%
block
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录