From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlzxg-0007cl-Pq for qemu-devel@nongnu.org; Tue, 13 Oct 2015 09:49:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zlzxd-0004of-89 for qemu-devel@nongnu.org; Tue, 13 Oct 2015 09:49:52 -0400 From: Alberto Garcia Date: Tue, 13 Oct 2015 16:48:49 +0300 Message-Id: Subject: [Qemu-devel] [PATCH 0/3] Add 'blockdev-del' command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Stefan Hajnoczi 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