-#!/usr/bin/env python
+#!/usr/bin/env python3
#
-# Test cases for the QMP 'x-blockdev-del' command
+# Test cases for the QMP 'blockdev-del' command
#
# Copyright (C) 2015 Igalia, S.L.
base_img = os.path.join(iotests.test_dir, 'base.img')
new_img = os.path.join(iotests.test_dir, 'new.img')
+if iotests.qemu_default_machine == 's390-ccw-virtio':
+ default_virtio_blk = 'virtio-blk-ccw'
+else:
+ default_virtio_blk = 'virtio-blk-pci'
class TestBlockdevDel(iotests.QMPTestCase):
def setUp(self):
iotests.qemu_img('create', '-f', iotests.imgfmt, base_img, '1M')
self.vm = iotests.VM()
- self.vm.add_device("virtio-scsi-pci,id=virtio-scsi")
+ self.vm.add_device("{},id=virtio-scsi".format(
+ iotests.get_virtio_scsi_device()))
self.vm.launch()
def tearDown(self):
# Check whether a BlockDriverState exists
def checkBlockDriverState(self, node, must_exist = True):
result = self.vm.qmp('query-named-block-nodes')
- nodes = filter(lambda x: x['node-name'] == node, result['return'])
+ nodes = [x for x in result['return'] if x['node-name'] == node]
self.assertLessEqual(len(nodes), 1)
self.assertEqual(must_exist, len(nodes) == 1)
# Add a BlockDriverState that will be used as overlay for the base_img BDS
def addBlockDriverStateOverlay(self, node):
self.checkBlockDriverState(node, False)
- iotests.qemu_img('create', '-f', iotests.imgfmt,
+ iotests.qemu_img('create', '-u', '-f', iotests.imgfmt,
'-b', base_img, new_img, '1M')
opts = {'driver': iotests.imgfmt,
'node-name': node,
- 'backing': '',
+ 'backing': None,
'file': {'driver': 'file',
'filename': new_img}}
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
# Delete a BlockDriverState
def delBlockDriverState(self, node, expect_error = False):
self.checkBlockDriverState(node)
- result = self.vm.qmp('x-blockdev-del', node_name = node)
+ result = self.vm.qmp('blockdev-del', node_name = node)
if expect_error:
self.assert_qmp(result, 'error/class', 'GenericError')
else:
self.checkBlockDriverState(node, expect_error)
# Add a device model
- def addDeviceModel(self, device, backend, driver = 'virtio-blk-pci'):
+ def addDeviceModel(self, device, backend, driver = default_virtio_blk):
result = self.vm.qmp('device_add', id = device,
driver = driver, drive = backend)
self.assert_qmp(result, 'return', {})
# Insert a BlockDriverState
def insertDrive(self, device, node):
self.checkBlockDriverState(node)
- result = self.vm.qmp('x-blockdev-insert-medium',
+ result = self.vm.qmp('blockdev-insert-medium',
id = device, node_name = node)
self.assert_qmp(result, 'return', {})
self.checkBlockDriverState(node)
self.wait_until_completed(id)
# Add a BlkDebug node
- # Note that the purpose of this is to test the x-blockdev-del
+ # Note that the purpose of this is to test the blockdev-del
# sanity checks, not to create a usable blkdebug drive
def addBlkDebug(self, debug, node):
self.checkBlockDriverState(node, False)
self.checkBlockDriverState(debug)
# Add a BlkVerify node
- # Note that the purpose of this is to test the x-blockdev-del
+ # Note that the purpose of this is to test the blockdev-del
# sanity checks, not to create a usable blkverify drive
def addBlkVerify(self, blkverify, test, raw):
self.checkBlockDriverState(test, False)
# FIXME mirror0 disappears, drive-mirror doesn't take a reference
#self.delBlockDriverState('mirror0')
+ @iotests.skip_if_unsupported(['blkdebug'])
def testBlkDebug(self):
self.addBlkDebug('debug0', 'node0')
# 'node0' is used by the blkdebug node
self.delBlockDriverState('debug0')
self.checkBlockDriverState('node0', False)
+ @iotests.skip_if_unsupported(['blkverify'])
def testBlkVerify(self):
self.addBlkVerify('verify0', 'node0', 'node1')
# We cannot remove the children of a blkverify device
self.checkBlockDriverState('node0', False)
self.checkBlockDriverState('node1', False)
+ @iotests.skip_if_unsupported(['quorum'])
def testQuorum(self):
- if not 'quorum' in iotests.qemu_img_pipe('--help'):
- return
self.addQuorum('quorum0', 'node0', 'node1')
# We cannot remove the children of a Quorum device
self.delBlockDriverState('node0', expect_error = True)
if __name__ == '__main__':
- iotests.main(supported_fmts=["qcow2"])
+ iotests.main(supported_fmts=["qcow2"],
+ supported_protocols=["file"])