Add two simple test-cases: timeout failure with
break-snapshot-on-cbw-error behavior and similar with
break-guest-write-on-cbw-error behavior.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
---
tests/qemu-iotests/tests/copy-before-write | 78 +++++++++++++++++++
.../qemu-iotests/tests/copy-before-write.out | 4 +-
2 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/tests/qemu-iotests/tests/copy-before-write b/tests/qemu-iotests/tests/copy-before-write
index a32608f597..5c90b8cd50 100755
--- a/tests/qemu-iotests/tests/copy-before-write
+++ b/tests/qemu-iotests/tests/copy-before-write
@@ -122,6 +122,84 @@ read 1048576/1048576 bytes at offset 0
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
""")
+ def do_cbw_timeout(self, on_cbw_error):
+ result = self.vm.qmp('object-add', {
+ 'qom-type': 'throttle-group',
+ 'id': 'group0',
+ 'limits': {'bps-write': 300 * 1024}
+ })
+ self.assert_qmp(result, 'return', {})
+
+ result = self.vm.qmp('blockdev-add', {
+ 'node-name': 'cbw',
+ 'driver': 'copy-before-write',
+ 'on-cbw-error': on_cbw_error,
+ 'cbw-timeout': 1,
+ 'file': {
+ 'driver': iotests.imgfmt,
+ 'file': {
+ 'driver': 'file',
+ 'filename': source_img,
+ }
+ },
+ 'target': {
+ 'driver': 'throttle',
+ 'throttle-group': 'group0',
+ 'file': {
+ 'driver': 'qcow2',
+ 'file': {
+ 'driver': 'file',
+ 'filename': temp_img
+ }
+ }
+ }
+ })
+ self.assert_qmp(result, 'return', {})
+
+ result = self.vm.qmp('blockdev-add', {
+ 'node-name': 'access',
+ 'driver': 'snapshot-access',
+ 'file': 'cbw'
+ })
+ self.assert_qmp(result, 'return', {})
+
+ result = self.vm.hmp_qemu_io('cbw', 'write 0 512K')
+ self.assert_qmp(result, 'return', '')
+
+ # We need second write to trigger throttling
+ result = self.vm.hmp_qemu_io('cbw', 'write 512K 512K')
+ self.assert_qmp(result, 'return', '')
+
+ result = self.vm.hmp_qemu_io('access', 'read 0 1M')
+ self.assert_qmp(result, 'return', '')
+
+ self.vm.shutdown()
+ log = self.vm.get_log()
+ log = re.sub(r'^\[I \d+\.\d+\] OPENED\n', '', log)
+ log = re.sub(r'\[I \+\d+\.\d+\] CLOSED\n?$', '', log)
+ log = iotests.filter_qemu_io(log)
+ return log
+
+ def test_timeout_break_guest(self):
+ log = self.do_cbw_timeout('break-guest-write')
+ self.assertEqual(log, """\
+wrote 524288/524288 bytes at offset 0
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+write failed: Connection timed out
+read 1048576/1048576 bytes at offset 0
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+""")
+
+ def test_timeout_break_snapshot(self):
+ log = self.do_cbw_timeout('break-snapshot')
+ self.assertEqual(log, """\
+wrote 524288/524288 bytes at offset 0
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 524288/524288 bytes at offset 524288
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read failed: Permission denied
+""")
+
if __name__ == '__main__':
iotests.main(supported_fmts=['qcow2'],
diff --git a/tests/qemu-iotests/tests/copy-before-write.out b/tests/qemu-iotests/tests/copy-before-write.out
index fbc63e62f8..89968f35d7 100644
--- a/tests/qemu-iotests/tests/copy-before-write.out
+++ b/tests/qemu-iotests/tests/copy-before-write.out
@@ -1,5 +1,5 @@
-..
+....
----------------------------------------------------------------------
-Ran 2 tests
+Ran 4 tests
OK
--
2.35.1
On 06.04.22 20:08, Vladimir Sementsov-Ogievskiy wrote:
> Add two simple test-cases: timeout failure with
> break-snapshot-on-cbw-error behavior and similar with
> break-guest-write-on-cbw-error behavior.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
> ---
> tests/qemu-iotests/tests/copy-before-write | 78 +++++++++++++++++++
> .../qemu-iotests/tests/copy-before-write.out | 4 +-
> 2 files changed, 80 insertions(+), 2 deletions(-)
>
> diff --git a/tests/qemu-iotests/tests/copy-before-write b/tests/qemu-iotests/tests/copy-before-write
> index a32608f597..5c90b8cd50 100755
> --- a/tests/qemu-iotests/tests/copy-before-write
> +++ b/tests/qemu-iotests/tests/copy-before-write
> @@ -122,6 +122,84 @@ read 1048576/1048576 bytes at offset 0
> 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> """)
>
> + def do_cbw_timeout(self, on_cbw_error):
> + result = self.vm.qmp('object-add', {
> + 'qom-type': 'throttle-group',
> + 'id': 'group0',
> + 'limits': {'bps-write': 300 * 1024}
Hm, yes, I can’t find a way to make this work without your other
series. For some reason, not even -accel tcg helps; and using qtest to
advance the virtual clock doesn’t really help because the qemu-io
commands block while the request is throttled.
One thing that should work would be to run everything in a
qemu-storage-daemon instance, and then having qemu-io access an NBD
export...
07.04.2022 12:19, Hanna Reitz wrote:
> On 06.04.22 20:08, Vladimir Sementsov-Ogievskiy wrote:
>> Add two simple test-cases: timeout failure with
>> break-snapshot-on-cbw-error behavior and similar with
>> break-guest-write-on-cbw-error behavior.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
>> ---
>> tests/qemu-iotests/tests/copy-before-write | 78 +++++++++++++++++++
>> .../qemu-iotests/tests/copy-before-write.out | 4 +-
>> 2 files changed, 80 insertions(+), 2 deletions(-)
>>
>> diff --git a/tests/qemu-iotests/tests/copy-before-write b/tests/qemu-iotests/tests/copy-before-write
>> index a32608f597..5c90b8cd50 100755
>> --- a/tests/qemu-iotests/tests/copy-before-write
>> +++ b/tests/qemu-iotests/tests/copy-before-write
>> @@ -122,6 +122,84 @@ read 1048576/1048576 bytes at offset 0
>> 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> """)
>> + def do_cbw_timeout(self, on_cbw_error):
>> + result = self.vm.qmp('object-add', {
>> + 'qom-type': 'throttle-group',
>> + 'id': 'group0',
>> + 'limits': {'bps-write': 300 * 1024}
>
> Hm, yes, I can’t find a way to make this work without your other series. For some reason, not even -accel tcg helps; and using qtest to advance the virtual clock doesn’t really help because the qemu-io commands block while the request is throttled.
>
> One thing that should work would be to run everything in a qemu-storage-daemon instance, and then having qemu-io access an NBD export...
>
Simple switch to QEMUMachine helps. I'll resend soon.
--
Best regards,
Vladimir
© 2016 - 2026 Red Hat, Inc.