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