diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2016-03-31 15:07:43 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2016-04-05 09:22:28 +0200 |
commit | 5cf87fd68e1ea06013594682cec6feb5488fb773 (patch) | |
tree | bfcc7bfe741eb987702bcdebd52f976cc773ad89 /blockdev.c | |
parent | 2e3a76ae3e47d502f9f0c4424b719945fba9d459 (diff) |
block: forbid x-blockdev-del from acting on DriveInfo
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>
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/blockdev.c b/blockdev.c index e50e8eabd0..332068a837 100644 --- a/blockdev.c +++ b/blockdev.c @@ -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; |