From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alcKF-0003g1-QM for qemu-devel@nongnu.org; Thu, 31 Mar 2016 09:07:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1alcKA-0007f6-Rc for qemu-devel@nongnu.org; Thu, 31 Mar 2016 09:07:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alcKA-0007f1-MI for qemu-devel@nongnu.org; Thu, 31 Mar 2016 09:07:46 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 6EB6AC0005D5 for ; Thu, 31 Mar 2016 13:07:46 +0000 (UTC) From: Paolo Bonzini Date: Thu, 31 Mar 2016 15:07:43 +0200 Message-Id: <1459429663-1230-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] block: forbid x-blockdev-del from acting on DriveInfo List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, mreitz@redhat.com 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 Signed-off-by: Paolo Bonzini --- blockdev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/blockdev.c b/blockdev.c index e50e8ea..332068a 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; -- 2.5.5