209 (1373B)
1 #!/usr/bin/env python3 2 # group: rw quick 3 # 4 # Tests for NBD BLOCK_STATUS extension 5 # 6 # Copyright (c) 2018 Virtuozzo 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 22 import iotests 23 from iotests import qemu_img_create, qemu_io, qemu_img_log, qemu_nbd, \ 24 file_path, log 25 26 iotests.script_initialize(supported_fmts=['qcow2']) 27 28 disk = file_path('disk') 29 nbd_sock = file_path('nbd-sock', base_dir=iotests.sock_dir) 30 nbd_uri = 'nbd+unix:///exp?socket=' + nbd_sock 31 32 qemu_img_create('-f', iotests.imgfmt, disk, '1M') 33 qemu_io('-f', iotests.imgfmt, '-c', 'write 0 512K', disk) 34 35 qemu_nbd('-k', nbd_sock, '-x', 'exp', '-f', iotests.imgfmt, disk) 36 qemu_img_log('map', '-f', 'raw', '--output=json', nbd_uri) 37 log('done.') # avoid new line at the end of output file