block: Add 'x-blockdev-del' QMP command

This command is still experimental, hence the name.

This is the companion to 'blockdev-add'. It allows deleting a
BlockBackend with its associated BlockDriverState tree, or a
BlockDriverState that is not attached to any backend.

In either case, the command fails if the reference count is greater
than 1 or the BlockDriverState has any parents.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 6cfc148c77aca1da942b094d811bfa3fcf7ac7bb.1446475331.git.berto@igalia.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Alberto Garcia
2015-11-02 16:51:55 +02:00
committed by Max Reitz
parent f636ae85f3
commit 81b936ae70
3 changed files with 155 additions and 4 deletions

View File

@@ -3946,8 +3946,8 @@ blockdev-add
Add a block device.
This command is still a work in progress. It doesn't support all
block drivers, it lacks a matching blockdev-del, and more. Stay away
from it unless you want to help with its development.
block drivers among other things. Stay away from it unless you want
to help with its development.
Arguments:
@@ -3990,6 +3990,63 @@ Example (2):
<- { "return": {} }
EQMP
{
.name = "x-blockdev-del",
.args_type = "id:s?,node-name:s?",
.mhandler.cmd_new = qmp_marshal_x_blockdev_del,
},
SQMP
x-blockdev-del
------------
Since 2.5
Deletes a block device thas has been added using blockdev-add.
The selected device can be either a block backend or a graph node.
In the former case the backend will be destroyed, along with its
inserted medium if there's any. The command will fail if the backend
or its medium are in use.
In the latter case the node will be destroyed. The command will fail
if the node is attached to a block backend or is otherwise being
used.
One of "id" or "node-name" must be specified, but not both.
This command is still a work in progress and is considered
experimental. Stay away from it unless you want to help with its
development.
Arguments:
- "id": Name of the block backend device to delete (json-string, optional)
- "node-name": Name of the graph node to delete (json-string, optional)
Example:
-> { "execute": "blockdev-add",
"arguments": {
"options": {
"driver": "qcow2",
"id": "drive0",
"file": {
"driver": "file",
"filename": "test.qcow2"
}
}
}
}
<- { "return": {} }
-> { "execute": "x-blockdev-del",
"arguments": { "id": "drive0" }
}
<- { "return": {} }
EQMP
{