]> git.proxmox.com Git - mirror_qemu.git/commit - blockdev.c
blockdev: Refuse to drive_del something added with blockdev-add
authorMarkus Armbruster <armbru@redhat.com>
Thu, 11 Sep 2014 14:45:39 +0000 (16:45 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 11 Sep 2014 15:14:24 +0000 (17:14 +0200)
commit48f364dd0ba8d6323ee9ac2b35996eef667bac39
tree55453f953fcb28aacc67e5504876472372fa1ee3
parent624ff5736ef9245bb8070400ccaf65857b6d1c38
blockdev: Refuse to drive_del something added with blockdev-add

For some device models, the guest can prevent unplug.  Some users need a
way to forcibly revoke device model access to the block backend then, so
the underlying images can be safely used for something else.

drive_del lets you do that.  Unfortunately, it conflates revoking access
with destroying the backend.

Commit 9063f81 made drive_del immediately destroy the root BDS.  Nice:
the device name becomes available for reuse immediately.  Not so nice:
the device model's pointer to the root BDS dangles, and we're prone to
crash when the memory gets reused.

Commit d22b2f4 fixed that by hiding the root BDS instead of destroying
it.  Destruction only happens on unplug.  "Hiding" means removing it
from bdrv_states and graph_bdrv_states; see bdrv_make_anon().

This "destroy on revoke" is a misfeature we don't want to carry
forward to blockdev-add, just like "destroy on unplug" (commit
2d246f0).  So make drive_del fail on anything added with blockdev-add.

We'll add separate QMP commands to revoke device model access and to
destroy backends.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blockdev.c