qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 21/33] qemu-iotests/118: Test media change with qdev name
Date: Thu, 22 Sep 2016 18:29:22 +0200	[thread overview]
Message-ID: <1474561774-19256-22-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1474561774-19256-1-git-send-email-kwolf@redhat.com>

We just added the option to use qdev device names in all device related
block QMP commands. This patch converts some of the test cases in 118 to
use qdev device names instead of BlockBackend names to cover the new
way. It converts cases for each of the media change commands, but only
for CD-ROM and not everywhere, so that the old way is still tested, too.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 tests/qemu-iotests/118        | 85 ++++++++++++++++++++++++++++++++++---------
 tests/qemu-iotests/iotests.py |  5 +++
 2 files changed, 73 insertions(+), 17 deletions(-)

diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118
index 9e5951f..0380069 100755
--- a/tests/qemu-iotests/118
+++ b/tests/qemu-iotests/118
@@ -62,6 +62,9 @@ class ChangeBaseClass(iotests.QMPTestCase):
             self.fail('Timeout while waiting for the tray to close')
 
 class GeneralChangeTestsBaseClass(ChangeBaseClass):
+
+    device_name = None
+
     def test_change(self):
         result = self.vm.qmp('change', device='drive0', target=new_img,
                                        arg=iotests.imgfmt)
@@ -76,9 +79,15 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_blockdev_change_medium(self):
-        result = self.vm.qmp('blockdev-change-medium', device='drive0',
-                                                       filename=new_img,
-                                                       format=iotests.imgfmt)
+        if self.device_name is not None:
+            result = self.vm.qmp('blockdev-change-medium',
+                                 id=self.device_name, filename=new_img,
+                                 format=iotests.imgfmt)
+        else:
+            result = self.vm.qmp('blockdev-change-medium',
+                                 device='drive0', filename=new_img,
+                                 format=iotests.imgfmt)
+
         self.assert_qmp(result, 'return', {})
 
         self.wait_for_open()
@@ -90,7 +99,10 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_eject(self):
-        result = self.vm.qmp('eject', device='drive0', force=True)
+        if self.device_name is not None:
+            result = self.vm.qmp('eject', id=self.device_name, force=True)
+        else:
+            result = self.vm.qmp('eject', device='drive0', force=True)
         self.assert_qmp(result, 'return', {})
 
         self.wait_for_open()
@@ -101,7 +113,10 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
         self.assert_qmp_absent(result, 'return[0]/inserted')
 
     def test_tray_eject_change(self):
-        result = self.vm.qmp('eject', device='drive0', force=True)
+        if self.device_name is not None:
+            result = self.vm.qmp('eject', id=self.device_name, force=True)
+        else:
+            result = self.vm.qmp('eject', device='drive0', force=True)
         self.assert_qmp(result, 'return', {})
 
         self.wait_for_open()
@@ -111,9 +126,12 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
             self.assert_qmp(result, 'return[0]/tray_open', True)
         self.assert_qmp_absent(result, 'return[0]/inserted')
 
-        result = self.vm.qmp('blockdev-change-medium', device='drive0',
-                                                       filename=new_img,
-                                                       format=iotests.imgfmt)
+        if self.device_name is not None:
+            result = self.vm.qmp('blockdev-change-medium', id=self.device_name,
+                                 filename=new_img, format=iotests.imgfmt)
+        else:
+            result = self.vm.qmp('blockdev-change-medium', device='drive0',
+                                 filename=new_img, format=iotests.imgfmt)
         self.assert_qmp(result, 'return', {})
 
         self.wait_for_close()
@@ -124,7 +142,12 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_tray_open_close(self):
-        result = self.vm.qmp('blockdev-open-tray', device='drive0', force=True)
+        if self.device_name is not None:
+            result = self.vm.qmp('blockdev-open-tray',
+                                 id=self.device_name, force=True)
+        else:
+            result = self.vm.qmp('blockdev-open-tray',
+                                 device='drive0', force=True)
         self.assert_qmp(result, 'return', {})
 
         self.wait_for_open()
@@ -137,7 +160,10 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
         else:
             self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
 
-        result = self.vm.qmp('blockdev-close-tray', device='drive0')
+        if self.device_name is not None:
+            result = self.vm.qmp('blockdev-close-tray', id=self.device_name)
+        else:
+            result = self.vm.qmp('blockdev-close-tray', device='drive0')
         self.assert_qmp(result, 'return', {})
 
         if self.has_real_tray or not self.was_empty:
@@ -162,7 +188,10 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
             self.assert_qmp(result, 'return[0]/tray_open', True)
         self.assert_qmp_absent(result, 'return[0]/inserted')
 
-        result = self.vm.qmp('blockdev-close-tray', device='drive0')
+        if self.device_name is not None:
+            result = self.vm.qmp('blockdev-close-tray', id=self.device_name)
+        else:
+            result = self.vm.qmp('blockdev-close-tray', device='drive0')
         self.assert_qmp(result, 'return', {})
 
         self.wait_for_close()
@@ -206,7 +235,12 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
                                                'driver': 'file'}})
         self.assert_qmp(result, 'return', {})
 
-        result = self.vm.qmp('blockdev-open-tray', device='drive0', force=True)
+        if self.device_name is not None:
+            result = self.vm.qmp('blockdev-open-tray',
+                                 id=self.device_name, force=True)
+        else:
+            result = self.vm.qmp('blockdev-open-tray',
+                                 device='drive0', force=True)
         self.assert_qmp(result, 'return', {})
 
         self.wait_for_open()
