yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
ddf19c
From 05fedde1374abb180cd2b51457385d8128aa7fe4 Mon Sep 17 00:00:00 2001
ddf19c
From: Kevin Wolf <kwolf@redhat.com>
ddf19c
Date: Fri, 7 Feb 2020 11:24:00 +0000
ddf19c
Subject: [PATCH 03/18] iotests: Create VM.blockdev_create()
ddf19c
ddf19c
RH-Author: Kevin Wolf <kwolf@redhat.com>
ddf19c
Message-id: <20200207112404.25198-3-kwolf@redhat.com>
ddf19c
Patchwork-id: 93748
ddf19c
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH v2 2/6] iotests: Create VM.blockdev_create()
ddf19c
Bugzilla: 1781637
ddf19c
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
ddf19c
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ddf19c
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ddf19c
ddf19c
We have several almost identical copies of a blockdev_create() function
ddf19c
in different test cases. Time to create one unified function in
ddf19c
iotests.py.
ddf19c
ddf19c
To keep the diff managable, this patch only creates the function and
ddf19c
follow-up patches will convert the individual test cases.
ddf19c
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
(cherry picked from commit e9dbd1cae86f7cb6f8e470e1485aeb0c6e23ae64)
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 tests/qemu-iotests/iotests.py | 16 ++++++++++++++++
ddf19c
 1 file changed, 16 insertions(+)
ddf19c
ddf19c
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
ddf19c
index 3cff671..5741efb 100644
ddf19c
--- a/tests/qemu-iotests/iotests.py
ddf19c
+++ b/tests/qemu-iotests/iotests.py
ddf19c
@@ -638,6 +638,22 @@ class VM(qtest.QEMUQtestMachine):
ddf19c
             elif status == 'null':
ddf19c
                 return error
ddf19c
 
ddf19c
+    # Returns None on success, and an error string on failure
ddf19c
+    def blockdev_create(self, options, job_id='job0', filters=None):
ddf19c
+        if filters is None:
ddf19c
+            filters = [filter_qmp_testfiles]
ddf19c
+        result = self.qmp_log('blockdev-create', filters=filters,
ddf19c
+                              job_id=job_id, options=options)
ddf19c
+
ddf19c
+        if 'return' in result:
ddf19c
+            assert result['return'] == {}
ddf19c
+            job_result = self.run_job(job_id)
ddf19c
+        else:
ddf19c
+            job_result = result['error']
ddf19c
+
ddf19c
+        log("")
ddf19c
+        return job_result
ddf19c
+
ddf19c
     def enable_migration_events(self, name):
ddf19c
         log('Enabling migration QMP events on %s...' % name)
ddf19c
         log(self.qmp('migrate-set-capabilities', capabilities=[
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c