[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/22] blockdev: Refuse to drive_del something added
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 16/22] blockdev: Refuse to drive_del something added with blockdev-add |
Date: |
Fri, 12 Sep 2014 17:57:00 +0200 |
From: Markus Armbruster <address@hidden>
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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
blockdev.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index e919566..b361fbb 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1739,6 +1739,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict,
QObject **ret_data)
{
const char *id = qdict_get_str(qdict, "id");
BlockDriverState *bs;
+ DriveInfo *dinfo;
AioContext *aio_context;
Error *local_err = NULL;
@@ -1748,6 +1749,13 @@ int do_drive_del(Monitor *mon, const QDict *qdict,
QObject **ret_data)
return -1;
}
+ dinfo = drive_get_by_blockdev(bs);
+ if (dinfo && !dinfo->enable_auto_del) {
+ error_report("Deleting device added with blockdev-add"
+ " is not supported");
+ return -1;
+ }
+
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
@@ -1775,7 +1783,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict,
QObject **ret_data)
bdrv_set_on_error(bs, BLOCKDEV_ON_ERROR_REPORT,
BLOCKDEV_ON_ERROR_REPORT);
} else {
- drive_del(drive_get_by_blockdev(bs));
+ drive_del(dinfo);
}
aio_context_release(aio_context);
--
1.8.3.1
- [Qemu-devel] [PULL 07/22] IDE: MMIO IDE device control should be little endian, (continued)
- [Qemu-devel] [PULL 07/22] IDE: MMIO IDE device control should be little endian, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 10/22] block: rename BlockAcctType members to start with BLOCK_ instead of BDRV_, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 11/22] block: Make the block accounting functions operate on BlockAcctStats, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 06/22] thread-pool: Drop unnecessary includes, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 08/22] block: Extract the BlockAcctStats structure, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 12/22] block/archipelago: Implement bdrv_truncate(), Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 13/22] qemu-iotests: Run 025 for Archipelago block driver, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 14/22] dataplane: fix virtio_blk_data_plane_create() op blocker error path, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 17/22] iotests: Send the correct fd in socket_scm_helper, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 18/22] block: round up file size to nearest sector, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 16/22] blockdev: Refuse to drive_del something added with blockdev-add,
Kevin Wolf <=
- [Qemu-devel] [PULL 19/22] block: don't convert file size to sector size, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 15/22] block: extend BLOCK_IO_ERROR with reason string, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 20/22] qapi: introduce PreallocMode and new PreallocModes full and falloc., Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 21/22] raw-posix: Add falloc and full preallocation option, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 22/22] qcow2: Add falloc and full preallocation option, Kevin Wolf, 2014/09/12
- Re: [Qemu-devel] [PULL 00/22] Block patches, Peter Maydell, 2014/09/15