xref: /openbmc/qemu/tests/qemu-iotests/209 (revision 8f9e54cc)
17c477526SPhilippe Mathieu-Daudé#!/usr/bin/env python3
29dd003a9SVladimir Sementsov-Ogievskiy# group: rw quick
365374c1aSVladimir Sementsov-Ogievskiy#
465374c1aSVladimir Sementsov-Ogievskiy# Tests for NBD BLOCK_STATUS extension
565374c1aSVladimir Sementsov-Ogievskiy#
665374c1aSVladimir Sementsov-Ogievskiy# Copyright (c) 2018 Virtuozzo International GmbH
765374c1aSVladimir Sementsov-Ogievskiy#
865374c1aSVladimir Sementsov-Ogievskiy# This program is free software; you can redistribute it and/or modify
965374c1aSVladimir Sementsov-Ogievskiy# it under the terms of the GNU General Public License as published by
1065374c1aSVladimir Sementsov-Ogievskiy# the Free Software Foundation; either version 2 of the License, or
1165374c1aSVladimir Sementsov-Ogievskiy# (at your option) any later version.
1265374c1aSVladimir Sementsov-Ogievskiy#
1365374c1aSVladimir Sementsov-Ogievskiy# This program is distributed in the hope that it will be useful,
1465374c1aSVladimir Sementsov-Ogievskiy# but WITHOUT ANY WARRANTY; without even the implied warranty of
1565374c1aSVladimir Sementsov-Ogievskiy# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1665374c1aSVladimir Sementsov-Ogievskiy# GNU General Public License for more details.
1765374c1aSVladimir Sementsov-Ogievskiy#
1865374c1aSVladimir Sementsov-Ogievskiy# You should have received a copy of the GNU General Public License
1965374c1aSVladimir Sementsov-Ogievskiy# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2065374c1aSVladimir Sementsov-Ogievskiy#
2165374c1aSVladimir Sementsov-Ogievskiy
2265374c1aSVladimir Sementsov-Ogievskiyimport iotests
23*8f9e54ccSVladimir Sementsov-Ogievskiyfrom iotests import qemu_img_create, qemu_io, qemu_img_log, qemu_nbd, \
24*8f9e54ccSVladimir Sementsov-Ogievskiy                    file_path, log
2565374c1aSVladimir Sementsov-Ogievskiy
267d814059SJohn Snowiotests.script_initialize(supported_fmts=['qcow2'])
2765374c1aSVladimir Sementsov-Ogievskiy
2873752070SMax Reitzdisk = file_path('disk')
2973752070SMax Reitznbd_sock = file_path('nbd-sock', base_dir=iotests.sock_dir)
3065374c1aSVladimir Sementsov-Ogievskiynbd_uri = 'nbd+unix:///exp?socket=' + nbd_sock
3165374c1aSVladimir Sementsov-Ogievskiy
3265374c1aSVladimir Sementsov-Ogievskiyqemu_img_create('-f', iotests.imgfmt, disk, '1M')
3365374c1aSVladimir Sementsov-Ogievskiyqemu_io('-f', iotests.imgfmt, '-c', 'write 0 512K', disk)
3465374c1aSVladimir Sementsov-Ogievskiy
3565374c1aSVladimir Sementsov-Ogievskiyqemu_nbd('-k', nbd_sock, '-x', 'exp', '-f', iotests.imgfmt, disk)
36*8f9e54ccSVladimir Sementsov-Ogievskiyqemu_img_log('map', '-f', 'raw', '--output=json', nbd_uri)
37*8f9e54ccSVladimir Sementsov-Ogievskiylog('done.')  # avoid new line at the end of output file
38