2015-11-02 14:51:56 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
2017-03-21 16:53:28 +00:00
|
|
|
# Test cases for the QMP 'blockdev-del' command
|
2015-11-02 14:51:56 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2015 Igalia, S.L.
|
|
|
|
# Author: Alberto Garcia <berto@igalia.com>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
import os
|
|
|
|
import iotests
|
|
|
|
import time
|
|
|
|
|
|
|
|
base_img = os.path.join(iotests.test_dir, 'base.img')
|
|
|
|
new_img = os.path.join(iotests.test_dir, 'new.img')
|
2017-09-13 09:10:36 +00:00
|
|
|
if iotests.qemu_default_machine == 's390-ccw-virtio':
|
|
|
|
default_virtio_blk = 'virtio-blk-ccw'
|
|
|
|
else:
|
|
|
|
default_virtio_blk = 'virtio-blk-pci'
|
2015-11-02 14:51:56 +00:00
|
|
|
|
|
|
|
class TestBlockdevDel(iotests.QMPTestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
iotests.qemu_img('create', '-f', iotests.imgfmt, base_img, '1M')
|
|
|
|
self.vm = iotests.VM()
|
2019-07-29 20:35:54 +00:00
|
|
|
self.vm.add_device("{},id=virtio-scsi".format(
|
|
|
|
iotests.get_virtio_scsi_device()))
|
2015-11-02 14:51:56 +00:00
|
|
|
self.vm.launch()
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
self.vm.shutdown()
|
|
|
|
os.remove(base_img)
|
|
|
|
if os.path.isfile(new_img):
|
|
|
|
os.remove(new_img)
|
|
|
|
|
|
|
|
# Check whether a BlockDriverState exists
|
|
|
|
def checkBlockDriverState(self, node, must_exist = True):
|
|
|
|
result = self.vm.qmp('query-named-block-nodes')
|
iotests: Different iterator behavior in Python 3
In Python 3, several functions now return iterators instead of lists.
This includes range(), items(), map(), and filter(). This means that if
we really want a list, we have to wrap those instances with list(). But
then again, the two instances where this is the case for map() and
filter(), there are shorter expressions which work without either
function.
On the other hand, sometimes we do just want an iterator, in which case
we have sometimes used xrange() and iteritems() which no longer exist in
Python 3. Just change these calls to be range() and items(), works in
both Python 2 and 3, and is really what we want in 3 (which is what
matters). But because it is so simple to do (and to find and remove
once we completely switch to Python 3), make range() be an alias for
xrange() in the two affected tests (044 and 163).
In one instance, we only wanted the first instance of the result of a
filter() call. Instead of using next(filter()) which would work only in
Python 3, or list(filter())[0] which would work everywhere but is a bit
weird, this instance is changed to use a generator expression with a
next() wrapped around, which works both in 2.7 and 3.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20181022135307.14398-6-mreitz@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-10-22 13:53:03 +00:00
|
|
|
nodes = [x for x in result['return'] if x['node-name'] == node]
|
2015-11-02 14:51:56 +00:00
|
|
|
self.assertLessEqual(len(nodes), 1)
|
|
|
|
self.assertEqual(must_exist, len(nodes) == 1)
|
|
|
|
|
|
|
|
# Add a BlockDriverState without a BlockBackend
|
|
|
|
def addBlockDriverState(self, node):
|
|
|
|
file_node = '%s_file' % node
|
|
|
|
self.checkBlockDriverState(node, False)
|
|
|
|
self.checkBlockDriverState(file_node, False)
|
|
|
|
opts = {'driver': iotests.imgfmt,
|
|
|
|
'node-name': node,
|
|
|
|
'file': {'driver': 'file',
|
|
|
|
'node-name': file_node,
|
|
|
|
'filename': base_img}}
|
2016-10-07 15:05:04 +00:00
|
|
|
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
|
2015-11-02 14:51:56 +00:00
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
self.checkBlockDriverState(node)
|
|
|
|
self.checkBlockDriverState(file_node)
|
|
|
|
|
|
|
|
# Add a BlockDriverState that will be used as overlay for the base_img BDS
|
|
|
|
def addBlockDriverStateOverlay(self, node):
|
|
|
|
self.checkBlockDriverState(node, False)
|
2017-07-18 00:34:22 +00:00
|
|
|
iotests.qemu_img('create', '-u', '-f', iotests.imgfmt,
|
2015-11-02 14:51:56 +00:00
|
|
|
'-b', base_img, new_img, '1M')
|
|
|
|
opts = {'driver': iotests.imgfmt,
|
|
|
|
'node-name': node,
|
block: Use JSON null instead of "" to disable backing file
BlockdevRef is an alternate of BlockdevOptions (inline definition) and
str (reference to an existing block device by name). BlockdevRef
value "" is special: "no block device should be referenced." It's
actually interpreted that way in just one place: optional member
@backing of COW formats. Semantics:
* Present means "use this block device" as backing storage
* Absent means "default to the one stored in the image"
* Except "" means "don't use backing storage at all"
The first two are perfectly normal: when the parameter is absent, it
defaults to an implied value, but the value's meaning is the same.
The third one overloads the parameter with a second meaning. The
overloading is *implicit*, i.e. it's not visible in the types. Works
here, because "" is not a value block device ID.
Pressing argument values the schema accepts, but are semantically
invalid, into service to mean "do something else entirely" is not
general, as suitable invalid values need not exist. I also find it
ugly.
To clean this up, we could add a separate flag argument to suppress
@backing, or add a distinct value to @backing. This commit implements
the latter: add JSON null to the values of @backing, deprecate "".
Because we're so close to the 2.10 freeze, implement it in the
stupidest way possible: have qmp_blockdev_add() rewrite null to ""
before anything else can see the null. Works, because BlockdevRef
occurs only within arguments of blockdev-add. The proper way to do it
would be rewriting "" to null, preferably in a cleaner way, but that
requires fixing up code to work with null. Add a TODO comment for
that.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-18 06:54:00 +00:00
|
|
|
'backing': None,
|
2015-11-02 14:51:56 +00:00
|
|
|
'file': {'driver': 'file',
|
|
|
|
'filename': new_img}}
|
2016-10-07 15:05:04 +00:00
|
|
|
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
|
2015-11-02 14:51:56 +00:00
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
self.checkBlockDriverState(node)
|
|
|
|
|
|
|
|
# Delete a BlockDriverState
|
|
|
|
def delBlockDriverState(self, node, expect_error = False):
|
|
|
|
self.checkBlockDriverState(node)
|
2017-03-21 16:53:28 +00:00
|
|
|
result = self.vm.qmp('blockdev-del', node_name = node)
|
2015-11-02 14:51:56 +00:00
|
|
|
if expect_error:
|
|
|
|
self.assert_qmp(result, 'error/class', 'GenericError')
|
|
|
|
else:
|
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
self.checkBlockDriverState(node, expect_error)
|
|
|
|
|
|
|
|
# Add a device model
|
2017-09-13 09:10:36 +00:00
|
|
|
def addDeviceModel(self, device, backend, driver = default_virtio_blk):
|
2015-11-02 14:51:56 +00:00
|
|
|
result = self.vm.qmp('device_add', id = device,
|
2016-09-21 12:56:08 +00:00
|
|
|
driver = driver, drive = backend)
|
2015-11-02 14:51:56 +00:00
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
|
|
|
|
# Delete a device model
|
2016-09-21 12:56:08 +00:00
|
|
|
def delDeviceModel(self, device, is_virtio_blk = True):
|
2015-11-02 14:51:56 +00:00
|
|
|
result = self.vm.qmp('device_del', id = device)
|
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
|
|
|
|
result = self.vm.qmp('system_reset')
|
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
|
2016-09-21 12:56:08 +00:00
|
|
|
if is_virtio_blk:
|
|
|
|
device_path = '/machine/peripheral/%s/virtio-backend' % device
|
|
|
|
event = self.vm.event_wait(name="DEVICE_DELETED",
|
|
|
|
match={'data': {'path': device_path}})
|
|
|
|
self.assertNotEqual(event, None)
|
2015-11-02 14:51:56 +00:00
|
|
|
|
|
|
|
event = self.vm.event_wait(name="DEVICE_DELETED",
|
|
|
|
match={'data': {'device': device}})
|
|
|
|
self.assertNotEqual(event, None)
|
|
|
|
|
|
|
|
# Remove a BlockDriverState
|
2016-09-21 12:56:08 +00:00
|
|
|
def ejectDrive(self, device, node, expect_error = False,
|
2015-11-02 14:51:56 +00:00
|
|
|
destroys_media = True):
|
|
|
|
self.checkBlockDriverState(node)
|
2016-09-21 12:56:08 +00:00
|
|
|
result = self.vm.qmp('eject', id = device)
|
2015-11-02 14:51:56 +00:00
|
|
|
if expect_error:
|
|
|
|
self.assert_qmp(result, 'error/class', 'GenericError')
|
|
|
|
self.checkBlockDriverState(node)
|
|
|
|
else:
|
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
self.checkBlockDriverState(node, not destroys_media)
|
|
|
|
|
|
|
|
# Insert a BlockDriverState
|
2016-09-21 12:56:08 +00:00
|
|
|
def insertDrive(self, device, node):
|
2015-11-02 14:51:56 +00:00
|
|
|
self.checkBlockDriverState(node)
|
2017-11-10 22:43:02 +00:00
|
|
|
result = self.vm.qmp('blockdev-insert-medium',
|
2016-09-21 12:56:08 +00:00
|
|
|
id = device, node_name = node)
|
2015-11-02 14:51:56 +00:00
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
self.checkBlockDriverState(node)
|
|
|
|
|
|
|
|
# Create a snapshot using 'blockdev-snapshot-sync'
|
|
|
|
def createSnapshotSync(self, node, overlay):
|
|
|
|
self.checkBlockDriverState(node)
|
|
|
|
self.checkBlockDriverState(overlay, False)
|
|
|
|
opts = {'node-name': node,
|
|
|
|
'snapshot-file': new_img,
|
|
|
|
'snapshot-node-name': overlay,
|
|
|
|
'format': iotests.imgfmt}
|
|
|
|
result = self.vm.qmp('blockdev-snapshot-sync', conv_keys=False, **opts)
|
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
self.checkBlockDriverState(node)
|
|
|
|
self.checkBlockDriverState(overlay)
|
|
|
|
|
|
|
|
# Create a snapshot using 'blockdev-snapshot'
|
|
|
|
def createSnapshot(self, node, overlay):
|
|
|
|
self.checkBlockDriverState(node)
|
|
|
|
self.checkBlockDriverState(overlay)
|
|
|
|
result = self.vm.qmp('blockdev-snapshot',
|
|
|
|
node = node, overlay = overlay)
|
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
self.checkBlockDriverState(node)
|
|
|
|
self.checkBlockDriverState(overlay)
|
|
|
|
|
|
|
|
# Create a mirror
|
2016-09-21 12:56:08 +00:00
|
|
|
def createMirror(self, node, new_node):
|
2015-11-02 14:51:56 +00:00
|
|
|
self.checkBlockDriverState(new_node, False)
|
2016-09-21 12:56:08 +00:00
|
|
|
opts = {'device': node,
|
|
|
|
'job-id': node,
|
2015-11-02 14:51:56 +00:00
|
|
|
'target': new_img,
|
|
|
|
'node-name': new_node,
|
|
|
|
'sync': 'top',
|
|
|
|
'format': iotests.imgfmt}
|
|
|
|
result = self.vm.qmp('drive-mirror', conv_keys=False, **opts)
|
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
self.checkBlockDriverState(new_node)
|
|
|
|
|
|
|
|
# Complete an existing block job
|
2016-09-21 12:56:08 +00:00
|
|
|
def completeBlockJob(self, id, node_before, node_after):
|
|
|
|
result = self.vm.qmp('block-job-complete', device=id)
|
2015-11-02 14:51:56 +00:00
|
|
|
self.assert_qmp(result, 'return', {})
|
2016-09-21 12:56:08 +00:00
|
|
|
self.wait_until_completed(id)
|
2015-11-02 14:51:56 +00:00
|
|
|
|
|
|
|
# Add a BlkDebug node
|
2017-03-21 16:53:28 +00:00
|
|
|
# Note that the purpose of this is to test the blockdev-del
|
2015-11-02 14:51:56 +00:00
|
|
|
# sanity checks, not to create a usable blkdebug drive
|
|
|
|
def addBlkDebug(self, debug, node):
|
|
|
|
self.checkBlockDriverState(node, False)
|
|
|
|
self.checkBlockDriverState(debug, False)
|
|
|
|
image = {'driver': iotests.imgfmt,
|
|
|
|
'node-name': node,
|
|
|
|
'file': {'driver': 'file',
|
|
|
|
'filename': base_img}}
|
|
|
|
opts = {'driver': 'blkdebug',
|
|
|
|
'node-name': debug,
|
|
|
|
'image': image}
|
2016-10-07 15:05:04 +00:00
|
|
|
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
|
2015-11-02 14:51:56 +00:00
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
self.checkBlockDriverState(node)
|
|
|
|
self.checkBlockDriverState(debug)
|
|
|
|
|
|
|
|
# Add a BlkVerify node
|
2017-03-21 16:53:28 +00:00
|
|
|
# Note that the purpose of this is to test the blockdev-del
|
2015-11-02 14:51:56 +00:00
|
|
|
# sanity checks, not to create a usable blkverify drive
|
|
|
|
def addBlkVerify(self, blkverify, test, raw):
|
|
|
|
self.checkBlockDriverState(test, False)
|
|
|
|
self.checkBlockDriverState(raw, False)
|
|
|
|
self.checkBlockDriverState(blkverify, False)
|
|
|
|
iotests.qemu_img('create', '-f', iotests.imgfmt, new_img, '1M')
|
|
|
|
node_0 = {'driver': iotests.imgfmt,
|
|
|
|
'node-name': test,
|
|
|
|
'file': {'driver': 'file',
|
|
|
|
'filename': base_img}}
|
|
|
|
node_1 = {'driver': iotests.imgfmt,
|
|
|
|
'node-name': raw,
|
|
|
|
'file': {'driver': 'file',
|
|
|
|
'filename': new_img}}
|
|
|
|
opts = {'driver': 'blkverify',
|
|
|
|
'node-name': blkverify,
|
|
|
|
'test': node_0,
|
|
|
|
'raw': node_1}
|
2016-10-07 15:05:04 +00:00
|
|
|
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
|
2015-11-02 14:51:56 +00:00
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
self.checkBlockDriverState(test)
|
|
|
|
self.checkBlockDriverState(raw)
|
|
|
|
self.checkBlockDriverState(blkverify)
|
|
|
|
|
|
|
|
# Add a Quorum node
|
|
|
|
def addQuorum(self, quorum, child0, child1):
|
|
|
|
self.checkBlockDriverState(child0, False)
|
|
|
|
self.checkBlockDriverState(child1, False)
|
|
|
|
self.checkBlockDriverState(quorum, False)
|
|
|
|
iotests.qemu_img('create', '-f', iotests.imgfmt, new_img, '1M')
|
|
|
|
child_0 = {'driver': iotests.imgfmt,
|
|
|
|
'node-name': child0,
|
|
|
|
'file': {'driver': 'file',
|
|
|
|
'filename': base_img}}
|
|
|
|
child_1 = {'driver': iotests.imgfmt,
|
|
|
|
'node-name': child1,
|
|
|
|
'file': {'driver': 'file',
|
|
|
|
'filename': new_img}}
|
|
|
|
opts = {'driver': 'quorum',
|
|
|
|
'node-name': quorum,
|
|
|
|
'vote-threshold': 1,
|
|
|
|
'children': [ child_0, child_1 ]}
|
2016-10-07 15:05:04 +00:00
|
|
|
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
|
2015-11-02 14:51:56 +00:00
|
|
|
self.assert_qmp(result, 'return', {})
|
|
|
|
self.checkBlockDriverState(child0)
|
|
|
|
self.checkBlockDriverState(child1)
|
|
|
|
self.checkBlockDriverState(quorum)
|
|
|
|
|
|
|
|
########################
|
|
|
|
# The tests start here #
|
|
|
|
########################
|
|
|
|
|
|
|
|
def testBlockDriverState(self):
|
|
|
|
self.addBlockDriverState('node0')
|
|
|
|
# You cannot delete a file BDS directly
|
|
|
|
self.delBlockDriverState('node0_file', expect_error = True)
|
|
|
|
self.delBlockDriverState('node0')
|
|
|
|
|
|
|
|
def testDeviceModel(self):
|
2016-09-21 12:56:08 +00:00
|
|
|
self.addBlockDriverState('node0')
|
|
|
|
self.addDeviceModel('device0', 'node0')
|
|
|
|
self.ejectDrive('device0', 'node0', expect_error = True)
|
|
|
|
self.delBlockDriverState('node0', expect_error = True)
|
2015-11-02 14:51:56 +00:00
|
|
|
self.delDeviceModel('device0')
|
2016-09-21 12:56:08 +00:00
|
|
|
self.delBlockDriverState('node0')
|
2015-11-02 14:51:56 +00:00
|
|
|
|
|
|
|
def testAttachMedia(self):
|
|
|
|
# This creates a BlockBackend and removes its media
|
2016-09-21 12:56:08 +00:00
|
|
|
self.addBlockDriverState('node0')
|
|
|
|
self.addDeviceModel('device0', 'node0', 'scsi-cd')
|
|
|
|
self.ejectDrive('device0', 'node0', destroys_media = False)
|
|
|
|
self.delBlockDriverState('node0')
|
|
|
|
|
|
|
|
# This creates a new BlockDriverState and inserts it into the device
|
2015-11-02 14:51:56 +00:00
|
|
|
self.addBlockDriverState('node1')
|
2016-09-21 12:56:08 +00:00
|
|
|
self.insertDrive('device0', 'node1')
|
|
|
|
# The node can't be removed: the new device has an extra reference
|
2015-11-02 14:51:56 +00:00
|
|
|
self.delBlockDriverState('node1', expect_error = True)
|
|
|
|
# The BDS still exists after being ejected, but now it can be removed
|
2016-09-21 12:56:08 +00:00
|
|
|
self.ejectDrive('device0', 'node1', destroys_media = False)
|
2015-11-02 14:51:56 +00:00
|
|
|
self.delBlockDriverState('node1')
|
2016-09-21 12:56:08 +00:00
|
|
|
self.delDeviceModel('device0', False)
|
2015-11-02 14:51:56 +00:00
|
|
|
|
|
|
|
def testSnapshotSync(self):
|
2016-09-21 12:56:08 +00:00
|
|
|
self.addBlockDriverState('node0')
|
|
|
|
self.addDeviceModel('device0', 'node0')
|
2015-11-02 14:51:56 +00:00
|
|
|
self.createSnapshotSync('node0', 'overlay0')
|
|
|
|
# This fails because node0 is now being used as a backing image
|
|
|
|
self.delBlockDriverState('node0', expect_error = True)
|
2016-09-21 12:56:08 +00:00
|
|
|
self.delBlockDriverState('overlay0', expect_error = True)
|
|
|
|
# This succeeds because device0 only has the backend reference
|
|
|
|
self.delDeviceModel('device0')
|
|
|
|
# FIXME Would still be there if blockdev-snapshot-sync took a ref
|
|
|
|
self.checkBlockDriverState('overlay0', False)
|
|
|
|
self.delBlockDriverState('node0')
|
2015-11-02 14:51:56 +00:00
|
|
|
|
|
|
|
def testSnapshot(self):
|
2016-09-21 12:56:08 +00:00
|
|
|
self.addBlockDriverState('node0')
|
|
|
|
self.addDeviceModel('device0', 'node0', 'scsi-cd')
|
2015-11-02 14:51:56 +00:00
|
|
|
self.addBlockDriverStateOverlay('overlay0')
|
|
|
|
self.createSnapshot('node0', 'overlay0')
|
|
|
|
self.delBlockDriverState('node0', expect_error = True)
|
|
|
|
self.delBlockDriverState('overlay0', expect_error = True)
|
2016-09-21 12:56:08 +00:00
|
|
|
self.ejectDrive('device0', 'overlay0', destroys_media = False)
|
2015-11-02 14:51:56 +00:00
|
|
|
self.delBlockDriverState('node0', expect_error = True)
|
|
|
|
self.delBlockDriverState('overlay0')
|
2016-09-21 12:56:08 +00:00
|
|
|
self.delBlockDriverState('node0')
|
2015-11-02 14:51:56 +00:00
|
|
|
|
|
|
|
def testMirror(self):
|
2016-09-21 12:56:08 +00:00
|
|
|
self.addBlockDriverState('node0')
|
|
|
|
self.addDeviceModel('device0', 'node0', 'scsi-cd')
|
|
|
|
self.createMirror('node0', 'mirror0')
|
2015-11-02 14:51:56 +00:00
|
|
|
# The block job prevents removing the device
|
|
|
|
self.delBlockDriverState('node0', expect_error = True)
|
|
|
|
self.delBlockDriverState('mirror0', expect_error = True)
|
2016-09-21 12:56:08 +00:00
|
|
|
self.wait_ready('node0')
|
|
|
|
self.completeBlockJob('node0', 'node0', 'mirror0')
|
2015-11-02 14:51:56 +00:00
|
|
|
self.assert_no_active_block_jobs()
|
2016-09-21 12:56:08 +00:00
|
|
|
# This succeeds because the device now points to mirror0
|
|
|
|
self.delBlockDriverState('node0')
|
|
|
|
self.delBlockDriverState('mirror0', expect_error = True)
|
|
|
|
self.delDeviceModel('device0', False)
|
|
|
|
# FIXME mirror0 disappears, drive-mirror doesn't take a reference
|
|
|
|
#self.delBlockDriverState('mirror0')
|
2015-11-02 14:51:56 +00:00
|
|
|
|
2019-03-07 13:34:00 +00:00
|
|
|
@iotests.skip_if_unsupported(['blkdebug'])
|
2015-11-02 14:51:56 +00:00
|
|
|
def testBlkDebug(self):
|
|
|
|
self.addBlkDebug('debug0', 'node0')
|
|
|
|
# 'node0' is used by the blkdebug node
|
|
|
|
self.delBlockDriverState('node0', expect_error = True)
|
|
|
|
# But we can remove the blkdebug node directly
|
|
|
|
self.delBlockDriverState('debug0')
|
|
|
|
self.checkBlockDriverState('node0', False)
|
|
|
|
|
2019-03-07 13:34:00 +00:00
|
|
|
@iotests.skip_if_unsupported(['blkverify'])
|
2015-11-02 14:51:56 +00:00
|
|
|
def testBlkVerify(self):
|
|
|
|
self.addBlkVerify('verify0', 'node0', 'node1')
|
|
|
|
# We cannot remove the children of a blkverify device
|
|
|
|
self.delBlockDriverState('node0', expect_error = True)
|
|
|
|
self.delBlockDriverState('node1', expect_error = True)
|
|
|
|
# But we can remove the blkverify node directly
|
|
|
|
self.delBlockDriverState('verify0')
|
|
|
|
self.checkBlockDriverState('node0', False)
|
|
|
|
self.checkBlockDriverState('node1', False)
|
|
|
|
|
2019-03-07 13:34:00 +00:00
|
|
|
@iotests.skip_if_unsupported(['quorum'])
|
2015-11-02 14:51:56 +00:00
|
|
|
def testQuorum(self):
|
2016-10-28 07:08:17 +00:00
|
|
|
if not iotests.supports_quorum():
|
2015-11-10 16:28:11 +00:00
|
|
|
return
|
2016-10-28 07:08:17 +00:00
|
|
|
|
2015-11-02 14:51:56 +00:00
|
|
|
self.addQuorum('quorum0', 'node0', 'node1')
|
|
|
|
# We cannot remove the children of a Quorum device
|
|
|
|
self.delBlockDriverState('node0', expect_error = True)
|
|
|
|
self.delBlockDriverState('node1', expect_error = True)
|
|
|
|
# But we can remove the Quorum node directly
|
|
|
|
self.delBlockDriverState('quorum0')
|
|
|
|
self.checkBlockDriverState('node0', False)
|
|
|
|
self.checkBlockDriverState('node1', False)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2019-09-02 19:33:18 +00:00
|
|
|
iotests.main(supported_fmts=["qcow2"],
|
|
|
|
supported_protocols=["file"])
|