qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, eblake@redhat.com, mreitz@redhat.com,
	jsnow@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 09/10] block: Accept device model name for block_set_io_throttle
Date: Mon, 19 Sep 2016 18:54:56 +0200	[thread overview]
Message-ID: <1474304097-5790-10-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1474304097-5790-1-git-send-email-kwolf@redhat.com>

In order to remove the necessity to use 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 <kwolf@redhat.com>
---
 blockdev.c           | 12 +++++++-----
 qapi/block-core.json |  8 +++++---
 qmp-commands.hx      |  8 +++++---
 3 files changed, 17 insertions(+), 11 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/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',
diff --git a/qmp-commands.hx b/qmp-commands.hx
index cf1ffc5..9b8696c 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2084,7 +2084,7 @@ EQMP
 
     {
         .name       = "block_set_io_throttle",
-        .args_type  = "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l,iops_wr:l,bps_max:l?,bps_rd_max:l?,bps_wr_max:l?,iops_max:l?,iops_rd_max:l?,iops_wr_max:l?,bps_max_length:l?,bps_rd_max_length:l?,bps_wr_max_length:l?,iops_max_length:l?,iops_rd_max_length:l?,iops_wr_max_length:l?,iops_size:l?,group:s?",
+        .args_type  = "device:B?,id:s?,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l,iops_wr:l,bps_max:l?,bps_rd_max:l?,bps_wr_max:l?,iops_max:l?,iops_rd_max:l?,iops_wr_max:l?,bps_max_length:l?,bps_rd_max_length:l?,bps_wr_max_length:l?,iops_max_length:l?,iops_rd_max_length:l?,iops_wr_max_length:l?,iops_size:l?,group:s?",
         .mhandler.cmd_new = qmp_marshal_block_set_io_throttle,
     },
 
@@ -2096,7 +2096,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)
@@ -2120,7 +2122,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,
-- 
1.8.3.1

  parent reply	other threads:[~2016-09-19 16:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-19 16:54 [Qemu-devel] [PATCH v2 00/10] block: Accept qdev IDs in device level QMP commands Kevin Wolf
2016-09-19 16:54 ` [Qemu-devel] [PATCH v2 01/10] block: Add blk_by_dev() Kevin Wolf
2016-09-19 16:54 ` [Qemu-devel] [PATCH v2 02/10] qdev-monitor: Factor out find_device_state() Kevin Wolf
2016-09-19 16:54 ` [Qemu-devel] [PATCH v2 03/10] qdev-monitor: Add blk_by_qdev_id() Kevin Wolf
2016-09-19 16:54 ` [Qemu-devel] [PATCH v2 04/10] block: Accept device model name for blockdev-open/close-tray Kevin Wolf
2016-09-19 19:28   ` Eric Blake
2016-09-20 11:05     ` Kevin Wolf
2016-09-19 16:54 ` [Qemu-devel] [PATCH v2 05/10] block: Accept device model name for x-blockdev-insert-medium Kevin Wolf
2016-09-19 16:54 ` [Qemu-devel] [PATCH v2 06/10] block: Accept device model name for x-blockdev-remove-medium Kevin Wolf
2016-09-19 19:32   ` Eric Blake
2016-09-19 16:54 ` [Qemu-devel] [PATCH v2 07/10] block: Accept device model name for eject Kevin Wolf
2016-09-19 19:33   ` Eric Blake
2016-09-19 16:54 ` [Qemu-devel] [PATCH v2 08/10] block: Accept device model name for blockdev-change-medium Kevin Wolf
2016-09-19 19:34   ` Eric Blake
2016-09-19 16:54 ` Kevin Wolf [this message]
2016-09-19 19:35   ` [Qemu-devel] [PATCH v2 09/10] block: Accept device model name for block_set_io_throttle Eric Blake
2016-09-19 16:54 ` [Qemu-devel] [PATCH v2 10/10] qemu-iotests/118: Test media change with qdev name Kevin Wolf
2016-09-19 19:38   ` Eric Blake
2016-09-19 19:15 ` [Qemu-devel] [PATCH v2 00/10] block: Accept qdev IDs in device level QMP commands no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474304097-5790-10-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).