[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 09/37] hmp: Allow using a qdev id in block_set_io_thr
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 09/37] hmp: Allow using a qdev id in block_set_io_throttle |
Date: |
Tue, 15 May 2018 17:40:05 +0200 |
From: Alberto Garcia <address@hidden>
The QMP version of this command can take a qdev ID since 7a9877a02635,
but the HMP version is still using the deprecated block device name so
there's no way to refer to a block device added like this:
-blockdev node-name=disk0,driver=qcow2,file.driver=file,file.filename=hd.qcow2
-device virtio-blk-pci,id=virtio-blk-pci0,drive=disk0
This patch works around this problem by using the specified name as a
qdev ID if the block device name is not found.
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
hmp.c | 14 ++++++++++++--
hmp-commands.hx | 3 ++-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/hmp.c b/hmp.c
index 898e25f3e1..bdb340605c 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1789,9 +1789,8 @@ void hmp_change(Monitor *mon, const QDict *qdict)
void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
+ char *device = (char *) qdict_get_str(qdict, "device");
BlockIOThrottle throttle = {
- .has_device = true,
- .device = (char *) qdict_get_str(qdict, "device"),
.bps = qdict_get_int(qdict, "bps"),
.bps_rd = qdict_get_int(qdict, "bps_rd"),
.bps_wr = qdict_get_int(qdict, "bps_wr"),
@@ -1800,6 +1799,17 @@ void hmp_block_set_io_throttle(Monitor *mon, const QDict
*qdict)
.iops_wr = qdict_get_int(qdict, "iops_wr"),
};
+ /* qmp_block_set_io_throttle has separate parameters for the
+ * (deprecated) block device name and the qdev ID but the HMP
+ * version has only one, so we must decide which one to pass. */
+ if (blk_by_name(device)) {
+ throttle.has_device = true;
+ throttle.device = device;
+ } else {
+ throttle.has_id = true;
+ throttle.id = device;
+ }
+
qmp_block_set_io_throttle(&throttle, &err);
hmp_handle_error(mon, &err);
}
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 35d862a5d2..227f7eee88 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1647,7 +1647,8 @@ ETEXI
STEXI
@item block_set_io_throttle @var{device} @var{bps} @var{bps_rd} @var{bps_wr}
@var{iops} @var{iops_rd} @var{iops_wr}
@findex block_set_io_throttle
-Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd}
@var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr}
+Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd}
@var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr}.
address@hidden can be a block device name, a qdev ID or a QOM path.
ETEXI
{
--
2.13.6
- [Qemu-block] [PULL 00/37] Block layer patches, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 04/37] null: Switch to byte-based read/write, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 03/37] file-win32: Switch to byte-based callbacks, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 02/37] block: Support byte-based aio callbacks, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 05/37] rbd: Switch to byte-based callbacks, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 06/37] vxhs: Switch to byte-based callbacks, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 07/37] block: Drop last of the sector-based aio callbacks, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 08/37] block: Merge .bdrv_co_writev{, _flags} in drivers, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 09/37] hmp: Allow using a qdev id in block_set_io_throttle,
Kevin Wolf <=
- [Qemu-block] [PULL 01/37] block-backend: simplify blk_get_aio_context, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 10/37] blockjob: expose error string via query, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 15/37] blockjob: Introduce block_job_ratelimit_get_delay(), Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 11/37] blockjob: Fix assertion in block_job_finalize(), Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 16/37] blockjob: Add block_job_driver(), Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 14/37] blockjob: Implement block_job_set_speed() centrally, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 19/37] specs/qcow2: Clarify that compressed clusters have the COPIED bit reset, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 13/37] blockjob: Move RateLimit to BlockJob, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 12/37] blockjob: Wrappers for progress counter access, Kevin Wolf, 2018/05/15
- [Qemu-block] [PULL 17/37] iotests: Split 214 off of 122, Kevin Wolf, 2018/05/15