Skip to content

Commit

Permalink
qemu_guest_agent: add new guest agent case
Browse files Browse the repository at this point in the history
1.frozen guest FS
2.send shutdown agent cmd to guest
3.send reboot agent cmd to guest
4.send reset HMP/QMP cmd to guest

Signed-off-by: Xiangchun Fu <xfu@redhat.com>
  • Loading branch information
xiangchunfu committed Mar 28, 2018
1 parent bd33606 commit 6814abd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions qemu/tests/cfg/qemu_guest_agent.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@
no Windows
gagent_check_type = fsfreeze
gagent_fs_test_cmd = "rm -f /tmp/foo; echo foo > /tmp/foo"
- check_reset_reboot_shutdown_fsfreeze:
gagent_check_type = reset_reboot_shutdown
- check_snapshot:
# fsfreeze series commands can't run on windows guest.
type = qemu_guest_agent_snapshot
Expand Down
29 changes: 29 additions & 0 deletions qemu/tests/qemu_guest_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,35 @@ def _action_after_fsfreeze(self, *args):
raise error.TestFail("FS freeze failed, guest still can"
" write file")

def gagent_check_reset_reboot_shutdown(self, test, params, env):

"""
Execute "system_reset" and send "shutdown,reboot"
command to guest agent after FS freezed
:param test: kvm test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
gagent = self.gagent
gagent.fsfreeze()

for mode in (gagent.SHUTDOWN_MODE_POWERDOWN, gagent.SHUTDOWN_MODE_REBOOT):
try:
if gagent.shutdown(mode):
test.fail("agent shutdown command shouldn't succeed for freeze FS")
except guest_agent.VAgentCmdError as detail:
if not re.search('guest-shutdown has been disabled', str(detail)):
test.fail(str(detail))
gagent.verify_fsfreeze_status(gagent.FSFREEZE_STATUS_FROZEN)

if not vm.monitor.cmd("system_reset"):
time.sleep(120)
timeout = int(params.get("login_timeout", 240))
session = self.vm.wait_for_login(timeout=timeout)
vm.graceful_shutdown(60)

@error_context.context_aware
def _action_before_fsthaw(self, *args):
pass
Expand Down

0 comments on commit 6814abd

Please sign in to comment.