yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-blockdev-Rename-I-O-throttling-options-for-QMP.patch

218e99
From 6407962af839506d7dcd956d48986324264a3587 Mon Sep 17 00:00:00 2001
218e99
From: Kevin Wolf <kwolf@redhat.com>
218e99
Date: Mon, 9 Sep 2013 14:28:19 +0200
218e99
Subject: [PATCH 28/38] blockdev: Rename I/O throttling options for QMP
218e99
218e99
RH-Author: Kevin Wolf <kwolf@redhat.com>
218e99
Message-id: <1378736903-18489-29-git-send-email-kwolf@redhat.com>
218e99
Patchwork-id: 54215
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH 28/32] blockdev: Rename I/O throttling options for QMP
218e99
Bugzilla: 1005818
218e99
RH-Acked-by: Fam Zheng <famz@redhat.com>
218e99
RH-Acked-by: Max Reitz <mreitz@redhat.com>
218e99
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
218e99
Bugzilla: 1005818
218e99
218e99
In QMP, we want to use dashes instead of underscores in QMP argument
218e99
names, and use nested options for throttling.
218e99
218e99
The new option names affect the command line as well, but for
218e99
compatibility drive_init() will convert the old option names before
218e99
calling into the code that will be shared between -drive and
218e99
blockdev-add.
218e99
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
Reviewed-by: Eric Blake <eblake@redhat.com>
218e99
(cherry picked from commit 57975222b6a928dd4a4a8a7b37093cc8ecba5045)
218e99
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
---
218e99
 blockdev.c | 52 +++++++++++++++++++++++++++++++++++++++-------------
218e99
 1 file changed, 39 insertions(+), 13 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 blockdev.c |   52 +++++++++++++++++++++++++++++++++++++++-------------
218e99
 1 files changed, 39 insertions(+), 13 deletions(-)
218e99
218e99
diff --git a/blockdev.c b/blockdev.c
218e99
index 1c9ca4d..08b1aaf 100644
218e99
--- a/blockdev.c
218e99
+++ b/blockdev.c
218e99
@@ -312,7 +312,8 @@ static bool do_check_io_limits(BlockIOLimit *io_limits, Error **errp)
218e99
     return true;
218e99
 }
218e99
 
218e99
-DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
218e99
+static DriveInfo *blockdev_init(QemuOpts *all_opts,
218e99
+                                BlockInterfaceType block_default_type)
218e99
 {
218e99
     const char *buf;
218e99
     const char *file = NULL;
218e99
@@ -485,17 +486,17 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
218e99
 
218e99
     /* disk I/O throttling */
218e99
     io_limits.bps[BLOCK_IO_LIMIT_TOTAL]  =
218e99
-                           qemu_opt_get_number(opts, "bps", 0);
218e99
+        qemu_opt_get_number(opts, "throttling.bps-total", 0);
218e99
     io_limits.bps[BLOCK_IO_LIMIT_READ]   =
218e99
-                           qemu_opt_get_number(opts, "bps_rd", 0);
218e99
+        qemu_opt_get_number(opts, "throttling.bps-read", 0);
218e99
     io_limits.bps[BLOCK_IO_LIMIT_WRITE]  =
218e99
-                           qemu_opt_get_number(opts, "bps_wr", 0);
218e99
+        qemu_opt_get_number(opts, "throttling.bps-write", 0);
218e99
     io_limits.iops[BLOCK_IO_LIMIT_TOTAL] =
218e99
-                           qemu_opt_get_number(opts, "iops", 0);
218e99
+        qemu_opt_get_number(opts, "throttling.iops-total", 0);
218e99
     io_limits.iops[BLOCK_IO_LIMIT_READ]  =
218e99
-                           qemu_opt_get_number(opts, "iops_rd", 0);
218e99
+        qemu_opt_get_number(opts, "throttling.iops-read", 0);
218e99
     io_limits.iops[BLOCK_IO_LIMIT_WRITE] =
218e99
-                           qemu_opt_get_number(opts, "iops_wr", 0);
218e99
+        qemu_opt_get_number(opts, "throttling.iops-write", 0);
218e99
 
218e99
     if (!do_check_io_limits(&io_limits, &error)) {
218e99
         error_report("%s", error_get_pretty(error));
218e99
@@ -726,6 +727,31 @@ err:
218e99
     return NULL;
218e99
 }
218e99
 
218e99
+static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to)
218e99
+{
218e99
+    const char *value;
218e99
+
218e99
+    value = qemu_opt_get(opts, from);
218e99
+    if (value) {
218e99
+        qemu_opt_set(opts, to, value);
218e99
+        qemu_opt_unset(opts, from);
218e99
+    }
218e99
+}
218e99
+
218e99
+DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
218e99
+{
218e99
+    /* Change legacy command line options into QMP ones */
218e99
+    qemu_opt_rename(all_opts, "iops", "throttling.iops-total");
218e99
+    qemu_opt_rename(all_opts, "iops_rd", "throttling.iops-read");
218e99
+    qemu_opt_rename(all_opts, "iops_wr", "throttling.iops-write");
218e99
+
218e99
+    qemu_opt_rename(all_opts, "bps", "throttling.bps-total");
218e99
+    qemu_opt_rename(all_opts, "bps_rd", "throttling.bps-read");
218e99
+    qemu_opt_rename(all_opts, "bps_wr", "throttling.bps-write");
218e99
+
218e99
+    return blockdev_init(all_opts, block_default_type);
218e99
+}
218e99
+
218e99
 void do_commit(Monitor *mon, const QDict *qdict)
218e99
 {
218e99
     const char *device = qdict_get_str(qdict, "device");
218e99
@@ -1679,27 +1705,27 @@ QemuOptsList qemu_common_drive_opts = {
218e99
             .type = QEMU_OPT_BOOL,
218e99
             .help = "open drive file as read-only",
218e99
         },{
218e99
-            .name = "iops",
218e99
+            .name = "throttling.iops-total",
218e99
             .type = QEMU_OPT_NUMBER,
218e99
             .help = "limit total I/O operations per second",
218e99
         },{
218e99
-            .name = "iops_rd",
218e99
+            .name = "throttling.iops-read",
218e99
             .type = QEMU_OPT_NUMBER,
218e99
             .help = "limit read operations per second",
218e99
         },{
218e99
-            .name = "iops_wr",
218e99
+            .name = "throttling.iops-write",
218e99
             .type = QEMU_OPT_NUMBER,
218e99
             .help = "limit write operations per second",
218e99
         },{
218e99
-            .name = "bps",
218e99
+            .name = "throttling.bps-total",
218e99
             .type = QEMU_OPT_NUMBER,
218e99
             .help = "limit total bytes per second",
218e99
         },{
218e99
-            .name = "bps_rd",
218e99
+            .name = "throttling.bps-read",
218e99
             .type = QEMU_OPT_NUMBER,
218e99
             .help = "limit read bytes per second",
218e99
         },{
218e99
-            .name = "bps_wr",
218e99
+            .name = "throttling.bps-write",
218e99
             .type = QEMU_OPT_NUMBER,
218e99
             .help = "limit write bytes per second",
218e99
         },{
218e99
-- 
218e99
1.7.1
218e99