xref: /qemu/tests/qemu-iotests/139 (revision 22329f0d2963515e031584d21a03d3585b19cbf9)
1903cb1bfSPhilippe Mathieu-Daudé#!/usr/bin/env python3
29dd003a9SVladimir Sementsov-Ogievskiy# group: rw quick
3342075fdSAlberto Garcia#
479b7a77eSMarkus Armbruster# Test cases for the QMP 'blockdev-del' command
5342075fdSAlberto Garcia#
6342075fdSAlberto Garcia# Copyright (C) 2015 Igalia, S.L.
7342075fdSAlberto Garcia# Author: Alberto Garcia <berto@igalia.com>
8342075fdSAlberto Garcia#
9342075fdSAlberto Garcia# This program is free software; you can redistribute it and/or modify
10342075fdSAlberto Garcia# it under the terms of the GNU General Public License as published by
11342075fdSAlberto Garcia# the Free Software Foundation; either version 2 of the License, or
12342075fdSAlberto Garcia# (at your option) any later version.
13342075fdSAlberto Garcia#
14342075fdSAlberto Garcia# This program is distributed in the hope that it will be useful,
15342075fdSAlberto Garcia# but WITHOUT ANY WARRANTY; without even the implied warranty of
16342075fdSAlberto Garcia# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17342075fdSAlberto Garcia# GNU General Public License for more details.
18342075fdSAlberto Garcia#
19342075fdSAlberto Garcia# You should have received a copy of the GNU General Public License
20342075fdSAlberto Garcia# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21342075fdSAlberto Garcia#
22342075fdSAlberto Garcia
23342075fdSAlberto Garciaimport os
24342075fdSAlberto Garciaimport iotests
25342075fdSAlberto Garciaimport time
26342075fdSAlberto Garcia
27342075fdSAlberto Garciabase_img = os.path.join(iotests.test_dir, 'base.img')
28342075fdSAlberto Garcianew_img = os.path.join(iotests.test_dir, 'new.img')
29342075fdSAlberto Garcia
30342075fdSAlberto Garciaclass TestBlockdevDel(iotests.QMPTestCase):
31342075fdSAlberto Garcia
32342075fdSAlberto Garcia    def setUp(self):
33342075fdSAlberto Garcia        iotests.qemu_img('create', '-f', iotests.imgfmt, base_img, '1M')
34342075fdSAlberto Garcia        self.vm = iotests.VM()
35*22329f0dSLaurent Vivier        self.vm.add_device("{},id=virtio-scsi".format('virtio-scsi'))
36342075fdSAlberto Garcia        self.vm.launch()
37342075fdSAlberto Garcia
38342075fdSAlberto Garcia    def tearDown(self):
39342075fdSAlberto Garcia        self.vm.shutdown()
40342075fdSAlberto Garcia        os.remove(base_img)
41342075fdSAlberto Garcia        if os.path.isfile(new_img):
42342075fdSAlberto Garcia            os.remove(new_img)
43342075fdSAlberto Garcia
44342075fdSAlberto Garcia    # Check whether a BlockDriverState exists
45342075fdSAlberto Garcia    def checkBlockDriverState(self, node, must_exist = True):
46342075fdSAlberto Garcia        result = self.vm.qmp('query-named-block-nodes')
4768474776SMax Reitz        nodes = [x for x in result['return'] if x['node-name'] == node]
48342075fdSAlberto Garcia        self.assertLessEqual(len(nodes), 1)
49342075fdSAlberto Garcia        self.assertEqual(must_exist, len(nodes) == 1)
50342075fdSAlberto Garcia
51342075fdSAlberto Garcia    # Add a BlockDriverState without a BlockBackend
52342075fdSAlberto Garcia    def addBlockDriverState(self, node):
53342075fdSAlberto Garcia        file_node = '%s_file' % node
54342075fdSAlberto Garcia        self.checkBlockDriverState(node, False)
55342075fdSAlberto Garcia        self.checkBlockDriverState(file_node, False)
56342075fdSAlberto Garcia        opts = {'driver': iotests.imgfmt,
57342075fdSAlberto Garcia                'node-name': node,
58342075fdSAlberto Garcia                'file': {'driver': 'file',
59342075fdSAlberto Garcia                         'node-name': file_node,
60342075fdSAlberto Garcia                         'filename': base_img}}
610153d2f5SKevin Wolf        result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
62342075fdSAlberto Garcia        self.assert_qmp(result, 'return', {})
63342075fdSAlberto Garcia        self.checkBlockDriverState(node)
64342075fdSAlberto Garcia        self.checkBlockDriverState(file_node)
65342075fdSAlberto Garcia
66342075fdSAlberto Garcia    # Add a BlockDriverState that will be used as overlay for the base_img BDS
67342075fdSAlberto Garcia    def addBlockDriverStateOverlay(self, node):
68342075fdSAlberto Garcia        self.checkBlockDriverState(node, False)
696e6e55f5SJohn Snow        iotests.qemu_img('create', '-u', '-f', iotests.imgfmt,
70b66ff2c2SEric Blake                         '-b', base_img, '-F', iotests.imgfmt, new_img, '1M')
71342075fdSAlberto Garcia        opts = {'driver': iotests.imgfmt,
72342075fdSAlberto Garcia                'node-name': node,
73c42e8742SMarkus Armbruster                'backing': None,
74342075fdSAlberto Garcia                'file': {'driver': 'file',
75342075fdSAlberto Garcia                         'filename': new_img}}
760153d2f5SKevin Wolf        result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
77342075fdSAlberto Garcia        self.assert_qmp(result, 'return', {})
78342075fdSAlberto Garcia        self.checkBlockDriverState(node)
79342075fdSAlberto Garcia
80342075fdSAlberto Garcia    # Delete a BlockDriverState
81342075fdSAlberto Garcia    def delBlockDriverState(self, node, expect_error = False):
82342075fdSAlberto Garcia        self.checkBlockDriverState(node)
8379b7a77eSMarkus Armbruster        result = self.vm.qmp('blockdev-del', node_name = node)
84342075fdSAlberto Garcia        if expect_error:
85342075fdSAlberto Garcia            self.assert_qmp(result, 'error/class', 'GenericError')
86342075fdSAlberto Garcia        else:
87342075fdSAlberto Garcia            self.assert_qmp(result, 'return', {})
88342075fdSAlberto Garcia        self.checkBlockDriverState(node, expect_error)
89342075fdSAlberto Garcia
90342075fdSAlberto Garcia    # Add a device model
91*22329f0dSLaurent Vivier    def addDeviceModel(self, device, backend, driver = 'virtio-blk'):
92342075fdSAlberto Garcia        result = self.vm.qmp('device_add', id = device,
9362acae8aSKevin Wolf                             driver = driver, drive = backend)
94342075fdSAlberto Garcia        self.assert_qmp(result, 'return', {})
95342075fdSAlberto Garcia
96342075fdSAlberto Garcia    # Delete a device model
9762acae8aSKevin Wolf    def delDeviceModel(self, device, is_virtio_blk = True):
98342075fdSAlberto Garcia        result = self.vm.qmp('device_del', id = device)
99342075fdSAlberto Garcia        self.assert_qmp(result, 'return', {})
100342075fdSAlberto Garcia
101342075fdSAlberto Garcia        result = self.vm.qmp('system_reset')
102342075fdSAlberto Garcia        self.assert_qmp(result, 'return', {})
103342075fdSAlberto Garcia
10462acae8aSKevin Wolf        if is_virtio_blk:
105342075fdSAlberto Garcia            device_path = '/machine/peripheral/%s/virtio-backend' % device
106342075fdSAlberto Garcia            event = self.vm.event_wait(name="DEVICE_DELETED",
107342075fdSAlberto Garcia                                       match={'data': {'path': device_path}})
108342075fdSAlberto Garcia            self.assertNotEqual(event, None)
109342075fdSAlberto Garcia
110342075fdSAlberto Garcia        event = self.vm.event_wait(name="DEVICE_DELETED",
111342075fdSAlberto Garcia                                   match={'data': {'device': device}})
112342075fdSAlberto Garcia        self.assertNotEqual(event, None)
113342075fdSAlberto Garcia
114342075fdSAlberto Garcia    # Remove a BlockDriverState
11562acae8aSKevin Wolf    def ejectDrive(self, device, node, expect_error = False,
116342075fdSAlberto Garcia                   destroys_media = True):
117342075fdSAlberto Garcia        self.checkBlockDriverState(node)
11862acae8aSKevin Wolf        result = self.vm.qmp('eject', id = device)
119342075fdSAlberto Garcia        if expect_error:
120342075fdSAlberto Garcia            self.assert_qmp(result, 'error/class', 'GenericError')
121342075fdSAlberto Garcia            self.checkBlockDriverState(node)
122342075fdSAlberto Garcia        else:
123342075fdSAlberto Garcia            self.assert_qmp(result, 'return', {})
124342075fdSAlberto Garcia            self.checkBlockDriverState(node, not destroys_media)
125342075fdSAlberto Garcia
126342075fdSAlberto Garcia    # Insert a BlockDriverState
12762acae8aSKevin Wolf    def insertDrive(self, device, node):
128342075fdSAlberto Garcia        self.checkBlockDriverState(node)
12934ce1111SMax Reitz        result = self.vm.qmp('blockdev-insert-medium',
13062acae8aSKevin Wolf                             id = device, node_name = node)
131342075fdSAlberto Garcia        self.assert_qmp(result, 'return', {})
132342075fdSAlberto Garcia        self.checkBlockDriverState(node)
133342075fdSAlberto Garcia
134342075fdSAlberto Garcia    # Create a snapshot using 'blockdev-snapshot-sync'
135342075fdSAlberto Garcia    def createSnapshotSync(self, node, overlay):
136342075fdSAlberto Garcia        self.checkBlockDriverState(node)
137342075fdSAlberto Garcia        self.checkBlockDriverState(overlay, False)
138342075fdSAlberto Garcia        opts = {'node-name': node,
139342075fdSAlberto Garcia                'snapshot-file': new_img,
140342075fdSAlberto Garcia                'snapshot-node-name': overlay,
141342075fdSAlberto Garcia                'format': iotests.imgfmt}
142342075fdSAlberto Garcia        result = self.vm.qmp('blockdev-snapshot-sync', conv_keys=False, **opts)
143342075fdSAlberto Garcia        self.assert_qmp(result, 'return', {})
144342075fdSAlberto Garcia        self.checkBlockDriverState(node)
145342075fdSAlberto Garcia        self.checkBlockDriverState(overlay)
146342075fdSAlberto Garcia
147342075fdSAlberto Garcia    # Create a snapshot using 'blockdev-snapshot'
148342075fdSAlberto Garcia    def createSnapshot(self, node, overlay):
149342075fdSAlberto Garcia        self.checkBlockDriverState(node)
150342075fdSAlberto Garcia        self.checkBlockDriverState(overlay)
151342075fdSAlberto Garcia        result = self.vm.qmp('blockdev-snapshot',
152342075fdSAlberto Garcia                             node = node, overlay = overlay)
153342075fdSAlberto Garcia        self.assert_qmp(result, 'return', {})
154342075fdSAlberto Garcia        self.checkBlockDriverState(node)
155342075fdSAlberto Garcia        self.checkBlockDriverState(overlay)
156342075fdSAlberto Garcia
157342075fdSAlberto Garcia    # Create a mirror
15862acae8aSKevin Wolf    def createMirror(self, node, new_node):
159342075fdSAlberto Garcia        self.checkBlockDriverState(new_node, False)
16062acae8aSKevin Wolf        opts = {'device': node,
16162acae8aSKevin Wolf                'job-id': node,
162342075fdSAlberto Garcia                'target': new_img,
163342075fdSAlberto Garcia                'node-name': new_node,
164342075fdSAlberto Garcia                'sync': 'top',
165342075fdSAlberto Garcia                'format': iotests.imgfmt}
166342075fdSAlberto Garcia        result = self.vm.qmp('drive-mirror', conv_keys=False, **opts)
167342075fdSAlberto Garcia        self.assert_qmp(result, 'return', {})
168342075fdSAlberto Garcia        self.checkBlockDriverState(new_node)
169342075fdSAlberto Garcia
170342075fdSAlberto Garcia    # Complete an existing block job
17162acae8aSKevin Wolf    def completeBlockJob(self, id, node_before, node_after):
17262acae8aSKevin Wolf        result = self.vm.qmp('block-job-complete', device=id)
173342075fdSAlberto Garcia        self.assert_qmp(result, 'return', {})
17462acae8aSKevin Wolf        self.wait_until_completed(id)
175342075fdSAlberto Garcia
176342075fdSAlberto Garcia    # Add a BlkDebug node
17779b7a77eSMarkus Armbruster    # Note that the purpose of this is to test the blockdev-del
178342075fdSAlberto Garcia    # sanity checks, not to create a usable blkdebug drive
179342075fdSAlberto Garcia    def addBlkDebug(self, debug, node):
180342075fdSAlberto Garcia        self.checkBlockDriverState(node, False)
181342075fdSAlberto Garcia        self.checkBlockDriverState(debug, False)
182342075fdSAlberto Garcia        image = {'driver': iotests.imgfmt,
183342075fdSAlberto Garcia                 'node-name': node,
184342075fdSAlberto Garcia                 'file': {'driver': 'file',
185342075fdSAlberto Garcia                          'filename': base_img}}
186342075fdSAlberto Garcia        opts = {'driver': 'blkdebug',
187342075fdSAlberto Garcia                'node-name': debug,
188342075fdSAlberto Garcia                'image': image}
1890153d2f5SKevin Wolf        result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
190342075fdSAlberto Garcia        self.assert_qmp(result, 'return', {})
191342075fdSAlberto Garcia        self.checkBlockDriverState(node)
192342075fdSAlberto Garcia        self.checkBlockDriverState(debug)
193342075fdSAlberto Garcia
194342075fdSAlberto Garcia    # Add a BlkVerify node
19579b7a77eSMarkus Armbruster    # Note that the purpose of this is to test the blockdev-del
196342075fdSAlberto Garcia    # sanity checks, not to create a usable blkverify drive
197342075fdSAlberto Garcia    def addBlkVerify(self, blkverify, test, raw):
198342075fdSAlberto Garcia        self.checkBlockDriverState(test, False)
199342075fdSAlberto Garcia        self.checkBlockDriverState(raw, False)
200342075fdSAlberto Garcia        self.checkBlockDriverState(blkverify, False)
201342075fdSAlberto Garcia        iotests.qemu_img('create', '-f', iotests.imgfmt, new_img, '1M')
202342075fdSAlberto Garcia        node_0 = {'driver': iotests.imgfmt,
203342075fdSAlberto Garcia                  'node-name': test,
204342075fdSAlberto Garcia                  'file': {'driver': 'file',
205342075fdSAlberto Garcia                           'filename': base_img}}
206342075fdSAlberto Garcia        node_1 = {'driver': iotests.imgfmt,
207342075fdSAlberto Garcia                  'node-name': raw,
208342075fdSAlberto Garcia                  'file': {'driver': 'file',
209342075fdSAlberto Garcia                           'filename': new_img}}
210342075fdSAlberto Garcia        opts = {'driver': 'blkverify',
211342075fdSAlberto Garcia                'node-name': blkverify,
212342075fdSAlberto Garcia                'test': node_0,
213342075fdSAlberto Garcia                'raw': node_1}
2140153d2f5SKevin Wolf        result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
215342075fdSAlberto Garcia        self.assert_qmp(result, 'return', {})
216342075fdSAlberto Garcia        self.checkBlockDriverState(test)
217342075fdSAlberto Garcia        self.checkBlockDriverState(raw)
218342075fdSAlberto Garcia        self.checkBlockDriverState(blkverify)
219342075fdSAlberto Garcia
220342075fdSAlberto Garcia    # Add a Quorum node
221342075fdSAlberto Garcia    def addQuorum(self, quorum, child0, child1):
222342075fdSAlberto Garcia        self.checkBlockDriverState(child0, False)
223342075fdSAlberto Garcia        self.checkBlockDriverState(child1, False)
224342075fdSAlberto Garcia        self.checkBlockDriverState(quorum, False)
225342075fdSAlberto Garcia        iotests.qemu_img('create', '-f', iotests.imgfmt, new_img, '1M')
226342075fdSAlberto Garcia        child_0 = {'driver': iotests.imgfmt,
227342075fdSAlberto Garcia                   'node-name': child0,
228342075fdSAlberto Garcia                   'file': {'driver': 'file',
229342075fdSAlberto Garcia                            'filename': base_img}}
230342075fdSAlberto Garcia        child_1 = {'driver': iotests.imgfmt,
231342075fdSAlberto Garcia                   'node-name': child1,
232342075fdSAlberto Garcia                   'file': {'driver': 'file',
233342075fdSAlberto Garcia                            'filename': new_img}}
234342075fdSAlberto Garcia        opts = {'driver': 'quorum',
235342075fdSAlberto Garcia                'node-name': quorum,
236342075fdSAlberto Garcia                'vote-threshold': 1,
237342075fdSAlberto Garcia                'children': [ child_0, child_1 ]}
2380153d2f5SKevin Wolf        result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
239342075fdSAlberto Garcia        self.assert_qmp(result, 'return', {})
240342075fdSAlberto Garcia        self.checkBlockDriverState(child0)
241342075fdSAlberto Garcia        self.checkBlockDriverState(child1)
242342075fdSAlberto Garcia        self.checkBlockDriverState(quorum)
243342075fdSAlberto Garcia
244342075fdSAlberto Garcia    ########################
245342075fdSAlberto Garcia    # The tests start here #
246342075fdSAlberto Garcia    ########################
247342075fdSAlberto Garcia
248342075fdSAlberto Garcia    def testBlockDriverState(self):
249342075fdSAlberto Garcia        self.addBlockDriverState('node0')
250342075fdSAlberto Garcia        # You cannot delete a file BDS directly
251342075fdSAlberto Garcia        self.delBlockDriverState('node0_file', expect_error = True)
252342075fdSAlberto Garcia        self.delBlockDriverState('node0')
253342075fdSAlberto Garcia
254342075fdSAlberto Garcia    def testDeviceModel(self):
25562acae8aSKevin Wolf        self.addBlockDriverState('node0')
25662acae8aSKevin Wolf        self.addDeviceModel('device0', 'node0')
25762acae8aSKevin Wolf        self.ejectDrive('device0', 'node0', expect_error = True)
25862acae8aSKevin Wolf        self.delBlockDriverState('node0', expect_error = True)
259342075fdSAlberto Garcia        self.delDeviceModel('device0')
26062acae8aSKevin Wolf        self.delBlockDriverState('node0')
261342075fdSAlberto Garcia
262342075fdSAlberto Garcia    def testAttachMedia(self):
263342075fdSAlberto Garcia        # This creates a BlockBackend and removes its media
26462acae8aSKevin Wolf        self.addBlockDriverState('node0')
26562acae8aSKevin Wolf        self.addDeviceModel('device0', 'node0', 'scsi-cd')
26662acae8aSKevin Wolf        self.ejectDrive('device0', 'node0', destroys_media = False)
26762acae8aSKevin Wolf        self.delBlockDriverState('node0')
26862acae8aSKevin Wolf
26962acae8aSKevin Wolf        # This creates a new BlockDriverState and inserts it into the device
270342075fdSAlberto Garcia        self.addBlockDriverState('node1')
27162acae8aSKevin Wolf        self.insertDrive('device0', 'node1')
27262acae8aSKevin Wolf        # The node can't be removed: the new device has an extra reference
273342075fdSAlberto Garcia        self.delBlockDriverState('node1', expect_error = True)
274342075fdSAlberto Garcia        # The BDS still exists after being ejected, but now it can be removed
27562acae8aSKevin Wolf        self.ejectDrive('device0', 'node1', destroys_media = False)
276342075fdSAlberto Garcia        self.delBlockDriverState('node1')
27762acae8aSKevin Wolf        self.delDeviceModel('device0', False)
278342075fdSAlberto Garcia
279342075fdSAlberto Garcia    def testSnapshotSync(self):
28062acae8aSKevin Wolf        self.addBlockDriverState('node0')
28162acae8aSKevin Wolf        self.addDeviceModel('device0', 'node0')
282342075fdSAlberto Garcia        self.createSnapshotSync('node0', 'overlay0')
283342075fdSAlberto Garcia        # This fails because node0 is now being used as a backing image
284342075fdSAlberto Garcia        self.delBlockDriverState('node0', expect_error = True)
28562acae8aSKevin Wolf        self.delBlockDriverState('overlay0', expect_error = True)
28662acae8aSKevin Wolf        # This succeeds because device0 only has the backend reference
28762acae8aSKevin Wolf        self.delDeviceModel('device0')
28862acae8aSKevin Wolf        # FIXME Would still be there if blockdev-snapshot-sync took a ref
28962acae8aSKevin Wolf        self.checkBlockDriverState('overlay0', False)
29062acae8aSKevin Wolf        self.delBlockDriverState('node0')
291342075fdSAlberto Garcia
292342075fdSAlberto Garcia    def testSnapshot(self):
29362acae8aSKevin Wolf        self.addBlockDriverState('node0')
29462acae8aSKevin Wolf        self.addDeviceModel('device0', 'node0', 'scsi-cd')
295342075fdSAlberto Garcia        self.addBlockDriverStateOverlay('overlay0')
296342075fdSAlberto Garcia        self.createSnapshot('node0', 'overlay0')
297342075fdSAlberto Garcia        self.delBlockDriverState('node0', expect_error = True)
298342075fdSAlberto Garcia        self.delBlockDriverState('overlay0', expect_error = True)
29962acae8aSKevin Wolf        self.ejectDrive('device0', 'overlay0', destroys_media = False)
300342075fdSAlberto Garcia        self.delBlockDriverState('node0', expect_error = True)
301342075fdSAlberto Garcia        self.delBlockDriverState('overlay0')
30262acae8aSKevin Wolf        self.delBlockDriverState('node0')
303342075fdSAlberto Garcia
304342075fdSAlberto Garcia    def testMirror(self):
30562acae8aSKevin Wolf        self.addBlockDriverState('node0')
30662acae8aSKevin Wolf        self.addDeviceModel('device0', 'node0', 'scsi-cd')
30762acae8aSKevin Wolf        self.createMirror('node0', 'mirror0')
308342075fdSAlberto Garcia        # The block job prevents removing the device
309342075fdSAlberto Garcia        self.delBlockDriverState('node0', expect_error = True)
310342075fdSAlberto Garcia        self.delBlockDriverState('mirror0', expect_error = True)
31162acae8aSKevin Wolf        self.wait_ready('node0')
31262acae8aSKevin Wolf        self.completeBlockJob('node0', 'node0', 'mirror0')
313342075fdSAlberto Garcia        self.assert_no_active_block_jobs()
31462acae8aSKevin Wolf        # This succeeds because the device now points to mirror0
31562acae8aSKevin Wolf        self.delBlockDriverState('node0')
31662acae8aSKevin Wolf        self.delBlockDriverState('mirror0', expect_error = True)
31762acae8aSKevin Wolf        self.delDeviceModel('device0', False)
31862acae8aSKevin Wolf        # FIXME mirror0 disappears, drive-mirror doesn't take a reference
31962acae8aSKevin Wolf        #self.delBlockDriverState('mirror0')
320342075fdSAlberto Garcia
321d9df28e7SAndrey Shinkevich    @iotests.skip_if_unsupported(['blkdebug'])
322342075fdSAlberto Garcia    def testBlkDebug(self):
323342075fdSAlberto Garcia        self.addBlkDebug('debug0', 'node0')
324342075fdSAlberto Garcia        # 'node0' is used by the blkdebug node
325342075fdSAlberto Garcia        self.delBlockDriverState('node0', expect_error = True)
326342075fdSAlberto Garcia        # But we can remove the blkdebug node directly
327342075fdSAlberto Garcia        self.delBlockDriverState('debug0')
328342075fdSAlberto Garcia        self.checkBlockDriverState('node0', False)
329342075fdSAlberto Garcia
330d9df28e7SAndrey Shinkevich    @iotests.skip_if_unsupported(['blkverify'])
331342075fdSAlberto Garcia    def testBlkVerify(self):
332342075fdSAlberto Garcia        self.addBlkVerify('verify0', 'node0', 'node1')
333342075fdSAlberto Garcia        # We cannot remove the children of a blkverify device
334342075fdSAlberto Garcia        self.delBlockDriverState('node0', expect_error = True)
335342075fdSAlberto Garcia        self.delBlockDriverState('node1', expect_error = True)
336342075fdSAlberto Garcia        # But we can remove the blkverify node directly
337342075fdSAlberto Garcia        self.delBlockDriverState('verify0')
338342075fdSAlberto Garcia        self.checkBlockDriverState('node0', False)
339342075fdSAlberto Garcia        self.checkBlockDriverState('node1', False)
340342075fdSAlberto Garcia
341d9df28e7SAndrey Shinkevich    @iotests.skip_if_unsupported(['quorum'])
342342075fdSAlberto Garcia    def testQuorum(self):
343342075fdSAlberto Garcia        self.addQuorum('quorum0', 'node0', 'node1')
344342075fdSAlberto Garcia        # We cannot remove the children of a Quorum device
345342075fdSAlberto Garcia        self.delBlockDriverState('node0', expect_error = True)
346342075fdSAlberto Garcia        self.delBlockDriverState('node1', expect_error = True)
347342075fdSAlberto Garcia        # But we can remove the Quorum node directly
348342075fdSAlberto Garcia        self.delBlockDriverState('quorum0')
349342075fdSAlberto Garcia        self.checkBlockDriverState('node0', False)
350342075fdSAlberto Garcia        self.checkBlockDriverState('node1', False)
351342075fdSAlberto Garcia
352342075fdSAlberto Garcia
353342075fdSAlberto Garciaif __name__ == '__main__':
354103cbc77SMax Reitz    iotests.main(supported_fmts=["qcow2"],
355103cbc77SMax Reitz                 supported_protocols=["file"])
356