qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] qemu-img: add add support for rate limit in commit and convert
@ 2020-10-20 14:39 Zhengui li
  2020-10-20 14:39 ` [PATCH v2 1/2] qemu-img: add support for rate limit in qemu-img commit Zhengui li
  2020-10-20 14:39 ` [PATCH v2 2/2] qemu-img: add support for rate limit in qemu-img convert Zhengui li
  0 siblings, 2 replies; 5+ messages in thread
From: Zhengui li @ 2020-10-20 14:39 UTC (permalink / raw)
  To: pbonzini, stefanha, mreitz, kwolf
  Cc: xieyingtai, lizhengui, qemu-devel, qemu-block

Currently, there is no rate limit for qemu-img commit and convert. This may
cause the task of qemu-img commit and convert to consume all the bandwidth
of the storage. This will affect the IO performance of other processes
and virtual machines under shared storage.

The following patches add support for rate limit in qemu-img commit and
convert to get better quality of sevice.

Zhengui Li (2):
  qemu-img: add support for rate limit in qemu-img commit
  qemu-img: add support for rate limit in qemu-img convert

 docs/tools/qemu-img.rst | 10 ++++++++--
 qemu-img-cmds.hx        |  8 ++++----
 qemu-img.c              | 38 +++++++++++++++++++++++++++++++++++---
 3 files changed, 47 insertions(+), 9 deletions(-)

-- 
2.6.4.windows.1



^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH v2 1/2] qemu-img: add support for offline rate limit in qemu-img commit
@ 2020-10-20 11:39 Zhengui li
  2020-10-20 11:39 ` [PATCH v2 2/2] qemu-img: add support for rate limit in qemu-img convert Zhengui li
  0 siblings, 1 reply; 5+ messages in thread
From: Zhengui li @ 2020-10-20 11:39 UTC (permalink / raw)
  To: pbonzini, stefanha, mreitz, kwolf
  Cc: xieyingtai, lizhengui, qemu-devel, qemu-block

From: Zhengui <lizhengui@huawei.com>

Currently, there is no rate limit for qemu-img commit. This may
cause the task of qemu-img commit to consume all the bandwidth
of the storage. This will affect the IO performance of other processes
and virtual machines under shared storage. So we add support for
offline rate limit in qemu-img commit to get better quality of sevice.

Signed-off-by: Zhengui <lizhengui@huawei.com>
---
 docs/tools/qemu-img.rst |  4 +++-
 qemu-img-cmds.hx        |  4 ++--
 qemu-img.c              | 14 ++++++++++++--
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
index c35bd64..bcb11b0 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -349,7 +349,7 @@ Command description:
   state after (the attempt at) repairing it. That is, a successful ``-r all``
   will yield the exit code 0, independently of the image state before.
 
-.. option:: commit [--object OBJECTDEF] [--image-opts] [-q] [-f FMT] [-t CACHE] [-b BASE] [-d] [-p] FILENAME
+.. option:: commit [--object OBJECTDEF] [--image-opts] [-q] [-f FMT] [-t CACHE] [-b BASE] [-r RATE_LIMIT] [-d] [-p] FILENAME
 
   Commit the changes recorded in *FILENAME* in its base image or backing file.
   If the backing file is smaller than the snapshot, then the backing file will be
@@ -371,6 +371,8 @@ Command description:
   garbage data when read. For this reason, ``-b`` implies ``-d`` (so that
   the top image stays valid).
 
+  The rate limit for the commit process is specified by ``-r``.
+
 .. option:: compare [--object OBJECTDEF] [--image-opts] [-f FMT] [-F FMT] [-T SRC_CACHE] [-p] [-q] [-s] [-U] FILENAME1 FILENAME2
 
   Check if two images have the same content. You can compare images with
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
index b89c019..2a31806 100644
--- a/qemu-img-cmds.hx
+++ b/qemu-img-cmds.hx
@@ -34,9 +34,9 @@ SRST
 ERST
 
 DEF("commit", img_commit,
-    "commit [--object objectdef] [--image-opts] [-q] [-f fmt] [-t cache] [-b base] [-d] [-p] filename")
+    "commit [--object objectdef] [--image-opts] [-q] [-f fmt] [-t cache] [-b base] [-r rate_limit] [-d] [-p] filename")
 SRST
-.. option:: commit [--object OBJECTDEF] [--image-opts] [-q] [-f FMT] [-t CACHE] [-b BASE] [-d] [-p] FILENAME
+.. option:: commit [--object OBJECTDEF] [--image-opts] [-q] [-f FMT] [-t CACHE] [-b BASE] [-r RATE_LIMIT] [-d] [-p] FILENAME
 ERST
 
 DEF("compare", img_compare,
diff --git a/qemu-img.c b/qemu-img.c
index 2103507..ea66139 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -980,6 +980,7 @@ static int img_commit(int argc, char **argv)
     CommonBlockJobCBInfo cbi;
     bool image_opts = false;
     AioContext *aio_context;
+    int64_t rate_limit = 0;
 
     fmt = NULL;
     cache = BDRV_DEFAULT_CACHE;
@@ -991,7 +992,7 @@ static int img_commit(int argc, char **argv)
             {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS},
             {0, 0, 0, 0}
         };
-        c = getopt_long(argc, argv, ":f:ht:b:dpq",
+        c = getopt_long(argc, argv, ":f:ht:b:dpqr:",
                         long_options, NULL);
         if (c == -1) {
             break;
@@ -1026,6 +1027,15 @@ static int img_commit(int argc, char **argv)
         case 'q':
             quiet = true;
             break;
+        case 'r': {
+            int64_t sval;
+
+            sval = cvtnum("rate limit", optarg);
+            if (sval < 0) {
+                return 1;
+            }
+            rate_limit = sval;
+        }   break;
         case OPTION_OBJECT: {
             QemuOpts *opts;
             opts = qemu_opts_parse_noisily(&qemu_object_opts,
@@ -1099,7 +1109,7 @@ static int img_commit(int argc, char **argv)
 
     aio_context = bdrv_get_aio_context(bs);
     aio_context_acquire(aio_context);
-    commit_active_start("commit", bs, base_bs, JOB_DEFAULT, 0,
+    commit_active_start("commit", bs, base_bs, JOB_DEFAULT, rate_limit,
                         BLOCKDEV_ON_ERROR_REPORT, NULL, common_block_job_cb,
                         &cbi, false, &local_err);
     aio_context_release(aio_context);
-- 
2.6.4.windows.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-10-20 14:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-20 14:39 [PATCH v2 0/2] qemu-img: add add support for rate limit in commit and convert Zhengui li
2020-10-20 14:39 ` [PATCH v2 1/2] qemu-img: add support for rate limit in qemu-img commit Zhengui li
2020-10-20 14:39 ` [PATCH v2 2/2] qemu-img: add support for rate limit in qemu-img convert Zhengui li
  -- strict thread matches above, loose matches on Subject: below --
2020-10-20 11:39 [PATCH v2 1/2] qemu-img: add support for offline rate limit in qemu-img commit Zhengui li
2020-10-20 11:39 ` [PATCH v2 2/2] qemu-img: add support for rate limit in qemu-img convert Zhengui li
2020-10-20 12:13   ` Alberto Garcia

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).