[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 20/33] block: Accept device model name for block_set_
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 20/33] block: Accept device model name for block_set_io_throttle |
Date: |
Thu, 22 Sep 2016 18:29:21 +0200 |
In order to remove the need for BlockBackend names in the external API,
we want to allow qdev device names in all device related commands.
This converts block_set_io_throttle to accept a qdev device name.
Signed-off-by: Kevin Wolf <address@hidden>
---
blockdev.c | 12 +++++++-----
docs/qmp-commands.txt | 6 ++++--
qapi/block-core.json | 8 +++++---
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 8c8fcd6..405145a 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2647,10 +2647,10 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg,
Error **errp)
BlockBackend *blk;
AioContext *aio_context;
- blk = blk_by_name(arg->device);
+ blk = qmp_get_blk(arg->has_device ? arg->device : NULL,
+ arg->has_id ? arg->id : NULL,
+ errp);
if (!blk) {
- error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
- "Device '%s' not found", arg->device);
return;
}
@@ -2659,7 +2659,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg,
Error **errp)
bs = blk_bs(blk);
if (!bs) {
- error_setg(errp, "Device '%s' has no medium", arg->device);
+ error_setg(errp, "Device has no medium");
goto out;
}
@@ -2723,7 +2723,9 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg,
Error **errp)
* just update the throttling group. */
if (!blk_get_public(blk)->throttle_state) {
blk_io_limits_enable(blk,
- arg->has_group ? arg->group : arg->device);
+ arg->has_group ? arg->group :
+ arg->has_device ? arg->device :
+ arg->id);
} else if (arg->has_group) {
blk_io_limits_update_group(blk, arg->group);
}
diff --git a/docs/qmp-commands.txt b/docs/qmp-commands.txt
index 8b2a0ea..41f5698 100644
--- a/docs/qmp-commands.txt
+++ b/docs/qmp-commands.txt
@@ -1459,7 +1459,9 @@ Change I/O throttle limits for a block drive.
Arguments:
-- "device": device name (json-string)
+- "device": block device name (deprecated, use @id instead)
+ (json-string, optional)
+- "id": the name or QOM path of the guest device (json-string, optional)
- "bps": total throughput limit in bytes per second (json-int)
- "bps_rd": read throughput limit in bytes per second (json-int)
- "bps_wr": write throughput limit in bytes per second (json-int)
@@ -1483,7 +1485,7 @@ Arguments:
Example:
--> { "execute": "block_set_io_throttle", "arguments": { "device": "virtio0",
+-> { "execute": "block_set_io_throttle", "arguments": { "id": "ide0-1-0",
"bps": 1000000,
"bps_rd": 0,
"bps_wr": 0,
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 1d7d4cc..5f04dab 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1377,7 +1377,9 @@
#
# A set of parameters describing block throttling.
#
-# @device: The name of the device
+# @device: #optional Block device name (deprecated, use @id instead)
+#
+# @id: #optional The name or QOM path of the guest device (since: 2.8)
#
# @bps: total throughput limit in bytes per second
#
@@ -1446,8 +1448,8 @@
# Since: 1.1
##
{ 'struct': 'BlockIOThrottle',
- 'data': { 'device': 'str', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
- 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
+ 'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int',
+ 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
'*bps_max': 'int', '*bps_rd_max': 'int',
'*bps_wr_max': 'int', '*iops_max': 'int',
'*iops_rd_max': 'int', '*iops_wr_max': 'int',
--
1.8.3.1
- [Qemu-devel] [PULL 14/33] qdev-monitor: Add blk_by_qdev_id(), (continued)
- [Qemu-devel] [PULL 14/33] qdev-monitor: Add blk_by_qdev_id(), Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 16/33] block: Accept device model name for x-blockdev-insert-medium, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 15/33] block: Accept device model name for blockdev-open/close-tray, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 17/33] block: Accept device model name for x-blockdev-remove-medium, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 18/33] block: Accept device model name for eject, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 19/33] block: Accept device model name for blockdev-change-medium, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 21/33] qemu-iotests/118: Test media change with qdev name, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 25/33] qemu-iotests/081: Avoid blockdev-add with id, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 23/33] qemu-iotests/067: Avoid blockdev-add with id, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 22/33] qemu-iotests/041: Avoid blockdev-add with id, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 20/33] block: Accept device model name for block_set_io_throttle,
Kevin Wolf <=
- [Qemu-devel] [PULL 26/33] qemu-iotests/087: Avoid blockdev-add with id, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 24/33] qemu-iotests/071: Avoid blockdev-add with id, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 27/33] qemu-iotests/117: Avoid blockdev-add with id, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 28/33] qemu-iotests/118: Avoid blockdev-add with id, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 29/33] qemu-iotests/124: Avoid blockdev-add with id, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 32/33] qemu-iotests/141: Avoid blockdev-add with id, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 33/33] block: Remove BB interface from blockdev-add/del, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 30/33] qemu-iotests/139: Avoid blockdev-add with id, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 31/33] block: Avoid printing NULL string in error messages, Kevin Wolf, 2016/09/22
- Re: [Qemu-devel] [PULL 00/33] Block layer patches, Peter Maydell, 2016/09/23