thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ae23c9
From e589d367bbab2f9e30ea0896cf7728b8a296f407 Mon Sep 17 00:00:00 2001
ae23c9
From: Kevin Wolf <kwolf@redhat.com>
ae23c9
Date: Tue, 26 Jun 2018 09:48:44 +0200
ae23c9
Subject: [PATCH 136/268] qemu-iotests: Add VM.run_job()
ae23c9
ae23c9
RH-Author: Kevin Wolf <kwolf@redhat.com>
ae23c9
Message-id: <20180626094856.6924-62-kwolf@redhat.com>
ae23c9
Patchwork-id: 81080
ae23c9
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 61/73] qemu-iotests: Add VM.run_job()
ae23c9
Bugzilla: 1513543
ae23c9
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: Fam Zheng <famz@redhat.com>
ae23c9
ae23c9
Add an iotests.py function that runs a job and only returns when it is
ae23c9
destroyed. An error is logged when the job failed and job-finalize and
ae23c9
job-dismiss commands are issued if necessary.
ae23c9
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Reviewed-by: Max Reitz <mreitz@redhat.com>
ae23c9
Reviewed-by: Jeff Cody <jcody@redhat.com>
ae23c9
(cherry picked from commit fc47d8513b45b1968b0ae32d4bb2f96d3aca066a)
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 tests/qemu-iotests/iotests.py | 19 +++++++++++++++++++
ae23c9
 1 file changed, 19 insertions(+)
ae23c9
ae23c9
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
ae23c9
index db4206f..2b47062 100644
ae23c9
--- a/tests/qemu-iotests/iotests.py
ae23c9
+++ b/tests/qemu-iotests/iotests.py
ae23c9
@@ -428,6 +428,25 @@ class VM(qtest.QEMUQtestMachine):
ae23c9
         log(str(result), filters)
ae23c9
         return result
ae23c9
 
ae23c9
+    def run_job(self, job, auto_finalize=True, auto_dismiss=False):
ae23c9
+        while True:
ae23c9
+            for ev in self.get_qmp_events_filtered(wait=True):
ae23c9
+                if ev['event'] == 'JOB_STATUS_CHANGE':
ae23c9
+                    status = ev['data']['status']
ae23c9
+                    if status == 'aborting':
ae23c9
+                        result = self.qmp('query-jobs')
ae23c9
+                        for j in result['return']:
ae23c9
+                            if j['id'] == job:
ae23c9
+                                log('Job failed: %s' % (j['error']))
ae23c9
+                    elif status == 'pending' and not auto_finalize:
ae23c9
+                        self.qmp_log('job-finalize', id=job)
ae23c9
+                    elif status == 'concluded' and not auto_dismiss:
ae23c9
+                        self.qmp_log('job-dismiss', id=job)
ae23c9
+                    elif status == 'null':
ae23c9
+                        return
ae23c9
+                else:
ae23c9
+                    iotests.log(ev)
ae23c9
+
ae23c9
 
ae23c9
 index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
ae23c9
 
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9