[Qemu-devel] [PATCH] iotests: add 248: test resume mirror after auto pause on ENOSPC

Vladimir Sementsov-Ogievskiy posted 1 patch 5 years, 1 month ago
Test docker-mingw@fedora passed
Test docker-clang@ubuntu passed
Test asan passed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190320095954.28874-1-vsementsov@virtuozzo.com
Maintainers: Max Reitz <mreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>
There is a newer version of this series
tests/qemu-iotests/248     | 77 ++++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/248.out | 12 ++++++
tests/qemu-iotests/group   |  1 +
3 files changed, 90 insertions(+)
create mode 100755 tests/qemu-iotests/248
create mode 100644 tests/qemu-iotests/248.out
[Qemu-devel] [PATCH] iotests: add 248: test resume mirror after auto pause on ENOSPC
Posted by Vladimir Sementsov-Ogievskiy 5 years, 1 month ago
Test that mirror job actually resume on resume command after being
automatically paused on ENOSPC error.

It's a follow-up test for 8d9648cbf3e
    "blockjob: fix user pause in block_job_error_action"

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 tests/qemu-iotests/248     | 77 ++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/248.out | 12 ++++++
 tests/qemu-iotests/group   |  1 +
 3 files changed, 90 insertions(+)
 create mode 100755 tests/qemu-iotests/248
 create mode 100644 tests/qemu-iotests/248.out

diff --git a/tests/qemu-iotests/248 b/tests/qemu-iotests/248
new file mode 100755
index 0000000000..ab88c96532
--- /dev/null
+++ b/tests/qemu-iotests/248
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+#
+# Test resume mirror after auto pause on ENOSPC
+#
+# Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import iotests
+from iotests import qemu_img_create, qemu_io, file_path, filter_qmp_testfiles
+
+iotests.verify_image_format(supported_fmts=['qcow2'])
+
+source, target = file_path('source', 'target')
+size = 5 * 1024 * 1024
+limit = 2 * 1024 * 1024
+
+qemu_img_create('-f', iotests.imgfmt, source, str(size))
+qemu_img_create('-f', iotests.imgfmt, target, str(size))
+qemu_io('-c', 'write 0 {}'.format(size), source)
+
+# raw format don't like empty files
+qemu_io('-c', 'write 0 {}'.format(size), target)
+
+vm = iotests.VM().add_drive(source)
+vm.launch()
+
+vm.qmp_log('blockdev-add', filters=[filter_qmp_testfiles], **{
+    'driver': iotests.imgfmt,
+    'node-name': 'target',
+    'file': {
+        'driver': 'raw',
+        'size': 2 * 1024 * 1024,
+        'file': {
+            'driver': 'file',
+            'filename': target
+        }
+    }
+})
+
+vm.qmp_log('blockdev-mirror', device='drive0', sync='full', target='target',
+           on_target_error='enospc')
+
+vm.event_wait('JOB_STATUS_CHANGE', timeout=3.0,
+              match={'data': {'status': 'paused'}})
+
+vm.qmp_log('query-block-jobs')
+
+vm.qmp_log('x-blockdev-reopen', filters=[filter_qmp_testfiles], **{
+    'driver': iotests.imgfmt,
+    'node-name': 'target',
+    'file': {
+        'driver': 'raw',
+        # size parameter dropped
+        'file': {
+            'driver': 'file',
+            'filename': target
+        }
+    }
+})
+
+vm.qmp_log('block-job-resume', device='drive0')
+vm.qmp_log('query-block-jobs')  # check that job is resumed
+
+vm.shutdown()
diff --git a/tests/qemu-iotests/248.out b/tests/qemu-iotests/248.out
new file mode 100644
index 0000000000..657f69b209
--- /dev/null
+++ b/tests/qemu-iotests/248.out
@@ -0,0 +1,12 @@
+{"execute": "blockdev-add", "arguments": {"driver": "qcow2", "file": {"driver": "raw", "file": {"driver": "file", "filename": "TEST_DIR/PID-target"}, "size": 2097152}, "node-name": "target"}}
+{"return": {}}
+{"execute": "blockdev-mirror", "arguments": {"device": "drive0", "on-target-error": "enospc", "sync": "full", "target": "target"}}
+{"return": {}}
+{"execute": "query-block-jobs", "arguments": {}}
+{"return": [{"auto-dismiss": true, "auto-finalize": true, "busy": false, "device": "drive0", "io-status": "nospace", "len": 5242880, "offset": 1048576, "paused": true, "ready": false, "speed": 0, "status": "paused", "type": "mirror"}]}
+{"execute": "x-blockdev-reopen", "arguments": {"driver": "qcow2", "file": {"driver": "raw", "file": {"driver": "file", "filename": "TEST_DIR/PID-target"}}, "node-name": "target"}}
+{"return": {}}
+{"execute": "block-job-resume", "arguments": {"device": "drive0"}}
+{"return": {}}
+{"execute": "query-block-jobs", "arguments": {}}
+{"return": [{"auto-dismiss": true, "auto-finalize": true, "busy": true, "device": "drive0", "io-status": "ok", "len": 5242880, "offset": 1048576, "paused": false, "ready": false, "speed": 0, "status": "running", "type": "mirror"}]}
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index d192abaecf..41da10c6cf 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -246,3 +246,4 @@
 245 rw auto
 246 rw auto quick
 247 rw auto quick
