]> git.proxmox.com Git - mirror_qemu.git/blame - tests/qemu-iotests/196
Merge tag 'pull-maintainer-may24-160524-2' of https://gitlab.com/stsquad/qemu into...
[mirror_qemu.git] / tests / qemu-iotests / 196
CommitLineData
903cb1bf 1#!/usr/bin/env python3
9dd003a9 2# group: rw quick migration
3590cd0f
VSO
3#
4# Test clearing unknown autoclear_features flag by qcow2 after
5# migration. This test mimics migration to older qemu.
6#
7# Copyright (c) 2017 Parallels International GmbH
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21#
22
23import os
24import iotests
25from iotests import qemu_img
26
27disk = os.path.join(iotests.test_dir, 'disk')
28migfile = os.path.join(iotests.test_dir, 'migfile')
29
30class TestInvalidateAutoclear(iotests.QMPTestCase):
31
32 def tearDown(self):
33 self.vm_a.shutdown()
34 self.vm_b.shutdown()
35 os.remove(disk)
36 os.remove(migfile)
37
38 def setUp(self):
39 qemu_img('create', '-f', iotests.imgfmt, disk, '1M')
40
41 self.vm_a = iotests.VM(path_suffix='a').add_drive(disk)
42 self.vm_a.launch()
43
44 self.vm_b = iotests.VM(path_suffix='b').add_drive(disk)
45 self.vm_b.add_incoming("exec: cat '" + migfile + "'")
46
47 def test_migration(self):
b6aed193 48 self.vm_a.cmd('migrate', uri='exec:cat>' + migfile)
3590cd0f
VSO
49 self.assertNotEqual(self.vm_a.event_wait("STOP"), None)
50
51 with open(disk, 'r+b') as f:
52 f.seek(88) # first byte of autoclear_features field
53 f.write(b'\xff')
54
55 self.vm_b.launch()
56 while True:
57 result = self.vm_b.qmp('query-status')
58 if result['return']['status'] == 'running':
59 break
60
61 with open(disk, 'rb') as f:
62 f.seek(88)
63 self.assertEqual(f.read(1), b'\x00')
64
65if __name__ == '__main__':
103cbc77 66 iotests.main(supported_fmts=['qcow2'],
b30b8077
VSO
67 supported_protocols=['file'],
68 unsupported_imgopts=['compat'])