xref: /openbmc/qemu/tests/qemu-iotests/209 (revision e9e51b71)
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
22import iotests
23from iotests import qemu_img_create, qemu_io, qemu_img_verbose, qemu_nbd, \
24                    file_path
25
26iotests.script_initialize(supported_fmts=['qcow2'])
27
28disk = file_path('disk')
29nbd_sock = file_path('nbd-sock', base_dir=iotests.sock_dir)
30nbd_uri = 'nbd+unix:///exp?socket=' + nbd_sock
31
32qemu_img_create('-f', iotests.imgfmt, disk, '1M')
33qemu_io('-f', iotests.imgfmt, '-c', 'write 0 512K', disk)
34
35qemu_nbd('-k', nbd_sock, '-x', 'exp', '-f', iotests.imgfmt, disk)
36qemu_img_verbose('map', '-f', 'raw', '--output=json', nbd_uri)
37