@@ -219,7 +253,11 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
         else:
             self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
 
-        result = self.vm.qmp('x-blockdev-remove-medium', device='drive0')
+        if self.device_name is not None:
+            result = self.vm.qmp('x-blockdev-remove-medium',
+                                 id=self.device_name)
+        else:
+            result = self.vm.qmp('x-blockdev-remove-medium', device='drive0')
         self.assert_qmp(result, 'return', {})
 
         result = self.vm.qmp('query-block')
@@ -227,8 +265,12 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
             self.assert_qmp(result, 'return[0]/tray_open', True)
         self.assert_qmp_absent(result, 'return[0]/inserted')
 
-        result = self.vm.qmp('x-blockdev-insert-medium', device='drive0',
-                                                       node_name='new')
+        if self.device_name is not None:
+            result = self.vm.qmp('x-blockdev-insert-medium',
+                                 id=self.device_name, node_name='new')
+        else:
+            result = self.vm.qmp('x-blockdev-insert-medium',
+                                 device='drive0', node_name='new')
         self.assert_qmp(result, 'return', {})
 
         result = self.vm.qmp('query-block')
@@ -236,7 +278,10 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
             self.assert_qmp(result, 'return[0]/tray_open', True)
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
-        result = self.vm.qmp('blockdev-close-tray', device='drive0')
+        if self.device_name is not None:
+            result = self.vm.qmp('blockdev-close-tray', id=self.device_name)
+        else:
+            result = self.vm.qmp('blockdev-close-tray', device='drive0')
         self.assert_qmp(result, 'return', {})
 
         self.wait_for_close()
@@ -280,7 +325,13 @@ class TestInitiallyFilled(GeneralChangeTestsBaseClass):
     def setUp(self, media, interface):
         qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k')
         qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k')
-        self.vm = iotests.VM().add_drive(old_img, 'media=%s' % media, interface)
+        self.vm = iotests.VM()
+        if interface == 'ide':
+            self.device_name = 'qdev0'
+            self.vm.add_drive(old_img, 'media=%s' % media, 'none')
+            self.vm.add_device('ide-cd,drive=drive0,id=%s' % self.device_name)
+        else:
+            self.vm.add_drive(old_img, 'media=%s' % media, interface)
         self.vm.launch()
 
     def tearDown(self):
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index f1f36d7..3329bc1 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -139,6 +139,11 @@ class VM(qtest.QEMUQtestMachine):
             self._debug = True
         self._num_drives = 0
 
+    def add_device(self, opts):
+        self._args.append('-device')
+        self._args.append(opts)
+        return self
+
     def add_drive_raw(self, opts):
         self._args.append('-drive')
         self._args.append(opts)
-- 
1.8.3.1

  parent reply	other threads:[~2016-09-22 16:30 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-22 16:29 [Qemu-devel] [PULL 00/33] Block layer patches Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 01/33] qcow2: fix encryption during cow of sectors Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 02/33] hmp: Remove dead code in hmp_qemu_io() Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 03/33] tests: allow to specify list of formats to test for check-block.sh Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 04/33] block: Remove bdrv_is_snapshot Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 05/33] block: Set BDRV_O_ALLOW_RDWR and snapshot_options before storing the flags Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 06/33] block: Update bs->open_flags earlier in bdrv_open_common() Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 07/33] block: Add "read-only" to the options QDict Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 08/33] block: Don't queue the same BDS twice in bdrv_reopen_queue_child() Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 09/33] commit: Add 'base' to the reopen queue before 'overlay_bs' Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 10/33] block: rename "read-only" to BDRV_OPT_READ_ONLY Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 11/33] block: Fix 'since' for compressed Drive/BlockdevBackup Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 12/33] block: Add blk_by_dev() Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 13/33] qdev-monitor: Factor out find_device_state() Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 14/33] qdev-monitor: Add blk_by_qdev_id() Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 15/33] block: Accept device model name for blockdev-open/close-tray Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 16/33] block: Accept device model name for x-blockdev-insert-medium Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 17/33] block: Accept device model name for x-blockdev-remove-medium Kevin Wolf
2016-09-26 10:59   ` Paolo Bonzini
2016-09-26 13:08     ` Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 18/33] block: Accept device model name for eject Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 19/33] block: Accept device model name for blockdev-change-medium Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 20/33] block: Accept device model name for block_set_io_throttle Kevin Wolf
2016-09-22 16:29 ` Kevin Wolf [this message]
2016-09-22 16:29 ` [Qemu-devel] [PULL 22/33] qemu-iotests/041: Avoid blockdev-add with id Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 23/33] qemu-iotests/067: " Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 24/33] qemu-iotests/071: " Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 25/33] qemu-iotests/081: " Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 26/33] qemu-iotests/087: " Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 27/33] qemu-iotests/117: " Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 28/33] qemu-iotests/118: " Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 29/33] qemu-iotests/124: " Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 30/33] qemu-iotests/139: " Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 31/33] block: Avoid printing NULL string in error messages Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 32/33] qemu-iotests/141: Avoid blockdev-add with id Kevin Wolf
2016-09-22 16:29 ` [Qemu-devel] [PULL 33/33] block: Remove BB interface from blockdev-add/del Kevin Wolf
2016-09-23 11:12 ` [Qemu-devel] [PULL 00/33] Block layer patches Peter Maydell
2016-09-23 11:41   ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474561774-19256-22-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).