Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
cfdd6e36
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,发现更多精彩内容 >>
未验证
提交
cfdd6e36
编写于
3月 16, 2018
作者:
X
Xu Han
提交者:
GitHub
3月 16, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1250 from xiagao/bug-1508356
qemu_guest_agent:Add check step after thaw FS in guest
上级
43c0ad51
dfd18d16
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
63 addition
and
59 deletion
+63
-59
qemu/tests/qemu_guest_agent.py
qemu/tests/qemu_guest_agent.py
+63
-59
未找到文件。
qemu/tests/qemu_guest_agent.py
浏览文件 @
cfdd6e36
...
...
@@ -5,8 +5,7 @@ import re
import
aexpect
from
autotest.client.shared
import
error
from
autotest.client
import
utils
from
avocado.utils
import
genio
from
avocado.utils
import
path
as
avo_path
from
avocado.utils
import
process
from
avocado.core
import
exceptions
...
...
@@ -189,7 +188,7 @@ class QemuGuestAgentTest(BaseVirtTest):
error_context
.
context
(
"Create a QemuAgent object."
,
logging
.
info
)
if
not
(
args
and
isinstance
(
args
,
tuple
)
and
len
(
args
)
==
2
):
raise
error
.
TestE
rror
(
"Got invalid arguments for guest agent"
)
self
.
test
.
e
rror
(
"Got invalid arguments for guest agent"
)
gagent_serial_type
=
args
[
0
]
gagent_name
=
args
[
1
]
...
...
@@ -212,8 +211,8 @@ class QemuGuestAgentTest(BaseVirtTest):
error_context
.
context
(
"Check if guest agent work."
,
logging
.
info
)
if
not
self
.
gagent
:
raise
error
.
TestError
(
"Could not find guest agent object
"
"for VM '%s'"
%
vm
.
name
)
self
.
test
.
error
(
"Could not find guest agent object
"
"for VM '%s'"
%
vm
.
name
)
self
.
gagent
.
verify_responsive
()
logging
.
info
(
self
.
gagent
.
cmd
(
"guest-info"
))
...
...
@@ -332,7 +331,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
error_context
.
context
(
"Check guest agent command 'guest-shutdown'"
", shutdown mode '%s'"
%
shutdown_mode
,
logging
.
info
)
if
not
self
.
env
or
not
self
.
params
:
raise
error
.
TestE
rror
(
"You should run 'setup' method before test"
)
self
.
test
.
e
rror
(
"You should run 'setup' method before test"
)
if
not
(
self
.
vm
and
self
.
vm
.
is_alive
()):
vm
=
self
.
env
.
get_vm
(
self
.
params
[
"main_vm"
])
...
...
@@ -357,7 +356,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
"""
self
.
__gagent_check_shutdown
(
self
.
gagent
.
SHUTDOWN_MODE_POWERDOWN
)
if
not
utils_misc
.
wait_for
(
self
.
vm
.
is_dead
,
self
.
vm
.
REBOOT_TIMEOUT
):
raise
error
.
TestF
ail
(
"Could not shutdown VM via guest agent'"
)
test
.
f
ail
(
"Could not shutdown VM via guest agent'"
)
@
error_context
.
context_aware
def
gagent_check_reboot
(
self
,
test
,
params
,
env
):
...
...
@@ -373,14 +372,14 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
error_context
.
context
(
"Verify serial output has '%s'"
%
pattern
)
rebooted
=
self
.
__gagent_check_serial_output
(
pattern
)
if
not
rebooted
:
raise
error
.
TestF
ail
(
"Could not reboot VM via guest agent"
)
test
.
f
ail
(
"Could not reboot VM via guest agent"
)
error_context
.
context
(
"Try to re-login to guest after reboot"
)
try
:
session
=
self
.
_get_session
(
self
.
params
,
None
)
session
.
close
()
except
Exception
,
detail
:
raise
error
.
TestFail
(
"Could not login to guest,
"
" detail: '%s'"
%
detail
)
test
.
fail
(
"Could not login to guest
"
" detail: '%s'"
%
detail
)
@
error_context
.
context_aware
def
gagent_check_halt
(
self
,
test
,
params
,
env
):
...
...
@@ -396,7 +395,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
error_context
.
context
(
"Verify serial output has '%s'"
%
pattern
)
halted
=
self
.
__gagent_check_serial_output
(
pattern
)
if
not
halted
:
raise
error
.
TestF
ail
(
"Could not halt VM via guest agent"
)
test
.
f
ail
(
"Could not halt VM via guest agent"
)
# Since VM is halted, force shutdown it.
try
:
self
.
vm
.
destroy
(
gracefully
=
False
)
...
...
@@ -473,8 +472,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
vcpus_num
=
len
(
vcpus_info
)
error_context
.
context
(
"the vcpu number:%d"
%
vcpus_num
,
logging
.
info
)
if
vcpus_num
<
2
:
raise
error
.
TestNAError
(
"the vpus number of guest should be more"
" than 1"
)
test
.
error
(
"the vpus number of guest should be more than 1"
)
vcpus_info
[
vcpus_num
-
1
][
"online"
]
=
False
del
vcpus_info
[
vcpus_num
-
1
][
"can-offline"
]
action
=
{
'vcpus'
:
[
vcpus_info
[
vcpus_num
-
1
]]}
...
...
@@ -482,7 +480,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
# Check if the result is as expected
vcpus_info
=
self
.
gagent
.
get_vcpus
()
if
vcpus_info
[
vcpus_num
-
1
][
"online"
]
is
not
False
:
raise
error
.
TestF
ail
(
"the vcpu status is not changed as expected"
)
test
.
f
ail
(
"the vcpu status is not changed as expected"
)
@
error_context
.
context_aware
def
gagent_check_get_time
(
self
,
test
,
params
,
env
):
...
...
@@ -501,13 +499,13 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
%
nanoseconds_time
,
logging
.
info
)
guest_time
=
session
.
cmd_output
(
get_guest_time_cmd
)
if
not
guest_time
:
raise
error
.
TestE
rror
(
"can't get the guest time for contrast"
)
test
.
e
rror
(
"can't get the guest time for contrast"
)
error_context
.
context
(
"the time get inside guest by shell cmd is '%d' "
%
int
(
guest_time
),
logging
.
info
)
delta
=
abs
(
int
(
guest_time
)
-
nanoseconds_time
/
1000000000
)
if
delta
>
3
:
raise
error
.
TestF
ail
(
"the time get by guest agent is not the same "
"with that by time check cmd inside guest"
)
test
.
f
ail
(
"the time get by guest agent is not the same "
"with that by time check cmd inside guest"
)
@
error_context
.
context_aware
def
gagent_check_set_time
(
self
,
test
,
params
,
env
):
...
...
@@ -523,7 +521,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
error_context
.
context
(
"get the time of the guest"
,
logging
.
info
)
guest_time_before
=
session
.
cmd_output
(
get_guest_time_cmd
)
if
not
guest_time_before
:
raise
error
.
TestE
rror
(
"can't get the guest time for contrast"
)
test
.
e
rror
(
"can't get the guest time for contrast"
)
error_context
.
context
(
"the time before being moved back into past is '%d' "
%
int
(
guest_time_before
),
logging
.
info
)
# Need to move the guest time one week into the past
...
...
@@ -534,8 +532,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
%
int
(
guest_time_after
),
logging
.
info
)
delta
=
abs
(
int
(
guest_time_after
)
-
target_time
/
1000000000
)
if
delta
>
3
:
raise
error
.
TestFail
(
"the time set for guest is not the same "
"with target"
)
test
.
fail
(
"the time set for guest is not the same with target"
)
# Set the system time from the hwclock
if
params
[
"os_type"
]
!=
"windows"
:
move_time_cmd
=
params
[
"move_time_cmd"
]
...
...
@@ -556,8 +553,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
logging
.
info
)
delta
=
abs
(
int
(
guest_time_after_reset
)
-
int
(
guest_hwclock
))
if
delta
>
3
:
raise
error
.
TestFail
(
"The guest time can't be set from hwclock"
" on host"
)
test
.
fail
(
"The guest time can't be set from hwclock on host"
)
@
error_context
.
context_aware
def
_get_mem_used
(
self
,
session
,
cmd
):
...
...
@@ -611,10 +607,10 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
session
.
close
()
# less than 500K is acceptable.
if
memory_usage_after
-
memory_usage_before
>
500
:
raise
error
.
TestF
ail
(
"The memory usages are different, "
"before run command is %skb and after
"
"
run command is %skb"
%
(
memory_usage_before
,
memory_usage_after
))
test
.
f
ail
(
"The memory usages are different, "
"before run command is %skb and
"
"after
run command is %skb"
%
(
memory_usage_before
,
memory_usage_after
))
@
error_context
.
context_aware
def
gagent_check_fstrim
(
self
,
test
,
params
,
env
):
...
...
@@ -654,7 +650,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
device_name
=
os
.
path
.
basename
(
device
)
path
=
"/sys/block/%s/device/scsi_disk"
%
device_name
path
+=
"/%s/provisioning_mode"
%
host_id
return
utils
.
read_one_line
(
path
).
strip
()
return
genio
.
read_one_line
(
path
).
strip
()
def
get_allocation_bitmap
():
"""
...
...
@@ -662,7 +658,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
"""
path
=
"/sys/bus/pseudo/drivers/scsi_debug/map"
try
:
return
utils
.
read_one_line
(
path
).
strip
()
return
genio
.
read_one_line
(
path
).
strip
()
except
IOError
:
logging
.
warn
(
"could not get bitmap info, path '%s' is "
"not exist"
,
path
)
...
...
@@ -678,8 +674,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
bitmap
=
get_allocation_bitmap
()
if
bitmap
:
logging
.
debug
(
"block allocation bitmap: %s"
%
bitmap
)
raise
error
.
TestError
(
"block allocation bitmap"
" not empty before test."
)
test
.
error
(
"block allocation bitmap not empty before test."
)
vm_name
=
params
[
"main_vm"
]
test_image
=
"scsi_debug"
params
[
"start_vm"
]
=
"yes"
...
...
@@ -722,7 +717,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
# check the bitmap before trim
bitmap_before_trim
=
get_allocation_bitmap
()
if
not
re
.
match
(
r
"\d+-\d+"
,
bitmap_before_trim
):
raise
error
.
TestF
ail
(
"didn't get the bitmap of the target disk"
)
test
.
f
ail
(
"didn't get the bitmap of the target disk"
)
error_context
.
context
(
"the bitmap_before_trim is %s"
%
bitmap_before_trim
,
logging
.
info
)
total_block_before_trim
=
abs
(
sum
([
eval
(
i
)
for
i
in
...
...
@@ -736,7 +731,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
# check the bitmap after trim
bitmap_after_trim
=
get_allocation_bitmap
()
if
not
re
.
match
(
r
"\d+-\d+"
,
bitmap_after_trim
):
raise
error
.
TestF
ail
(
"didn't get the bitmap of the target disk"
)
test
.
f
ail
(
"didn't get the bitmap of the target disk"
)
error_context
.
context
(
"the bitmap_after_trim is %s"
%
bitmap_after_trim
,
logging
.
info
)
total_block_after_trim
=
abs
(
sum
([
eval
(
i
)
for
i
in
...
...
@@ -745,8 +740,8 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
%
total_block_after_trim
,
logging
.
info
)
if
total_block_after_trim
>
total_block_before_trim
:
raise
error
.
TestF
ail
(
"the bitmap_after_trim is lager, the command"
"
guest-fstrim may not work"
)
test
.
f
ail
(
"the bitmap_after_trim is lager, the command"
"
guest-fstrim may not work"
)
if
self
.
vm
:
self
.
vm
.
destroy
()
...
...
@@ -772,7 +767,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
# check if the cmd "guest-network-get-interfaces" work
ret
=
self
.
gagent
.
get_network_interface
()
if
not
find_interface_by_name
(
ret
,
"lo"
):
error
.
TestF
ail
(
"didn't find 'lo' interface in the return value"
)
test
.
f
ail
(
"didn't find 'lo' interface in the return value"
)
error_context
.
context
(
"set down the interface: lo"
,
logging
.
info
)
down_interface_cmd
=
"ip link set lo down"
...
...
@@ -790,8 +785,8 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
interfaces_pre_add
]
if
(
len
(
bridge_list
)
!=
1
)
or
\
(
"lo_brige"
!=
bridge_list
[
0
][
"name"
]):
error
.
TestFail
(
"the interface list info after interface was down
"
"
was not as expected"
)
test
.
fail
(
"the interface list info after interface was down
"
"
was not as expected"
)
@
error_context
.
context_aware
def
_action_before_fsfreeze
(
self
,
*
args
):
...
...
@@ -800,21 +795,19 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
@
error_context
.
context_aware
def
_action_after_fsfreeze
(
self
,
*
args
):
error_context
.
context
(
"Verfiy FS is frozen in guest."
)
if
not
isinstance
(
args
,
tuple
):
return
error_context
.
context
(
"Verfiy FS is frozen in guest."
,
logging
.
info
)
if
not
self
.
_open_session_list
:
raise
error
.
TestE
rror
(
"Could not find any opened session"
)
self
.
test
.
e
rror
(
"Could not find any opened session"
)
# Use the last opened session to send cmd.
session
=
self
.
_open_session_list
[
-
1
]
try
:
session
.
cmd
(
self
.
params
[
"gagent_fs_test_cmd"
])
except
aexpect
.
ShellTimeoutError
:
logging
.
debug
(
"FS freeze successfully
."
)
logging
.
info
(
"FS is frozen as expected,can't write in guest
."
)
else
:
raise
error
.
TestFail
(
"FS freeze failed, guest still can"
" write file"
)
self
.
test
.
fail
(
"FS is not frozen,still can write in guest."
)
@
error_context
.
context_aware
def
_action_before_fsthaw
(
self
,
*
args
):
...
...
@@ -822,7 +815,20 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
@
error_context
.
context_aware
def
_action_after_fsthaw
(
self
,
*
args
):
pass
error_context
.
context
(
"Verify FS is thawed in guest."
,
logging
.
info
)
if
not
self
.
_open_session_list
:
session
=
self
.
_get_session
(
self
.
params
,
None
)
self
.
_open_session_list
.
append
(
session
)
# Use the last opened session to send cmd.
session
=
self
.
_open_session_list
[
-
1
]
try
:
session
.
cmd
(
self
.
params
[
"gagent_fs_test_cmd"
])
except
aexpect
.
ShellTimeoutError
:
self
.
test
.
fail
(
"FS is not thawed, still can't write in guest."
)
else
:
logging
.
info
(
"FS is thawed as expected, can write in guest."
)
@
error_context
.
context_aware
def
gagent_check_fsfreeze
(
self
,
test
,
params
,
env
):
...
...
@@ -834,15 +840,15 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
2) Freeze the FS.
3) Check the FS is frozen from both guest agent side and guest os side.
4) Thaw the FS.
5) Check the FS is unfrozen from both guest agent side and guest os side.
:param test: kvm test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environmen.
"""
error
.
base_context
(
"Check guest agent command 'guest-fsfreeze-freeze'"
,
logging
.
info
)
error_context
.
context
(
"Verify FS is thawed and freeze the FS."
)
error_context
.
context
(
"Check guest agent command "
"'guest-fsfreeze-freeze/thaw'"
,
logging
.
info
)
try
:
expect_status
=
self
.
gagent
.
FSFREEZE_STATUS_THAWED
self
.
gagent
.
verify_fsfreeze_status
(
expect_status
)
...
...
@@ -850,14 +856,14 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
# Thaw guest FS if the fs status is incorrect.
self
.
gagent
.
fsthaw
(
check_status
=
False
)
self
.
_action_before_fsfreeze
(
test
,
params
,
env
)
self
.
_action_before_fsfreeze
()
error_context
.
context
(
"Freeze the FS."
,
logging
.
info
)
self
.
gagent
.
fsfreeze
()
try
:
self
.
_action_after_fsfreeze
(
test
,
params
,
env
)
self
.
_action_after_fsfreeze
()
# Next, thaw guest fs.
self
.
_action_before_fsthaw
(
test
,
params
,
env
)
error_context
.
context
(
"Thaw the FS."
)
self
.
_action_before_fsthaw
()
error_context
.
context
(
"Thaw the FS."
,
logging
.
info
)
self
.
gagent
.
fsthaw
()
except
Exception
:
# Thaw fs finally, avoid problem in following cases.
...
...
@@ -869,8 +875,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
" detail: '%s'"
,
detail
)
raise
# Finally, do something after thaw.
self
.
_action_after_fsthaw
(
test
,
params
,
env
)
self
.
_action_after_fsthaw
()
@
error_context
.
context_aware
def
gagent_check_thaw_unfrozen
(
self
,
test
,
params
,
env
):
...
...
@@ -901,8 +906,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
func
=
getattr
(
self
,
chk_type
)
func
(
test
,
params
,
env
)
else
:
raise
error
.
TestError
(
"Could not find matching test, check your"
" config file"
)
test
.
error
(
"Could not find matching test, check your config file"
)
class
QemuGuestAgentBasicCheckWin
(
QemuGuestAgentBasicCheck
):
...
...
@@ -935,7 +939,7 @@ class QemuGuestAgentBasicCheckWin(QemuGuestAgentBasicCheck):
error_context
.
context
(
"Download qemu-ga.msi from website and copy "
"it to guest."
,
logging
.
info
)
utils
.
run
(
gagent_download_cmd
,
float
(
params
.
get
(
"login_timeout"
,
360
)))
process
.
system
(
gagent_download_cmd
,
float
(
params
.
get
(
"login_timeout"
,
360
)))
if
not
os
.
path
.
exists
(
gagent_host_path
):
test
.
error
(
"qemu-ga.msi is not exist, maybe it is not "
"successfully downloaded "
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录