4 # Tests for NBD BLOCK_STATUS extension
6 # Copyright (c) 2018 Virtuozzo International GmbH
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.
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.
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/>.
23 from iotests import qemu_img_create, qemu_io, qemu_img_verbose, qemu_nbd, \
26 iotests.script_initialize(supported_fmts=['qcow2'])
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
32 qemu_img_create('-f', iotests.imgfmt, disk, '1M')
33 qemu_io('-f', iotests.imgfmt, '-c', 'write 0 512K', disk)
35 qemu_nbd('-k', nbd_sock, '-x', 'exp', '-f', iotests.imgfmt, disk)
36 qemu_img_verbose('map', '-f', 'raw', '--output=json', nbd_uri)