Test the QAPI interface for multi-threaded exports. None of our exports currently support multi-threading, so it's always an error in the end, but we can still test the specific errors.
Signed-off-by: Hanna Czenczek <hre...@redhat.com> --- tests/qemu-iotests/307 | 47 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/307.out | 18 +++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/tests/qemu-iotests/307 b/tests/qemu-iotests/307 index b429b5aa50..f6ee3ebec0 100755 --- a/tests/qemu-iotests/307 +++ b/tests/qemu-iotests/307 @@ -142,5 +142,52 @@ with iotests.FilePath('image') as img, \ vm.qmp_log('query-block-exports') iotests.qemu_nbd_list_log('-k', socket) + iotests.log('\n=== Using multi-thread with NBD ===') + + # Actual multi-threading; (currently) not supported by NBD + vm.qmp_log('block-export-add', + id='export0', + type='nbd', + node_name='fmt', + iothread=['iothread0', 'iothread1']) + + # Should be treated the same way as actual multi-threading, even if there's + # only a single thread + vm.qmp_log('block-export-add', + id='export0', + type='nbd', + node_name='fmt', + iothread=['iothread0']) + + iotests.log('\n=== Empty thread list') + + # Simply not allowed + vm.qmp_log('block-export-add', + id='export0', + type='nbd', + node_name='fmt', + iothread=[]) + + iotests.log('\n=== Non-existent thread name in list') + + # Expect an error, even if NBD does not support multi-threading, because the + # list is parsed before being passed to NBD + vm.qmp_log('block-export-add', + id='export0', + type='nbd', + node_name='fmt', + iothread=['iothread0', 'nothread', 'iothread1']) + + iotests.log('\n=== Multi-thread with fixed-iothread') + + # With multi-threading, there is no single context to give the BDS, so it is + # just left where it is. fixed-iothread does not make sense then. + vm.qmp_log('block-export-add', + id='export0', + type='nbd', + node_name='fmt', + iothread=['iothread0', 'iothread1'], + fixed_iothread=True) + iotests.log('\n=== Shut down QEMU ===') vm.shutdown() diff --git a/tests/qemu-iotests/307.out b/tests/qemu-iotests/307.out index f645f3315f..a9b37d3ac1 100644 --- a/tests/qemu-iotests/307.out +++ b/tests/qemu-iotests/307.out @@ -134,4 +134,22 @@ read failed: Input/output error exports available: 0 +=== Using multi-thread with NBD === +{"execute": "block-export-add", "arguments": {"id": "export0", "iothread": ["iothread0", "iothread1"], "node-name": "fmt", "type": "nbd"}} +{"error": {"class": "GenericError", "desc": "NBD export does not support multi-threading"}} +{"execute": "block-export-add", "arguments": {"id": "export0", "iothread": ["iothread0"], "node-name": "fmt", "type": "nbd"}} +{"error": {"class": "GenericError", "desc": "NBD export does not support multi-threading"}} + +=== Empty thread list +{"execute": "block-export-add", "arguments": {"id": "export0", "iothread": [], "node-name": "fmt", "type": "nbd"}} +{"error": {"class": "GenericError", "desc": "The set of I/O threads must not be empty"}} + +=== Non-existent thread name in list +{"execute": "block-export-add", "arguments": {"id": "export0", "iothread": ["iothread0", "nothread", "iothread1"], "node-name": "fmt", "type": "nbd"}} +{"error": {"class": "GenericError", "desc": "iothread \"nothread\" not found"}} + +=== Multi-thread with fixed-iothread +{"execute": "block-export-add", "arguments": {"fixed-iothread": true, "id": "export0", "iothread": ["iothread0", "iothread1"], "node-name": "fmt", "type": "nbd"}} +{"error": {"class": "GenericError", "desc": "Cannot use fixed-iothread for a multi-threaded export"}} + === Shut down QEMU === -- 2.49.0