From nobody Mon Apr 29 21:15:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510336616834420.74164878998613; Fri, 10 Nov 2017 09:56:56 -0800 (PST) Received: from localhost ([::1]:42903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDDXk-0003JB-7H for importer@patchew.org; Fri, 10 Nov 2017 12:56:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDDWU-0002ie-UZ for qemu-devel@nongnu.org; Fri, 10 Nov 2017 12:55:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDDWQ-0006tA-Se for qemu-devel@nongnu.org; Fri, 10 Nov 2017 12:55:22 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:48670 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDDWQ-0006sF-Gn for qemu-devel@nongnu.org; Fri, 10 Nov 2017 12:55:18 -0500 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id vAAHsvT3012143; Fri, 10 Nov 2017 20:54:58 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Fri, 10 Nov 2017 20:54:57 +0300 Message-Id: <20171110175457.30173-1-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH] iotests: test clearing unknown autoclear_features by qcow2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, quintela@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Test clearing unknown autoclear_features by qcow2 on incoming migration. Signed-off-by: Vladimir Sementsov-Ogievskiy --- Hi all! This patch shows degradation, added in 2.10 in commit commit 9c5e6594f15b7364624a3ad40306c396c93a2145 Author: Kevin Wolf Date: Thu May 4 18:52:40 2017 +0200 block: Fix write/resize permissions for inactive images The problem: When on incoming migration with shared storage we reopen image to RW mode we call bdrv_invalidate_cache it firstly call drv->bdrv_invalidate_cache and only after it, through "parent->role->activate(parent, &local_err);" we set appropriate RW permission. Because of this, if drv->bdrv_invalidate_cache wants to write something (image is RW and BDRV_O_INACTIVE is not set) it goes into "bdrv_aligned_pwritev: Assertion `child->perm & BLK_PERM_WRITE' failed" One case, when qcow2_invalidate_cache wants to write something - when it wants to clear some unknown autoclear features. So, here is a test for it. Another case is when we try to migrate persistent dirty bitmaps through shared storage, on invalidate_cache qcow2 will try to set DIRTY bit in all loaded bitmaps. Kevin, what do you think? I understand that operation order should be chang= ed somehow in bdrv_invalidate_cache, but I'm not sure about how "parent->role-= >.." things works and can we safely move this part from function end to the midd= le. tests/qemu-iotests/196 | 63 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/196.out | 5 ++++ tests/qemu-iotests/group | 1 + 3 files changed, 69 insertions(+) create mode 100755 tests/qemu-iotests/196 create mode 100644 tests/qemu-iotests/196.out diff --git a/tests/qemu-iotests/196 b/tests/qemu-iotests/196 new file mode 100755 index 0000000000..9ffbc723c2 --- /dev/null +++ b/tests/qemu-iotests/196 @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# +# Test clearing unknown autoclear_features flag by qcow2 after +# migration. This test mimics migration to older qemu. +# +# Copyright (c) 2017 Parallels International GmbH +# +# 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 . +# + +import os +import iotests +from iotests import qemu_img + +disk =3D os.path.join(iotests.test_dir, 'disk') +migfile =3D os.path.join(iotests.test_dir, 'migfile') + +class TestInvalidateAutoclear(iotests.QMPTestCase): + + def tearDown(self): + self.vm_a.shutdown() + self.vm_b.shutdown() + os.remove(disk) + os.remove(migfile) + + def setUp(self): + qemu_img('create', '-f', iotests.imgfmt, disk, '1M') + + self.vm_a =3D iotests.VM(path_suffix=3D'a').add_drive(disk) + self.vm_a.launch() + + self.vm_b =3D iotests.VM(path_suffix=3D'b').add_drive(disk) + self.vm_b.add_incoming("exec: cat '" + migfile + "'") + + def test_migration(self): + result =3D self.vm_a.qmp('migrate', uri=3D'exec:cat>' + migfile) + self.assert_qmp(result, 'return', {}); + self.assertNotEqual(self.vm_a.event_wait("STOP"), None) + + with open(disk, 'r+b') as f: + f.seek(88) # first byte of autoclear_features field + f.write(b'\xff') + + self.vm_b.launch() + self.assertNotEqual(self.vm_b.event_wait("RESUME"), None) + + with open(disk, 'rb') as f: + f.seek(88) + self.assertEqual(f.read(1), b'\x00') + +if __name__ =3D=3D '__main__': + iotests.main(supported_fmts=3D['qcow2']) diff --git a/tests/qemu-iotests/196.out b/tests/qemu-iotests/196.out new file mode 100644 index 0000000000..ae1213e6f8 --- /dev/null +++ b/tests/qemu-iotests/196.out @@ -0,0 +1,5 @@ +. +---------------------------------------------------------------------- +Ran 1 tests + +OK diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 24e5ad1b79..78d01d9516 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -193,4 +193,5 @@ 192 rw auto quick 194 rw auto migration quick 195 rw auto quick +196 rw auto quick 197 rw auto quick --=20 2.11.1