4 # Copyright (C) 2018 Red Hat, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # Creator/Owner: Stefan Hajnoczi <stefanha@redhat.com>
21 # Check that the runtime NBD server does not crash when stopped after
22 # blockdev-snapshot-sync.
26 iotests.script_initialize(supported_fmts=['generic'])
28 with iotests.FilePath('disk.img') as disk_img_path, \
29 iotests.FilePath('disk-snapshot.img') as disk_snapshot_img_path, \
30 iotests.FilePath('nbd.sock', base_dir=iotests.sock_dir) as nbd_sock_path, \
34 iotests.qemu_img_create('-f', iotests.imgfmt, disk_img_path, img_size)
36 iotests.log('Launching VM...')
37 (vm.add_drive(disk_img_path, 'node-name=drive0-node', interface='none')
40 iotests.log('Starting NBD server...')
41 iotests.log(vm.qmp('nbd-server-start', addr={
44 "path": nbd_sock_path,
48 iotests.log('Adding NBD export...')
49 iotests.log(vm.qmp('nbd-server-add', device='drive0-node', writable=True))
51 iotests.log('Creating external snapshot...')
52 iotests.log(vm.qmp('blockdev-snapshot-sync',
53 node_name='drive0-node',
54 snapshot_node_name='drive0-snapshot-node',
55 snapshot_file=disk_snapshot_img_path))
57 iotests.log('Stopping NBD server...')
58 iotests.log(vm.qmp('nbd-server-stop'))