[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 20/23] blockdev: add x-blockdev-set-iothread force bo
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 20/23] blockdev: add x-blockdev-set-iothread force boolean |
Date: |
Mon, 18 Dec 2017 14:35:27 +0000 |
When a node is already associated with a BlockBackend the
x-blockdev-set-iothread command refuses to set the IOThread. This is to
prevent accidentally changing the IOThread when the nodes are in use.
When the nodes are created with -drive they automatically get a
BlockBackend. In that case we know nothing is using them yet and it's
safe to set the IOThread. Add a force boolean to override the check.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
qapi/block-core.json | 6 +++++-
blockdev.c | 11 ++++++-----
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 741d6c4367..a8cdbc300b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3962,6 +3962,9 @@
#
# @iothread: the name of the IOThread object or null for the main loop
#
+# @force: true if the node and its children should be moved when a BlockBackend
+# is already attached
+#
# Note: this command is experimental and intended for test cases that need
# control over IOThreads only.
#
@@ -3984,4 +3987,5 @@
##
{ 'command': 'x-blockdev-set-iothread',
'data' : { 'node-name': 'str',
- 'iothread': 'StrOrNull' } }
+ 'iothread': 'StrOrNull',
+ '*force': 'bool' } }
diff --git a/blockdev.c b/blockdev.c
index f75c01f664..9c3a430cfb 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -4131,7 +4131,7 @@ BlockJobInfoList *qmp_query_block_jobs(Error **errp)
}
void qmp_x_blockdev_set_iothread(const char *node_name, StrOrNull *iothread,
- Error **errp)
+ bool has_force, bool force, Error **errp)
{
AioContext *old_context;
AioContext *new_context;
@@ -4143,10 +4143,11 @@ void qmp_x_blockdev_set_iothread(const char *node_name,
StrOrNull *iothread,
return;
}
- /* If we want to allow more extreme test scenarios this guard could be
- * removed. For now it protects against accidents. */
- if (bdrv_has_blk(bs)) {
- error_setg(errp, "Node %s is in use", node_name);
+ /* Protects against accidents. */
+ if (!(has_force && force) && bdrv_has_blk(bs)) {
+ error_setg(errp, "Node %s is associated with a BlockBackend and could "
+ "be in use (use force=true to override this check)",
+ node_name);
return;
}
--
2.14.3
- [Qemu-devel] [PULL 10/23] block: don't keep AioContext acquired after blockdev_backup_prepare(), (continued)
- [Qemu-devel] [PULL 10/23] block: don't keep AioContext acquired after blockdev_backup_prepare(), Stefan Hajnoczi, 2017/12/18
- [Qemu-devel] [PULL 11/23] block: don't keep AioContext acquired after internal_snapshot_prepare(), Stefan Hajnoczi, 2017/12/18
- [Qemu-devel] [PULL 12/23] block: drop unused BlockDirtyBitmapState->aio_context field, Stefan Hajnoczi, 2017/12/18
- [Qemu-devel] [PULL 13/23] iothread: add iothread_by_id() API, Stefan Hajnoczi, 2017/12/18
- [Qemu-devel] [PULL 14/23] blockdev: add x-blockdev-set-iothread testing command, Stefan Hajnoczi, 2017/12/18
- [Qemu-devel] [PULL 15/23] qemu-iotests: add 202 external snapshots IOThread test, Stefan Hajnoczi, 2017/12/18
- [Qemu-devel] [PULL 16/23] virtio-blk: make queue size configurable, Stefan Hajnoczi, 2017/12/18
- [Qemu-devel] [PULL 17/23] virtio-blk: reject configs with logical block size > physical block size, Stefan Hajnoczi, 2017/12/18
- [Qemu-devel] [PULL 18/23] block: avoid recursive AioContext acquire in bdrv_inactivate_all(), Stefan Hajnoczi, 2017/12/18
- [Qemu-devel] [PULL 19/23] docs: mark nested AioContext locking as a legacy API, Stefan Hajnoczi, 2017/12/18
- [Qemu-devel] [PULL 20/23] blockdev: add x-blockdev-set-iothread force boolean,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 21/23] iotests: add VM.add_object(), Stefan Hajnoczi, 2017/12/18
- [Qemu-devel] [PULL 22/23] iothread: fix iothread_stop() race condition, Stefan Hajnoczi, 2017/12/18
- [Qemu-devel] [PULL 23/23] qemu-iotests: add 203 savevm with IOThreads test, Stefan Hajnoczi, 2017/12/18
- Re: [Qemu-devel] [PULL 00/23] Block patches, Peter Maydell, 2017/12/18