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