+248 rw auto quick
-- 
2.18.0


Re: [Qemu-devel] [PATCH] iotests: add 248: test resume mirror after auto pause on ENOSPC
Posted by Kevin Wolf 5 years, 1 month ago
Am 20.03.2019 um 10:59 hat Vladimir Sementsov-Ogievskiy geschrieben:
> Test that mirror job actually resume on resume command after being
> automatically paused on ENOSPC error.
> 
> It's a follow-up test for 8d9648cbf3e
>     "blockjob: fix user pause in block_job_error_action"
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  tests/qemu-iotests/248     | 77 ++++++++++++++++++++++++++++++++++++++
>  tests/qemu-iotests/248.out | 12 ++++++
>  tests/qemu-iotests/group   |  1 +
>  3 files changed, 90 insertions(+)
>  create mode 100755 tests/qemu-iotests/248
>  create mode 100644 tests/qemu-iotests/248.out
> 
> diff --git a/tests/qemu-iotests/248 b/tests/qemu-iotests/248
> new file mode 100755
> index 0000000000..ab88c96532
> --- /dev/null
> +++ b/tests/qemu-iotests/248
> @@ -0,0 +1,77 @@
> +#!/usr/bin/env python
> +#
> +# Test resume mirror after auto pause on ENOSPC
> +#
> +# Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +#
> +
> +import iotests
> +from iotests import qemu_img_create, qemu_io, file_path, filter_qmp_testfiles
> +
> +iotests.verify_image_format(supported_fmts=['qcow2'])
> +
> +source, target = file_path('source', 'target')
> +size = 5 * 1024 * 1024
> +limit = 2 * 1024 * 1024

limit is unused...

> +qemu_img_create('-f', iotests.imgfmt, source, str(size))
> +qemu_img_create('-f', iotests.imgfmt, target, str(size))
> +qemu_io('-c', 'write 0 {}'.format(size), source)
> +
> +# raw format don't like empty files
> +qemu_io('-c', 'write 0 {}'.format(size), target)
> +
> +vm = iotests.VM().add_drive(source)
> +vm.launch()
> +
> +vm.qmp_log('blockdev-add', filters=[filter_qmp_testfiles], **{
> +    'driver': iotests.imgfmt,
> +    'node-name': 'target',
> +    'file': {
> +        'driver': 'raw',
> +        'size': 2 * 1024 * 1024,

...because you used the literal value again here.

> +        'file': {
> +            'driver': 'file',
> +            'filename': target
> +        }
> +    }
> +})
> +
> +vm.qmp_log('blockdev-mirror', device='drive0', sync='full', target='target',
> +           on_target_error='enospc')
> +
> +vm.event_wait('JOB_STATUS_CHANGE', timeout=3.0,
> +              match={'data': {'status': 'paused'}})
> +
> +vm.qmp_log('query-block-jobs')
> +
> +vm.qmp_log('x-blockdev-reopen', filters=[filter_qmp_testfiles], **{
> +    'driver': iotests.imgfmt,
> +    'node-name': 'target',
> +    'file': {
> +        'driver': 'raw',
> +        # size parameter dropped
> +        'file': {
> +            'driver': 'file',
> +            'filename': target
> +        }
> +    }
> +})

Instead of duplicating the configuration here, maybe it would be nicer
to store it in a variable and just del options['file']['size'] before
passing them to x-blockdev-reopen.

By the way, I like that you used x-blockdev-reopen. It's much better
than my suggestion to use HMP qemu-io.

> +
> +vm.qmp_log('block-job-resume', device='drive0')
> +vm.qmp_log('query-block-jobs')  # check that job is resumed

This is the expected output for this query-block-jobs:

> +{"return": [{"auto-dismiss": true, "auto-finalize": true, "busy": true, "device": "drive0", "io-status": "ok", "len": 5242880, "offset": 1048576, "paused": false, "ready": false, "speed": 0, "status": "running", "type": "mirror"}]}

So it expects a specific offset of 1048576. Is this reliable without
throttling the job?

Kevin

Re: [Qemu-devel] [PATCH] iotests: add 248: test resume mirror after auto pause on ENOSPC
Posted by Vladimir Sementsov-Ogievskiy 5 years, 1 month ago
20.03.2019 14:03, Kevin Wolf wrote:
> Am 20.03.2019 um 10:59 hat Vladimir Sementsov-Ogievskiy geschrieben:
>> Test that mirror job actually resume on resume command after being
>> automatically paused on ENOSPC error.
>>
>> It's a follow-up test for 8d9648cbf3e
>>      "blockjob: fix user pause in block_job_error_action"
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>>   tests/qemu-iotests/248     | 77 ++++++++++++++++++++++++++++++++++++++
>>   tests/qemu-iotests/248.out | 12 ++++++
>>   tests/qemu-iotests/group   |  1 +
>>   3 files changed, 90 insertions(+)
>>   create mode 100755 tests/qemu-iotests/248
>>   create mode 100644 tests/qemu-iotests/248.out
>>
>> diff --git a/tests/qemu-iotests/248 b/tests/qemu-iotests/248
>> new file mode 100755
>> index 0000000000..ab88c96532
>> --- /dev/null
>> +++ b/tests/qemu-iotests/248
>> @@ -0,0 +1,77 @@
>> +#!/usr/bin/env python
>> +#
>> +# Test resume mirror after auto pause on ENOSPC
>> +#
>> +# Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved.
>> +#
>> +# This program is free software; you can redistribute it and/or modify
>> +# it under the terms of the GNU General Public License as published by
>> +# the Free Software Foundation; either version 2 of the License, or
>> +# (at your option) any later version.
>> +#
>> +# This program is distributed in the hope that it will be useful,
>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> +# GNU General Public License for more details.
>> +#
>> +# You should have received a copy of the GNU General Public License
>> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
>> +#
>> +
>> +import iotests
>> +from iotests import qemu_img_create, qemu_io, file_path, filter_qmp_testfiles
>> +
>> +iotests.verify_image_format(supported_fmts=['qcow2'])
>> +
>> +source, target = file_path('source', 'target')
>> +size = 5 * 1024 * 1024
>> +limit = 2 * 1024 * 1024
> 
> limit is unused...
> 
>> +qemu_img_create('-f', iotests.imgfmt, source, str(size))
>> +qemu_img_create('-f', iotests.imgfmt, target, str(size))
>> +qemu_io('-c', 'write 0 {}'.format(size), source)
>> +
>> +# raw format don't like empty files
>> +qemu_io('-c', 'write 0 {}'.format(size), target)
>> +
>> +vm = iotests.VM().add_drive(source)
>> +vm.launch()
>> +
>> +vm.qmp_log('blockdev-add', filters=[filter_qmp_testfiles], **{
>> +    'driver': iotests.imgfmt,
>> +    'node-name': 'target',
>> +    'file': {
>> +        'driver': 'raw',
>> +        'size': 2 * 1024 * 1024,
> 
> ...because you used the literal value again here.


hmm, I definitely wanted to use it here)

> 
>> +        'file': {
>> +            'driver': 'file',
>> +            'filename': target
>> +        }
>> +    }
>> +})
>> +
>> +vm.qmp_log('blockdev-mirror', device='drive0', sync='full', target='target',
>> +           on_target_error='enospc')
>> +
>> +vm.event_wait('JOB_STATUS_CHANGE', timeout=3.0,
>> +              match={'data': {'status': 'paused'}})
>> +
>> +vm.qmp_log('query-block-jobs')
>> +
>> +vm.qmp_log('x-blockdev-reopen', filters=[filter_qmp_testfiles], **{
>> +    'driver': iotests.imgfmt,
>> +    'node-name': 'target',
>> +    'file': {
>> +        'driver': 'raw',
>> +        # size parameter dropped
>> +        'file': {
>> +            'driver': 'file',
>> +            'filename': target
>> +        }
>> +    }
>> +})
> 
> Instead of duplicating the configuration here, maybe it would be nicer
> to store it in a variable and just del options['file']['size'] before
> passing them to x-blockdev-reopen.

I thought about this, but it seemed that duplicating in such a small test
looks more visually. On the other hand it leads to questions like yours)
So, OK, will do.

> 
> By the way, I like that you used x-blockdev-reopen. It's much better
> than my suggestion to use HMP qemu-io.
> 
>> +
>> +vm.qmp_log('block-job-resume', device='drive0')
>> +vm.qmp_log('query-block-jobs')  # check that job is resumed
> 
> This is the expected output for this query-block-jobs:
> 
>> +{"return": [{"auto-dismiss": true, "auto-finalize": true, "busy": true, "device": "drive0", "io-status": "ok", "len": 5242880, "offset": 1048576, "paused": false, "ready": false, "speed": 0, "status": "running", "type": "mirror"}]}
> 
> So it expects a specific offset of 1048576. Is this reliable without
> throttling the job?

Hmm, don't know. May be better to filter offset out.

> 
> Kevin
> 


-- 
Best regards,
Vladimir