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 fsthaw cmd to guest

Signed-off-by: Xiangchun Fu <xfu@redhat.com>
  • Loading branch information
xiangchunfu committed Nov 2, 2018
1 parent 262a0df commit 37c5f88
Show file tree
Hide file tree
Showing 2 changed files with 29 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_reboot_shutdown_fsfreeze:
gagent_check_type = reboot_shutdown
- check_snapshot:
# fsfreeze series commands can't run on windows guest.
type = qemu_guest_agent_snapshot
Expand Down
27 changes: 27 additions & 0 deletions qemu/tests/qemu_guest_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,33 @@ def _action_after_fsfreeze(self, *args):
else:
self.test.fail("FS is not frozen,still can write in guest.")

def gagent_check_reboot_shutdown(self, test, params, env):
"""
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()
try:
for mode in (gagent.SHUTDOWN_MODE_POWERDOWN, gagent.SHUTDOWN_MODE_REBOOT):
try:
gagent.shutdown(mode)
except guest_agent.VAgentCmdError as detail:
if not re.search('guest-shutdown has been disabled', str(detail)):
test.fail("This is not the desired information: ('%s')" % str(detail))
else:
test.fail("agent shutdown command shouldn't succeed for freeze FS")
finally:
try:
gagent.fsthaw(check_status=False)
except Exception:
pass

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

0 comments on commit 37c5f88

Please sign in to comment.