xen: Rename xen_be_send_notify
[qemu.git] / tests / qemu-iotests / 132
blobf53ef6e391bc8780077748da10a40406f4d41400
1 #!/usr/bin/env python
3 # Test mirror with unmap
5 # Copyright (C) 2015 Red Hat, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 import time
22 import os
23 import iotests
24 from iotests import qemu_img, qemu_io
26 test_img = os.path.join(iotests.test_dir, 'test.img')
27 target_img = os.path.join(iotests.test_dir, 'target.img')
29 class TestSingleDrive(iotests.QMPTestCase):
30 image_len = 2 * 1024 * 1024 # MB
32 def setUp(self):
33 # Write data to the image so we can compare later
34 qemu_img('create', '-f', iotests.imgfmt, test_img, str(TestSingleDrive.image_len))
35 qemu_io('-f', iotests.imgfmt, '-c', 'write -P0x5d 0 2M', test_img)
37 self.vm = iotests.VM().add_drive(test_img, 'discard=unmap')
38 self.vm.launch()
40 def tearDown(self):
41 self.vm.shutdown()
42 os.remove(test_img)
43 try:
44 os.remove(target_img)
45 except OSError:
46 pass
48 def test_mirror_discard(self):
49 result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
50 target=target_img)
51 self.assert_qmp(result, 'return', {})
52 self.vm.hmp_qemu_io('drive0', 'discard 0 64k')
53 self.complete_and_wait('drive0')
54 self.vm.shutdown()
55 self.assertTrue(iotests.compare_images(test_img, target_img),
56 'target image does not match source after mirroring')
58 if __name__ == '__main__':
59 iotests.main(supported_fmts=['raw', 'qcow2'])