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