Here's my first attempt at the 'blockdev-del' command. This series goes on top of Max's "BlockBackend and media" v6:
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg02810.html With Max's code, 'blockdev-add' can now create a BlockDriverState with or without a BlockBackend (depending on whether the 'id' parameter is passed). Therefore, 'blockdev-del' can be used to delete a backend and/or a BDS. The way it works is simple: it receives a single 'device' parameter which can refer to a block backend or a node name. - If it's a block backend, it will delete it along with its attached BDS (if any). - If it's a node name, it will delete the BDS along with the backend it is attached to (if any). - If you're wondering whether it's possible to delete the BDS but not the backend it is attached to, there is already eject or blockdev-remove-medium for that. If either the backend or the BDS are being used (refcount > 1, or if the BDS has any parents) the command fails. The series includes bunch of test cases with different scenarios (nodes with and without backend, empty backend, backing images, block jobs, Quorum). Regards, Berto Alberto Garcia (3): block: Add blk_get_refcnt() block: Add 'blockdev-del' QMP command iotests: Add test for the blockdev-del command block/block-backend.c | 5 ++ blockdev.c | 42 +++++++++ include/sysemu/block-backend.h | 1 + qapi/block-core.json | 21 +++++ qmp-commands.hx | 36 ++++++++ tests/qemu-iotests/139 | 189 +++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/139.out | 5 ++ tests/qemu-iotests/group | 1 + 8 files changed, 300 insertions(+) create mode 100644 tests/qemu-iotests/139 create mode 100644 tests/qemu-iotests/139.out -- 2.6.1