|
|
9bac43 |
From 3725eae71ddcc6f053793a530c1f4e3a43e9c4df Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
Date: Fri, 17 Nov 2017 11:19:07 +0100
|
|
|
9bac43 |
Subject: [PATCH 08/15] qemu-iotests: Test I/O limits with removable media
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
Message-id: <20171117111908.8815-9-stefanha@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 77743
|
|
|
9bac43 |
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 8/9] qemu-iotests: Test I/O limits with removable media
|
|
|
9bac43 |
Bugzilla: 1492295
|
|
|
9bac43 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
From: Alberto Garcia <berto@igalia.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
This test hotplugs a CD drive to a VM and checks that I/O limits can
|
|
|
9bac43 |
be set only when the drive has media inserted and that they are kept
|
|
|
9bac43 |
when the media is replaced.
|
|
|
9bac43 |
|
|
|
9bac43 |
This also tests the removal of a device with valid I/O limits set but
|
|
|
9bac43 |
no media inserted. This involves deleting and disabling the limits
|
|
|
9bac43 |
of a BlockBackend without BlockDriverState, a scenario that has been
|
|
|
9bac43 |
crashing until the fixes from the last couple of patches.
|
|
|
9bac43 |
|
|
|
9bac43 |
[Python PEP8 fixup: "Don't use spaces are the = sign when used to
|
|
|
9bac43 |
indicate a keyword argument or a default parameter value"
|
|
|
9bac43 |
--Stefan]
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: Alberto Garcia <berto@igalia.com>
|
|
|
9bac43 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
9bac43 |
Message-id: 071eb397118ed207c5a7f01d58766e415ee18d6a.1510339534.git.berto@igalia.com
|
|
|
9bac43 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
(cherry picked from commit 0761562687e0d8135310a94b1d3e08376387c027)
|
|
|
9bac43 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
---
|
|
|
9bac43 |
tests/qemu-iotests/093 | 62 ++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
9bac43 |
tests/qemu-iotests/093.out | 4 +--
|
|
|
9bac43 |
2 files changed, 64 insertions(+), 2 deletions(-)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093
|
|
|
9bac43 |
index ef39972..5c36a5f 100755
|
|
|
9bac43 |
--- a/tests/qemu-iotests/093
|
|
|
9bac43 |
+++ b/tests/qemu-iotests/093
|
|
|
9bac43 |
@@ -308,6 +308,68 @@ class ThrottleTestGroupNames(iotests.QMPTestCase):
|
|
|
9bac43 |
groupname = "group%d" % i
|
|
|
9bac43 |
self.verify_name(devname, groupname)
|
|
|
9bac43 |
|
|
|
9bac43 |
+class ThrottleTestRemovableMedia(iotests.QMPTestCase):
|
|
|
9bac43 |
+ def setUp(self):
|
|
|
9bac43 |
+ self.vm = iotests.VM()
|
|
|
9bac43 |
+ if iotests.qemu_default_machine == 's390-ccw-virtio':
|
|
|
9bac43 |
+ self.vm.add_device("virtio-scsi-ccw,id=virtio-scsi")
|
|
|
9bac43 |
+ else:
|
|
|
9bac43 |
+ self.vm.add_device("virtio-scsi-pci,id=virtio-scsi")
|
|
|
9bac43 |
+ self.vm.launch()
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ def tearDown(self):
|
|
|
9bac43 |
+ self.vm.shutdown()
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ def test_removable_media(self):
|
|
|
9bac43 |
+ # Add a couple of dummy nodes named cd0 and cd1
|
|
|
9bac43 |
+ result = self.vm.qmp("blockdev-add", driver="null-aio",
|
|
|
9bac43 |
+ node_name="cd0")
|
|
|
9bac43 |
+ self.assert_qmp(result, 'return', {})
|
|
|
9bac43 |
+ result = self.vm.qmp("blockdev-add", driver="null-aio",
|
|
|
9bac43 |
+ node_name="cd1")
|
|
|
9bac43 |
+ self.assert_qmp(result, 'return', {})
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ # Attach a CD drive with cd0 inserted
|
|
|
9bac43 |
+ result = self.vm.qmp("device_add", driver="scsi-cd",
|
|
|
9bac43 |
+ id="dev0", drive="cd0")
|
|
|
9bac43 |
+ self.assert_qmp(result, 'return', {})
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ # Set I/O limits
|
|
|
9bac43 |
+ args = { "id": "dev0", "iops": 100, "iops_rd": 0, "iops_wr": 0,
|
|
|
9bac43 |
+ "bps": 50, "bps_rd": 0, "bps_wr": 0 }
|
|
|
9bac43 |
+ result = self.vm.qmp("block_set_io_throttle", conv_keys=False, **args)
|
|
|
9bac43 |
+ self.assert_qmp(result, 'return', {})
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ # Check that the I/O limits have been set
|
|
|
9bac43 |
+ result = self.vm.qmp("query-block")
|
|
|
9bac43 |
+ self.assert_qmp(result, 'return[0]/inserted/iops', 100)
|
|
|
9bac43 |
+ self.assert_qmp(result, 'return[0]/inserted/bps', 50)
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ # Now eject cd0 and insert cd1
|
|
|
9bac43 |
+ result = self.vm.qmp("blockdev-open-tray", id='dev0')
|
|
|
9bac43 |
+ self.assert_qmp(result, 'return', {})
|
|
|
9bac43 |
+ result = self.vm.qmp("x-blockdev-remove-medium", id='dev0')
|
|
|
9bac43 |
+ self.assert_qmp(result, 'return', {})
|
|
|
9bac43 |
+ result = self.vm.qmp("x-blockdev-insert-medium", id='dev0', node_name='cd1')
|
|
|
9bac43 |
+ self.assert_qmp(result, 'return', {})
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ # Check that the I/O limits are still the same
|
|
|
9bac43 |
+ result = self.vm.qmp("query-block")
|
|
|
9bac43 |
+ self.assert_qmp(result, 'return[0]/inserted/iops', 100)
|
|
|
9bac43 |
+ self.assert_qmp(result, 'return[0]/inserted/bps', 50)
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ # Eject cd1
|
|
|
9bac43 |
+ result = self.vm.qmp("x-blockdev-remove-medium", id='dev0')
|
|
|
9bac43 |
+ self.assert_qmp(result, 'return', {})
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ # Check that we can't set limits if the device has no medium
|
|
|
9bac43 |
+ result = self.vm.qmp("block_set_io_throttle", conv_keys=False, **args)
|
|
|
9bac43 |
+ self.assert_qmp(result, 'error/class', 'GenericError')
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ # Remove the CD drive
|
|
|
9bac43 |
+ result = self.vm.qmp("device_del", id='dev0')
|
|
|
9bac43 |
+ self.assert_qmp(result, 'return', {})
|
|
|
9bac43 |
+
|
|
|
9bac43 |
|
|
|
9bac43 |
if __name__ == '__main__':
|
|
|
9bac43 |
iotests.main(supported_fmts=["raw"])
|
|
|
9bac43 |
diff --git a/tests/qemu-iotests/093.out b/tests/qemu-iotests/093.out
|
|
|
9bac43 |
index 2f7d390..594c16f 100644
|
|
|
9bac43 |
--- a/tests/qemu-iotests/093.out
|
|
|
9bac43 |
+++ b/tests/qemu-iotests/093.out
|
|
|
9bac43 |
@@ -1,5 +1,5 @@
|
|
|
9bac43 |
-.......
|
|
|
9bac43 |
+........
|
|
|
9bac43 |
----------------------------------------------------------------------
|
|
|
9bac43 |
-Ran 7 tests
|
|
|
9bac43 |
+Ran 8 tests
|
|
|
9bac43 |
|
|
|
9bac43 |
OK
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|