@@ -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
@@ -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,
@@ -185,6 +185,8 @@ class VMMigrateStateMismatchError(VMMigrateError):
class VMRebootError(VMError):
pass
+class VMStatusError(VMError):
+ pass
def get_image_filename(params, root_dir):
"""
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(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html