From: Max Reitz <mreitz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH 2/8] qemu-img: Add progress output for amend
Date: Fri, 25 Jul 2014 20:07:39 +0200 [thread overview]
Message-ID: <1406311665-2814-3-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1406311665-2814-1-git-send-email-mreitz@redhat.com>
Now that bdrv_amend_options() supports a status callback, use it to
display a progress report.
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
qemu-img.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 90d6b79..a06f425 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2732,6 +2732,13 @@ out:
return 0;
}
+static void amend_status_cb(BlockDriverState *bs,
+ int64_t offset, int64_t total_work_size)
+{
+ (void)bs;
+ qemu_progress_print(100.f * offset / total_work_size, 0);
+}
+
static int img_amend(int argc, char **argv)
{
int c, ret = 0;
@@ -2740,12 +2747,12 @@ static int img_amend(int argc, char **argv)
QemuOpts *opts = NULL;
const char *fmt = NULL, *filename, *cache;
int flags;
- bool quiet = false;
+ bool quiet = false, progress = false;
BlockDriverState *bs = NULL;
cache = BDRV_DEFAULT_CACHE;
for (;;) {
- c = getopt(argc, argv, "ho:f:t:q");
+ c = getopt(argc, argv, "ho:f:t:pq");
if (c == -1) {
break;
}
@@ -2775,6 +2782,9 @@ static int img_amend(int argc, char **argv)
case 't':
cache = optarg;
break;
+ case 'p':
+ progress = true;
+ break;
case 'q':
quiet = true;
break;
@@ -2785,6 +2795,11 @@ static int img_amend(int argc, char **argv)
error_exit("Must specify options (-o)");
}
+ if (quiet) {
+ progress = false;
+ }
+ qemu_progress_init(progress, 1.0);
+
filename = (optind == argc - 1) ? argv[argc - 1] : NULL;
if (fmt && has_help_option(options)) {
/* If a format is explicitly specified (and possibly no filename is
@@ -2827,13 +2842,18 @@ static int img_amend(int argc, char **argv)
goto out;
}
- ret = bdrv_amend_options(bs, opts, NULL);
+ /* In case the driver does not call amend_status_cb() */
+ qemu_progress_print(0.f, 0);
+ ret = bdrv_amend_options(bs, opts, &amend_status_cb);
+ qemu_progress_print(100.f, 0);
if (ret < 0) {
error_report("Error while amending options: %s", strerror(-ret));
goto out;
}
out:
+ qemu_progress_end();
+
if (bs) {
bdrv_unref(bs);
}
--
2.0.1
next prev parent reply other threads:[~2014-07-25 18:07 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-25 18:07 [Qemu-devel] [PATCH 0/8] block/qcow2: Improve (?) zero cluster expansion Max Reitz
2014-07-25 18:07 ` [Qemu-devel] [PATCH 1/8] block: Add status callback to bdrv_amend_options() Max Reitz
2014-07-30 14:50 ` Eric Blake
2014-07-25 18:07 ` Max Reitz [this message]
2014-07-30 14:55 ` [Qemu-devel] [PATCH 2/8] qemu-img: Add progress output for amend Eric Blake
2014-07-30 20:20 ` Max Reitz
2014-07-25 18:07 ` [Qemu-devel] [PATCH 3/8] qemu-img: Fix insignifcant memleak Max Reitz
2014-07-30 14:56 ` Eric Blake
2014-07-25 18:07 ` [Qemu-devel] [PATCH 4/8] block/qcow2: Make get_refcount() global Max Reitz
2014-07-30 15:04 ` Eric Blake
2014-07-25 18:07 ` [Qemu-devel] [PATCH 5/8] block/qcow2: Implement status CB for amend Max Reitz
2014-07-30 15:23 ` Eric Blake
2014-07-25 18:07 ` [Qemu-devel] [PATCH 6/8] block/qcow2: Simplify shared L2 handling in amend Max Reitz
2014-07-30 15:36 ` Eric Blake
2014-07-25 18:07 ` [Qemu-devel] [PATCH 7/8] block/qcow2: Speed up zero cluster expansion Max Reitz
2014-07-30 16:14 ` Eric Blake
2014-07-30 20:31 ` Max Reitz
2014-07-30 20:31 ` Eric Blake
2014-07-30 20:41 ` Max Reitz
2014-07-25 18:07 ` [Qemu-devel] [PATCH 8/8] iotests: Expand test 061 Max Reitz
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=1406311665-2814-3-git-send-email-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).