Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qemu_guest_agent: add new guest agent case #1032

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless try, better to raise original exception

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed try. use 'if' to instead of try.
if self.gagent.shutdown(self.gagent.SHUTDOWN_MODE_POWERDOWN):
self.gagent.verify_fsfreeze_status(self.gagent.FSFREEZE_STATUS_FROZEN)

    if self.gagent.shutdown(self.gagent.SHUTDOWN_MODE_REBOOT):
        self.gagent.verify_fsfreeze_status(self.gagent.FSFREEZE_STATUS_FROZEN)

    if vm.monitor.cmd("system_reset"):
        self.gagent.verify_fsfreeze_status(self.gagent.FSFREEZE_STATUS_THAWED)

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