]> Git Repo - qemu.git/blame - tests/qemu-iotests/196
iotests: Add qemu_io_log()
[qemu.git] / tests / qemu-iotests / 196
CommitLineData
3590cd0f
VSO
1#!/usr/bin/env python
2#
3# Test clearing unknown autoclear_features flag by qcow2 after
4# migration. This test mimics migration to older qemu.
5#
6# Copyright (c) 2017 Parallels International GmbH
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21
22import os
23import iotests
24from iotests import qemu_img
25
26disk = os.path.join(iotests.test_dir, 'disk')
27migfile = os.path.join(iotests.test_dir, 'migfile')
28
29class TestInvalidateAutoclear(iotests.QMPTestCase):
30
31 def tearDown(self):
32 self.vm_a.shutdown()
33 self.vm_b.shutdown()
34 os.remove(disk)
35 os.remove(migfile)
36
37 def setUp(self):
38 qemu_img('create', '-f', iotests.imgfmt, disk, '1M')
39
40 self.vm_a = iotests.VM(path_suffix='a').add_drive(disk)
41 self.vm_a.launch()
42
43 self.vm_b = iotests.VM(path_suffix='b').add_drive(disk)
44 self.vm_b.add_incoming("exec: cat '" + migfile + "'")
45
46 def test_migration(self):
47 result = self.vm_a.qmp('migrate', uri='exec:cat>' + migfile)
48 self.assert_qmp(result, 'return', {});
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
HR
66 iotests.main(supported_fmts=['qcow2'],
67 supported_protocols=['file'])
This page took 0.162586 seconds and 4 git commands to generate.