qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] qemu-img: add support for offline rate limit in qemu-img commit
@ 2020-10-18  5:31 Zhengui li
  2020-10-18  5:36 ` no-reply
  0 siblings, 1 reply; 2+ messages in thread
From: Zhengui li @ 2020-10-18  5:31 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>
---
 qemu-img-cmds.hx |  4 ++--
 qemu-img.c       | 14 ++++++++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
index b89c019..ed55b76 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] [-s speed] [-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] [-s SPEED] [-d] [-p] FILENAME
 ERST
 
 DEF("compare", img_compare,
diff --git a/qemu-img.c b/qemu-img.c
index 2103507..67c83b47 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:dpqs:",
                         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 's': {
+            char *end;
+            unsigned long long sval = strtoull(optarg, &end, 10);
+            if (*end != '\0' || sval > UINT_MAX) {
+                error_report("rate limit parse failed");
+                return 1;
+            }
+            rate_limit = (int64_t)sval * 1024 * 1024;
+        }   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);
-- 
1.8.3.1



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

* Re: [PATCH] qemu-img: add support for offline rate limit in qemu-img commit
  2020-10-18  5:31 [PATCH] qemu-img: add support for offline rate limit in qemu-img commit Zhengui li
@ 2020-10-18  5:36 ` no-reply
  0 siblings, 0 replies; 2+ messages in thread
From: no-reply @ 2020-10-18  5:36 UTC (permalink / raw)
  To: lizhengui
  Cc: kwolf, xieyingtai, lizhengui, qemu-block, qemu-devel, mreitz,
	stefanha, pbonzini

Patchew URL: https://patchew.org/QEMU/1602999097-24744-1-git-send-email-lizhengui@huawei.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 1602999097-24744-1-git-send-email-lizhengui@huawei.com
Subject: [PATCH] qemu-img: add support for offline rate limit in qemu-img commit

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]         patchew/1602999097-24744-1-git-send-email-lizhengui@huawei.com -> patchew/1602999097-24744-1-git-send-email-lizhengui@huawei.com
Switched to a new branch 'test'
ffdac92 qemu-img: add support for offline rate limit in qemu-img commit

=== OUTPUT BEGIN ===
ERROR: consider using qemu_strtoull in preference to strtoull
#59: FILE: qemu-img.c:1032:
+            unsigned long long sval = strtoull(optarg, &end, 10);

total: 1 errors, 0 warnings, 49 lines checked

Commit ffdac92f0f39 (qemu-img: add support for offline rate limit in qemu-img commit) has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/1602999097-24744-1-git-send-email-lizhengui@huawei.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

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

end of thread, other threads:[~2020-10-18  5:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-18  5:31 [PATCH] qemu-img: add support for offline rate limit in qemu-img commit Zhengui li
2020-10-18  5:36 ` no-reply

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