Skip to content

Commit

Permalink
block: forbid x-blockdev-del from acting on DriveInfo
Browse files Browse the repository at this point in the history
Failing on -drive/drive_add created BlockBackends was a
requirement for x-blockdev-del, but it sneaked through
the patch review.  Let's fix it now.

Example:

$ x86_64-softmmu/qemu-system-x86_64 -drive if=none,file=null-co://,id=null -qmp stdio
>> {'execute':'qmp_capabilities'}
<< {"return": {}}
>> {'execute':'x-blockdev-del','arguments':{'id':'null'}}
<< {"error": {"class": "GenericError", "desc": "Deleting block backend added with drive-add is not supported"}}

And without a DriveInfo:

>> { "execute": "blockdev-add", "arguments": { "options": { "driver":"null-co", "id":"null2"}}}
<< {"return": {}}
>> {'execute':'x-blockdev-del','arguments':{'id':'null2'}}
<< {"return": {}}

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
bonzini authored and kevmw committed Apr 5, 2016
1 parent 2e3a76a commit 5cf87fd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions blockdev.c
Expand Up @@ -4027,6 +4027,11 @@ void qmp_x_blockdev_del(bool has_id, const char *id,
error_setg(errp, "Cannot find block backend %s", id);
return;
}
if (blk_legacy_dinfo(blk)) {
error_setg(errp, "Deleting block backend added with drive-add"
" is not supported");
return;
}
if (blk_get_refcnt(blk) > 1) {
error_setg(errp, "Block backend %s is in use", id);
return;
Expand Down

0 comments on commit 5cf87fd

Please sign in to comment.