aboutsummaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-03-13 14:44:28 +0000
committerPeter Maydell <peter.maydell@linaro.org>2019-03-13 14:44:28 +0000
commit36fe7709664579c934f014f21e5610d69e5b298f (patch)
treed49a305977e4490bf20b1fc4866cbf22b667c56b /blockdev.c
parentf39901d59f38a32323055764b859c224c09d85b2 (diff)
parentbf3e50f6239090e63a8ffaaec971671e66d88e07 (diff)
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches: - file-posix: Make auto-read-only dynamic - Add x-blockdev-reopen QMP command - Finalize block-latency-histogram QMP command - gluster: Build fixes for newer lib version # gpg: Signature made Tue 12 Mar 2019 19:30:31 GMT # gpg: using RSA key 7F09B272C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full] # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: (28 commits) qemu-iotests: Test the x-blockdev-reopen QMP command block: Add an 'x-blockdev-reopen' QMP command block: Remove the AioContext parameter from bdrv_reopen_multiple() block: Add bdrv_reset_options_allowed() block: Add a 'mutable_opts' field to BlockDriver block: Allow changing the backing file on reopen block: Allow omitting the 'backing' option in certain cases block: Handle child references in bdrv_reopen_queue() block: Add 'keep_old_opts' parameter to bdrv_reopen_queue() block: Freeze the backing chain for the duration of the stream job block: Freeze the backing chain for the duration of the mirror job block: Freeze the backing chain for the duration of the commit job block: Allow freezing BdrvChild links nvme: fix write zeroes offset and count file-posix: Make auto-read-only dynamic file-posix: Prepare permission code for fd switching file-posix: Lock new fd in raw_reopen_prepare() file-posix: Store BDRVRawState.reopen_state during reopen file-posix: Factor out raw_reconfigure_getfd() file-posix: Fix bdrv_open_flags() for snapshot=on ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c61
1 files changed, 54 insertions, 7 deletions
diff --git a/blockdev.c b/blockdev.c
index 871966ca13..3cc51b2ee7 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -4287,6 +4287,53 @@ fail:
visit_free(v);
}
+void qmp_x_blockdev_reopen(BlockdevOptions *options, Error **errp)
+{
+ BlockDriverState *bs;
+ AioContext *ctx;
+ QObject *obj;
+ Visitor *v = qobject_output_visitor_new(&obj);
+ Error *local_err = NULL;
+ BlockReopenQueue *queue;
+ QDict *qdict;
+
+ /* Check for the selected node name */
+ if (!options->has_node_name) {
+ error_setg(errp, "Node name not specified");
+ goto fail;
+ }
+
+ bs = bdrv_find_node(options->node_name);
+ if (!bs) {
+ error_setg(errp, "Cannot find node named '%s'", options->node_name);
+ goto fail;
+ }
+
+ /* Put all options in a QDict and flatten it */
+ visit_type_BlockdevOptions(v, NULL, &options, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ goto fail;
+ }
+
+ visit_complete(v, &obj);
+ qdict = qobject_to(QDict, obj);
+
+ qdict_flatten(qdict);
+
+ /* Perform the reopen operation */
+ ctx = bdrv_get_aio_context(bs);
+ aio_context_acquire(ctx);
+ bdrv_subtree_drained_begin(bs);
+ queue = bdrv_reopen_queue(NULL, bs, qdict, false);
+ bdrv_reopen_multiple(queue, errp);
+ bdrv_subtree_drained_end(bs);
+ aio_context_release(ctx);
+
+fail:
+ visit_free(v);
+}
+
void qmp_blockdev_del(const char *node_name, Error **errp)
{
AioContext *aio_context;
@@ -4452,22 +4499,22 @@ void qmp_x_blockdev_set_iothread(const char *node_name, StrOrNull *iothread,
aio_context_release(old_context);
}
-void qmp_x_block_latency_histogram_set(
- const char *device,
+void qmp_block_latency_histogram_set(
+ const char *id,
bool has_boundaries, uint64List *boundaries,
bool has_boundaries_read, uint64List *boundaries_read,
bool has_boundaries_write, uint64List *boundaries_write,
bool has_boundaries_flush, uint64List *boundaries_flush,
Error **errp)
{
- BlockBackend *blk = blk_by_name(device);
+ BlockBackend *blk = qmp_get_blk(NULL, id, errp);
BlockAcctStats *stats;
int ret;
if (!blk) {
- error_setg(errp, "Device '%s' not found", device);
return;
}
+
stats = blk_get_stats(blk);
if (!has_boundaries && !has_boundaries_read && !has_boundaries_write &&
@@ -4482,7 +4529,7 @@ void qmp_x_block_latency_histogram_set(
stats, BLOCK_ACCT_READ,
has_boundaries_read ? boundaries_read : boundaries);
if (ret) {
- error_setg(errp, "Device '%s' set read boundaries fail", device);
+ error_setg(errp, "Device '%s' set read boundaries fail", id);
return;
}
}
@@ -4492,7 +4539,7 @@ void qmp_x_block_latency_histogram_set(
stats, BLOCK_ACCT_WRITE,
has_boundaries_write ? boundaries_write : boundaries);
if (ret) {
- error_setg(errp, "Device '%s' set write boundaries fail", device);
+ error_setg(errp, "Device '%s' set write boundaries fail", id);
return;
}
}
@@ -4502,7 +4549,7 @@ void qmp_x_block_latency_histogram_set(
stats, BLOCK_ACCT_FLUSH,
has_boundaries_flush ? boundaries_flush : boundaries);
if (ret) {
- error_setg(errp, "Device '%s' set flush boundaries fail", device);
+ error_setg(errp, "Device '%s' set flush boundaries fail", id);
return;
}
}