From: Amos Kong <akong@redhat.com>
To: autotest@test.kernel.org
Cc: lmr@redhat.com, kvm@vger.kernel.org
Subject: [PATCH 1/3] KVM-test: introduce a verify_status method
Date: Fri, 06 May 2011 23:03:33 +0800 [thread overview]
Message-ID: <20110506150333.5847.56754.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <BANLkTi=H9zx7cBoNbcJ-e7dDYCZdBG9QOQ@mail.gmail.com>
This method is used to check if VM status is same as
we expected.
Signed-off-by: Amos Kong <akong@redhat.com>
---
0 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/client/virt/kvm_monitor.py b/client/virt/kvm_monitor.py
index 7934b07..aff716a 100644
--- a/client/virt/kvm_monitor.py
+++ b/client/virt/kvm_monitor.py
@@ -282,6 +282,18 @@ class HumanMonitor(Monitor):
self.cmd("info status", debug=False)
+ def verify_status(self, status):
+ """
+ Verify VM status
+
+ @param status: Optional VM status, 'running' or 'paused'
+ @return: return True if VM status is same as we expected
+ """
+ o = self.cmd("info status", debug=False)
+ if status=='paused' or status=='running':
+ return (status in o)
+
+
# Command wrappers
# Notes:
# - All of the following commands raise exceptions in a similar manner to
@@ -650,6 +662,20 @@ class QMPMonitor(Monitor):
self.cmd(cmd="query-status", debug=False)
+ def verify_status(self, status):
+ """
+ Verify VM status
+
+ @param status: Optional VM status, 'running' or 'paused'
+ @return: return True if VM status is same as we expected
+ """
+ o = str(self.cmd(cmd="query-status", debug=False))
+ if (status=='paused' and "u'running': False" in o):
+ return True
+ if (status=='running' and "u'running': True" in o):
+ return True
+
+
def get_events(self):
"""
Return a list of the asynchronous events received since the last
diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
index 57fc61b..830ab2e 100644
--- a/client/virt/kvm_vm.py
+++ b/client/virt/kvm_vm.py
@@ -82,6 +82,15 @@ class VM(virt_vm.BaseVM):
return not self.process or not self.process.is_alive()
+ def verify_status(self, status):
+ """
+ Check VM status
+
+ @param status: Optional VM status, 'running' or 'paused'
+ @raise VMStatusError: If the VM status is not same as parameter
+ """
+ if not self.monitor.verify_status(status):
+ raise virt_vm.VMStatusError("VM status is unexpected.")
def clone(self, name=None, params=None, root_dir=None, address_cache=None,
diff --git a/client/virt/virt_vm.py b/client/virt/virt_vm.py
index fd28966..5e9838a 100644
--- a/client/virt/virt_vm.py
+++ b/client/virt/virt_vm.py
@@ -185,6 +185,8 @@ class VMMigrateStateMismatchError(VMMigrateError):
class VMRebootError(VMError):
pass
+class VMStatusError(VMError):
+ pass
def get_image_filename(params, root_dir):
"""
next prev parent reply other threads:[~2011-05-06 15:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-21 6:21 [Autotest PATCH] KVM-test: Simple stop/continue test Amos Kong
2011-04-29 5:05 ` [Autotest] " Lucas Meneghel Rodrigues
2011-05-06 15:03 ` Amos Kong [this message]
2011-05-06 15:03 ` [PATCH 2/3] " Amos Kong
2011-05-06 15:04 ` [PATCH 3/3] KVM-test: Check if guest bootable after reseting several times Amos Kong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110506150333.5847.56754.stgit@localhost6.localdomain6 \
--to=akong@redhat.com \
--cc=autotest@test.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=lmr@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox