All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	"qemu-block@nongnu.org" <qemu-block@nongnu.org>
Cc: Kevin Wolf <kwolf@redhat.com>, John Snow <jsnow@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 4/4] iotests: Add test for failing mirror complete
Date: Thu, 19 Sep 2019 18:51:28 +0200	[thread overview]
Message-ID: <737afcda-cbfd-2699-72f1-6775ff0f3169@redhat.com> (raw)
In-Reply-To: <19f8eac0-7722-4894-72bb-df7501ca20ef@virtuozzo.com>


[-- Attachment #1.1: Type: text/plain, Size: 3110 bytes --]

On 18.09.19 18:30, Vladimir Sementsov-Ogievskiy wrote:
> 12.09.2019 16:56, Max Reitz wrote:
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>>   tests/qemu-iotests/041     | 44 ++++++++++++++++++++++++++++++++++++++
>>   tests/qemu-iotests/041.out |  4 ++--
>>   2 files changed, 46 insertions(+), 2 deletions(-)
>>
>> diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
>> index 8568426311..84bc6d6581 100755
>> --- a/tests/qemu-iotests/041
>> +++ b/tests/qemu-iotests/041
>> @@ -1121,6 +1121,50 @@ class TestOrphanedSource(iotests.QMPTestCase):
>>                                target='dest-ro')
>>           self.assert_qmp(result, 'error/class', 'GenericError')
>>   
>> +    def test_failing_permission_in_complete(self):
>> +        self.assert_no_active_block_jobs()
>> +
>> +        # Unshare consistent-read on the target
>> +        # (The mirror job does not care)
>> +        result = self.vm.qmp('blockdev-add',
>> +                             driver='blkdebug',
>> +                             node_name='dest-perm',
>> +                             image='dest',
>> +                             unshare_child_perms=['consistent-read'])
>> +        self.assert_qmp(result, 'return', {})
>> +
>> +        result = self.vm.qmp('blockdev-mirror', job_id='job', device='src',
>> +                             sync='full', target='dest',
>> +                             filter_node_name='mirror-filter')
>> +        self.assert_qmp(result, 'return', {})
>> +
>> +        # Require consistent-read on the source
>> +        # (We can only add this node once the job has started, or it
>> +        # will complain that it does not want to run on non-root nodes)
>> +        result = self.vm.qmp('blockdev-add',
>> +                             driver='blkdebug',
>> +                             node_name='src-perm',
>> +                             image='src',
>> +                             take_child_perms=['consistent-read'])
>> +        self.assert_qmp(result, 'return', {})
>> +
>> +        # While completing, mirror will attempt to replace src by
>> +        # dest, which must fail because src-perm requires
>> +        # consistent-read but dest-perm does not share it; thus
>> +        # aborting the job when it is supposed to complete
>> +        self.complete_and_wait('job',
>> +                               completion_error='Operation not permitted')
>> +
>> +        # Assert that all of our nodes are still there (except for the
>> +        # mirror filter, which should be gone despite the failure)
>> +        nodes = self.vm.qmp('query-named-block-nodes')['return']
>> +        nodes = list(map(lambda image: image['node-name'], nodes))
> 
> using list comprehension is a bit more pythonic:
> nodes = [node['node-name'] for node in nodes]

OK.  I can never remember, so I rarely bother using list/dict
comprehensions and instead use what I would do in any other language.
(Hence the “Sadly” from John.)

(And then wait for some kind reviewer to tell me how to do it right. :-))

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-09-19 16:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-12 13:56 [Qemu-devel] [PATCH 0/4] mirror: Do not dereference invalid pointers Max Reitz
2019-09-12 13:56 ` [Qemu-devel] [PATCH 1/4] " Max Reitz
2019-09-13 22:43   ` John Snow
2019-09-18 15:16   ` Vladimir Sementsov-Ogievskiy
2019-09-12 13:56 ` [Qemu-devel] [PATCH 2/4] blkdebug: Allow taking/unsharing permissions Max Reitz
2019-09-18 16:01   ` Vladimir Sementsov-Ogievskiy
2019-09-19 16:49     ` Max Reitz
2019-09-12 13:56 ` [Qemu-devel] [PATCH 3/4] iotests: Add @error to wait_until_completed Max Reitz
2019-09-13 22:53   ` John Snow
2019-09-16  7:56     ` Max Reitz
2019-09-18 16:09   ` Vladimir Sementsov-Ogievskiy
2019-09-12 13:56 ` [Qemu-devel] [PATCH 4/4] iotests: Add test for failing mirror complete Max Reitz
2019-09-18 16:30   ` Vladimir Sementsov-Ogievskiy
2019-09-19 16:51     ` Max Reitz [this message]
2019-09-18 18:46   ` John Snow
2019-09-19 16:58     ` Max Reitz
2019-09-19 17:02       ` John Snow
2019-09-19 17:06         ` Max Reitz
2019-09-18 15:38 ` [Qemu-devel] [PATCH 0/4] mirror: Do not dereference invalid pointers Vladimir Sementsov-Ogievskiy
2019-09-19 16:45   ` Max Reitz
2019-09-19 16:50     ` Vladimir Sementsov-Ogievskiy

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=737afcda-cbfd-2699-72f1-6775ff0f3169@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.