Skip to contentSkip to conversation

block: forbid x-blockdev-del from acting on DriveInfo

PATCH Applied Paolo Bonzini 2 participants 2 messages Mar 31, 2016 – Apr 4, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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
Quoted 1 line
Quoted 1 line

{'execute':'qmp_capabilities'}

<< {"return": {}}

Quoted 1 line
Quoted 1 line

{'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:

Quoted 1 line
Quoted 1 line

{ "execute": "blockdev-add", "arguments": { "options": { "driver":"null-co", "id":"null2"}}}

<< {"return": {}}

Quoted 1 line
Quoted 1 line

{'execute':'x-blockdev-del','arguments':{'id':'null2'}}

<< {"return": {}}

---
 blockdev.c | 5 +++++
 1 file changed, 5 insertions(+)
blockdev.c +5 -0
index e50e8ea..332068a 100644
@@ -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;
Signature · 1 line
2.5.5
Applied
#1 lore raw

Am 31.03.2016 um 15:07 hat Paolo Bonzini geschrieben:

Quoted 14 lines

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
Quoted 1 line
Quoted 1 line

{'execute':'qmp_capabilities'}

<< {"return": {}}

Quoted 1 line
Quoted 1 line

{'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:

Quoted 7 lines
Quoted 1 line
Quoted 1 line

{ "execute": "blockdev-add", "arguments": { "options": { "driver":"null-co", "id":"null2"}}}

<< {"return": {}}

Quoted 1 line
Quoted 1 line

{'execute':'x-blockdev-del','arguments':{'id':'null2'}}

<< {"return": {}}

Thanks, applied to the block branch.

Kevin